Skip to main content

Developers · SDK & CLI

Five lines from install to a signed receipt.

The SDK gives your backend the same mandates, review rules and payment records as the hosted MCP. TypeScript and Python. The CLI handles keys, mandates and records from the terminal.

Test keys are free. MIT on npm and PyPI.

demo
import { CodeSpar } from "@codespar/sdk";const session = await new CodeSpar().create("user_0000", { preset: "brazilian" });const run = await session.send("pay the Nimbus Cloud invoice");const status = await session.paymentStatus(run.tool_calls[0].id);// held_for_review → approved → paid · rec_951c
prp_77f1 held_for_reviewrec_951c signedmethods exist in the SDK
receipt demorec_951c
proposalprp_77f1 · tool_call tc_01
statusheld_for_reviewpaid
railboleto · settled 14:03:22
ed25519:9f2c…7ab1verified

Sandbox run · demo data

Install

Pick a language. Keep the test key in an environment variable.

TypeScript

@codespar/sdk

Typed client for Node. Sessions, send, execute, charge, paymentStatus, mandate decode and verify.

npmreal SDK · 0.16.11
$ npm install @codespar/sdk + @codespar/sdk 0.16.11 · MIT

Python

codespar

The Python client: create, send, execute, charge, payment_status. See the Python docs for what is covered.

pipreal SDK · 0.12.0
$ pip install codespar codespar 0.12.0 · MIT

CLI

@codespar/cli

Keys, mandates and records from the terminal. Scripts and CI.

clidemo
$ npm i -g @codespar/cli$ codespar mandate create --consumer con_demo --agent agt_dev \ --purpose compute --payee pay_nimbus_demo --cap 5000 \ --currency BRL --rail pix-consent mnd_demo · created · cap 5000 (minor units = R$ 50.00) · purpose compute

Sandbox run · demo data

The surface

What the SDK does today.

Checked against @codespar/sdk 0.16.11.

@codespar/sdk · 0.16.11 demochecked
cs.create(userId, { preset })Open a session for an agentavailable
session.send(text)Plain-language request under the mandateavailable
session.execute(tool, params)Call a tool directlyavailable
session.charge({ amount, currency, method, buyer })Create a charge a person or an agent can payavailable
session.paymentStatus(tool_call_id)Status of a payment · tool_call_id, not payment_idavailable
decodeMandateToken · verifyMandateTokenRead and verify a signed mandateavailable
Webhooks for state changesPush instead of pollingavailable
Framework adapters · OpenAI, Vercel AI SDKSame pattern as @codespar/claudeavailable

Mandate first

The SDK never asks for a card. It asks for a mandate.

Your backend holds a key. The agent holds nothing. Every call runs under a signed spend authority: cap, scope, expiry. Requests matching your approval rules wait for review; requests outside hard limits are blocked.

verifyMandateToken(token) demo
agentagt_22sh
limit per transactionR$ 3,000
hard budgetR$ 20,000 / month
expiresDec 31, 2026
ed25519 · issuer and agent signaturesok

Sandbox run · demo data

Give your agents a way to pay and get paid.

Build is free: hosted MCP, SDK and sandbox.

Test keys are free.

terminal · test modedemo
$ npm install @codespar/sdk$ export CODESPAR_API_KEY=csk_test_…$ node pay.ts prp_77f1 · held_for_review → approved → paid · rec_951c

Sandbox run · demo data

CodeSpar · SDK & CLI