Mandate gives your AI agent a verified identity and a spending policy that sellers can trust. This guide walks you through every step — from signing up to making your first authenticated payment — entirely in the sandbox. No real USDC required.Documentation Index
Fetch the complete documentation index at: https://docs.usemandate.io/llms.txt
Use this file to discover all available pages before exploring further.
Sandbox API keys start with
ky_sand_. Every request in this guide uses the sandbox environment. No real money moves until you switch to a production key.Create an account
Sign up at usemandate.xyz. After email verification, the dashboard creates your account and issues a sandbox API key automatically.Your sandbox API key looks like this:Store this key in a
.env file or your secrets manager. The dashboard will not show it again after the initial display..env
Install the SDK
Install the Mandate SDK with your package manager:The SDK exports
npm
pnpm
yarn
KyaPaymentsClient — the main class your agent uses to make payments — along with typed error classes for handling policy denials and payment failures.Register an agent
Before your agent can pay for anything, you need to register it. Each registered agent gets a stable The response includes your agent’s ID:Copy the
agent_id that sellers can verify independently.Send a POST /v1/agents request with a name, an optional description, and any capability tags:curl
id — you’ll use it as agent_id in every mandate and payment request.Create a mandate
A mandate is the spending policy attached to your agent. It defines what the agent is allowed to spend, where, and for how long. You must have an active mandate before the policy engine will approve any payment.The response confirms the mandate and returns its ID:
curl
| Field | Description |
|---|---|
max_spend_total | Total USDC budget for the lifetime of this mandate |
max_spend_per_transaction | Maximum USDC for any single payment |
allowed_sellers | Domain allowlist — empty array means any seller is permitted |
allowed_categories | Category allowlist — empty array means any category is permitted |
expires_at | ISO 8601 timestamp after which the mandate is automatically revoked |
Make your first payment
With an agent registered and a mandate in place, your agent can now make authenticated payments. Import Under the hood,
KyaPaymentsClient and call fetchWithPayment — the SDK handles the full x402 challenge–policy–proof cycle automatically.fetchWithPayment does the following:- Sends the initial request — if the server returns
200, it returns the response immediately. - If the server returns
402, it parses the payment challenge from the response headers. - Calls
POST /v1/policy/evaluateto check the transaction against your mandate. - If the policy engine approves, calls
POST /v1/payments/proofto get a signed proof. - Retries the original request with
X-Payment-ProofandX-Kya-Agent-Idheaders attached.

