UniversalEscrow
DocumentationAPI reference

SDK guide

A typed TypeScript client over the same REST API. It saves you writing request plumbing and signature verification — it does not do anything you couldn't do with fetch.

Install

npm
npm install ./escrow-sdk-0.2.0.tgz

The SDK is distributed as a package file while public npm publishing is not available. It has no runtime dependencies and needs Node 22 or later.

Not on Node.js? You don't need the SDK. A backend in PHP, Python, Ruby, Java, .NET or Go makes the same requests with its own HTTP client — any language shows each one, with the SDK method it replaces.

Create an escrow

TypeScript
import { EscrowClient } from '@escrow/sdk';

const escrow = new EscrowClient({
  apiKey: process.env.ESCROW_API_KEY!,   // server-side only
  baseUrl: process.env.ESCROW_API_BASE!,
});

const order = await escrow.escrows.create(
  {
    amount: '1000000',            // atomic units — 1.000000 USDC
    currency: 'USDC',
    buyerWallet: '0x7099...79C8',
    sellerWallet: '0x3C44...93BC',
    externalReference: 'order-4417',
  },
  { idempotencyKey: 'order-4417' },
);

// Hand this to the buyer. It needs no account.
return order.checkoutUrl;

Server-side only. An API key in a browser is a key you have given away — the client is built for your backend. Buyers never need one: the checkout link carries no credential at all.

Verify a webhook

Signatures are computed over the raw request body. Parse it after verifying, never before — a re-serialised object is a different byte string and will not match. The webhooks guide shows the same check without the SDK.

TypeScript
import { verifySignature } from '@escrow/sdk';

app.post('/webhooks/escrow', express.raw({ type: 'application/json' }), (req, res) => {
  const ok = verifySignature(
    req.body.toString('utf8'),          // the RAW body, not the parsed object
    req.header('Escrow-Signature')!,
    process.env.ESCROW_WEBHOOK_SECRET!,
  );

  if (!ok) return res.sendStatus(400);

  const event = JSON.parse(req.body.toString('utf8'));
  if (event.type === 'escrow.funded') {
    // The money is on-chain and confirmed. Safe to fulfil the order.
  }

  res.sendStatus(204);
});

Handle failures

The two error types are worth distinguishing: one means the API rejected your request, the other means you never reached it — and only the second is safe to retry blindly, which is what idempotency keys are for.

TypeScript
import { EscrowApiError, EscrowNetworkError } from '@escrow/sdk';

try {
  await escrow.escrows.create(body, { idempotencyKey: key });
} catch (error) {
  if (error instanceof EscrowApiError) {
    // The API answered with an error envelope — inspect and decide.
  } else if (error instanceof EscrowNetworkError) {
    // Never reached the API. Retry with the SAME idempotency key.
  }
  throw error;
}

Resources on the client

escrow.escrows

create, list (filter by externalReference or groupId), retrieve, cancel, openDispute, and the intent/registration calls for funding, release and refund.

escrow.escrowGroups

create a milestone group of 2–20 escrows in one call, and retrieve it with every member and its progress.

escrow.sellerWallets

createVerification for a seller, retrieveVerification until it is VERIFIED, then list or retrieve verified wallets.

escrow.webhooks

register and update endpoints, testEndpoint, list events, inspect delivery attempts, replay an event, verifySignature.

escrow.disputes

retrieve a dispute and add evidence to it. Open one with escrows.openDispute.

escrow.transactions

read a transaction we are following, by id or by hash.

The package also exports every request and response type and the enums its responses use (EscrowStatus, WebhookEventType, …). There are no API-key methods: keys are managed in the dashboard only. Each resource maps directly onto the endpoints in the API reference.