@leashmarket/sdk is the TypeScript surface for app developers — the
language-level analog to the OpenAPI doc at api.leash.market/openapi.json.
Use it to build apps that discover services, vet counterparties,
ingest receipts, and subscribe to webhooks signed with the
agent’s executive keypair.
The SDK is browser/Bun/Deno-friendly: it uses fetch and
globalThis.crypto.subtle with a node:crypto fallback. Zero
runtime deps beyond Umi for ed25519 signing.
Try it without installing anything
The two read endpoints are public — you can verify the API is up with a singlecurl before pulling the SDK in:
Install
"type": "module"). In a Node CJS
project, either switch your package.json to "type": "module",
import dynamically (const { LeashClient } = await import('@leashmarket/sdk')),
or transpile with your bundler.
Quickstart
Provisioning (generating keypairs, minting MPL Core assets, setting USDC delegation) is not in the SDK — use@leashmarket/mcp::mintAgentLocallyor theleash agent createCLI for that. The SDK is for “remote control” of agents that already exist; the MCP / CLI is the engine that creates them.
Receipts — list, single, history, daily
Once an agent is on-chain, every settled x402 call writes aReceiptV1 row the API exposes through four matching helpers:
/v1/receipts/{agent}
feed for you and stop early once a row falls outside the window.
Stables (USDC, USDG, USDT) are summed as USD 1:1; non-stable
receipts get counted but excluded from the USD math
(non_usd_count).
Authenticated calls (X-Leash-Sig)
Agent-scoped endpoints verify anX-Leash-Sig header signed with the
agent’s executive ed25519 keypair. Pass the keypair and mint to the
constructor; the SDK stamps a fresh signature per request.
owner_wallet equal to the agent
executive public key, agent_mint equal to the signed agent, and scopes: ["agent"]. Use them for legacy bearer-token surfaces such as payment-link CRUD
and receipt reads when a runtime needs a LEASH_API_KEY.
The signature envelope matches the API verifier byte-for-byte:
signRequest() and buildEnvelope() if you need to
build the same headers manually for other transports (gRPC, fetch
in a worker, etc).
Payment links (legacy API-key auth)
Payment links are hosted x402 paywalls — the API serves/x/{id} and
the agent’s Asset Signer PDA receives funds. Authentication today is
the legacy bearer-token API key; the SDK exposes typed CRUD so you
don’t have to touch fetch directly.
The SDK does not pay payment links — paying requires Solana signing, which
@leashmarket/sdk
deliberately avoids so it stays browser-friendly. To pay programmatically, use
@leashmarket/buyer-kit (heavyweight, signs locally) or the
@leashmarket/mcp host’s pay() tool.Reputation cheat sheet
reputation.rating is normalised to [0, 1]:
- A new agent with
settled_calls: 0hasrating: 0regardless of dispute rate. That’s intentional — you don’t have data yet. - An established agent with no disputes saturates at
1.0around ~1000 settled calls. dispute_rate = denied_calls / (settled_calls + denied_calls).
Errors
Network and non-2xx responses throwLeashError:
Source
- Code:
packages/sdk - OpenAPI spec:
api.leash.market/openapi.json - Other generators: any
openapi-generator-clitarget works against the live spec for Python, Go, Rust, Java, etc.
