Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.keystoneos.xyz/llms.txt

Use this file to discover all available pages before exploring further.

KeyStone provides two types of client libraries, each designed for a different part of your stack:

Backend SDKs vs Frontend Packages

Backend SDKsFrontend Packages
Packages@keystoneos/sdk (TypeScript), keystoneos (Python)@keystoneos/react, @keystoneos/elements-core
Runs inYour server (Node.js, Python backend)Your user’s browser (React app)
AuthenticationM2M credentials (client_id + client_secret)Session tokens (short-lived, scoped JWTs)
PurposeFull API access - create settlements, manage webhooks, handle complianceDisplay settlement data, collect user decisions, trigger deposits
CredentialsMust be kept secret (never in browser)Safe for browser (scoped, short-lived, revocable)

Backend SDKs

For server-side integration. Use M2M credentials to access the full API.

TypeScript / Node.js

@keystoneos/sdk - Node.js 20+, zero dependencies. Handles auth, retries, idempotency, and webhook verification.

Python

keystoneos - Python 3.10+, async and sync clients. Full Pydantic models for all types.

What the SDKs handle

FeatureDetails
AuthenticationAuth0 M2M token fetch, caching, and automatic refresh before expiry
RetriesExponential backoff with jitter on 429 and 5xx. Respects Retry-After headers
IdempotencyBuilt-in generateIdempotencyKey() for safe retries on creation endpoints
Webhook verificationHMAC-SHA256 signature verification with timing-safe comparison
Type safetyFull TypeScript types / Pydantic models for all request and response objects
PaginationTyped paginated responses with items, total, limit, offset

Frontend Integration

Embed settlement UI into your platform’s web app. The frontend packages use session tokens (created by your backend) for scoped API access.

React Hooks

@keystoneos/react - Headless hooks for settlements, instructions, deposits. Bring your own UI.

Server Setup

@keystoneos/node - The backend side of the frontend integration: session tokens and webhook verification.

Components

KeystoneProvider - Wrap your app to enable all hooks.

What the frontend integration covers

LayerPackageWhat it does
Your backend@keystoneos/nodeCreates session tokens, verifies webhook signatures
Your frontend@keystoneos/reactReact hooks for settlements, instructions, deposits, templates
Core@keystoneos/elements-coreFramework-agnostic primitives (auth, events, state machine)

When to use what

ScenarioUse
Create settlements from your backend@keystoneos/sdk
Handle webhooks on your server@keystoneos/sdk or @keystoneos/node
Show settlement status to traders in your web app@keystoneos/react
Let traders submit instructions from your web app@keystoneos/react
Create session tokens for your frontend@keystoneos/node
Build a non-React frontend@keystoneos/elements-core
Call the API from a language without an SDKRaw HTTP (cURL, httpx, fetch)
Every endpoint in the API Reference works with any HTTP client. The SDKs and packages are convenience layers, not a separate API.

Quick comparison

import { KeystoneClient } from "@keystoneos/sdk";

// M2M auth - for your backend
const client = new KeystoneClient({
  clientId: process.env.KEYSTONE_CLIENT_ID!,
  clientSecret: process.env.KEYSTONE_CLIENT_SECRET!,
});

const instruction = await client.instructions.submit({
  templateSlug: "dvp-bilateral",
  role: "seller",
  party: { externalReference: "ACC-001", walletAddress: "0x..." },
  legs: [
    { legType: "asset_delivery", instrumentId: "0xTokenAddress", quantity: "1000000", direction: "deliver", chainId: 11155111 },
    { legType: "payment", instrumentId: "0xUSDCAddress", quantity: "1000000", direction: "receive", chainId: 11155111 },
  ],
  timeoutAt: new Date(Date.now() + 86400000).toISOString(),
  idempotencyKey: client.generateIdempotencyKey(),
});