← All documentation · Dashboard · REST API

JavaScript and TypeScript SDK

Dependency-free, typed, and compatible with Node.js 18+.

Install from the repository

git clone https://github.com/ssitdeveloper/zorqelio-monetization.git
cd zorqelio-monetization
npm install ./sdks/javascript

Authenticate

Create an account in the dashboard, then copy the one-time workspace API token into an environment variable. Use workspace API tokens for long-running server integrations; account sessions expire after 14 days.

export ZORQELIO_API_TOKEN="your-workspace-api-token"

Create a contract and validate a response

import { ZorqelioClient } from "@zorqelio/sdk";

const client = new ZorqelioClient(process.env.ZORQELIO_API_TOKEN);
const created = await client.createContract("Orders API", {
  type: "object",
  required: ["id", "status"],
  properties: { id: { type: "string" }, status: { type: "string" } }
});
const contractId = created.contract.contractId;
const result = await client.validate(contractId, { id: "ord_123", status: "paid" });
if (result.decision === "BLOCK") console.error(result.issues);

Monitor an API endpoint

const monitor = await client.createMonitor(contractId, "Orders API", {
  expectedIntervalMinutes: 15,
  endpointUrl: "https://api.example.com/orders/health"
});
console.log(monitor.monitor, monitor.authorization);

Scheduled checks accept public HTTPS JSON endpoints. Custom authentication headers and redirects are not supported. Omit endpointUrl to create a push monitor.

Methods

Errors and security

Failures throw ZorqelioError with HTTP status, error code and details. Keep tokens in environment variables or a secret manager; never put them in browser code.