POSTRecord
The user approves. Send the instruction, item, limit and recipient, and TheWavly signs it. An approved change becomes version 2, and both stay provable.
- Endpoint
/api/v0/mandates- Called by
- Agent builder
TheWavly API · v1
Record what the user approved as a signed mandate. Before the agent pays, check the purchase against it and get proceed, ask or stop, with a receipt anyone can verify.
API v1 · accounts, budgets, approvals
Create an account at /app to get a test key. Send it on every request. Test and live data never mix.
Authorization: Bearer sk_test_…
POST /v1/mandates
{
"instruction": "Buy Amma a saree for up to ₹2,500, at most ₹10,000 this month",
"approved_by": "user_7f3",
"rules": {
"items": ["Saree", "Silk saree"],
"max_amount_paise": 250000,
"budget_paise": 1000000,
"max_purchases": 5,
"payees": ["sarees@okhdfc"],
"deliver_to": "Amma"
},
"expires_in_seconds": 2592000
}
POST /v1/checks
Idempotency-Key: order-1042
{
"mandate": "mdt_…",
"purchase": { "item": "Saree", "amount_paise": 249900,
"payee": "sarees@okhdfc", "deliver_to": "Amma" }
}
The answer is proceed, ask or stop, with a result for every field and a receipt signed with your organisation’s Ed25519 key. On proceed the amount is held against the budget for 30 minutes. On ask the response carries approval.url: send it to the user, and the answer arrives by webhook or on GET /v1/checks/:id.
Every check also returns verify_url, a public page that verifies the receipt in the browser. It shows the answer, the amount and the time, but not the items or the user. Link it from your order confirmation with the badge: <a href="VERIFY_URL"><img src="https://thewavly.com/badge.svg" width="168" height="32" alt="Checked by TheWavly"></a>.
To make the check impossible to skip, even for an agent that has been talked into something, use TheWavly Guard. Put it in front of an MCP server’s order and payment tools, or wrap the function your payment tool runs in LangChain, the Vercel AI SDK or the OpenAI Agents SDK (guardFunction in JavaScript, thewavly.guard in Python). Either way, the amount comes from your own cart, not from the agent.
POST /v1/checks/chk_…/outcome
{ "status": "paid", "payment_reference": "UPI RRN 4416 2209" }
How each part of the API behaves, one card per topic. Open one, or read the full guides in the documentation.
| Field | If it fails |
|---|---|
| Mandate active (not revoked, expired or superseded) | stop |
| Item, UPI payee, merchant, deliver to, currency | stop |
| Amount above the per-purchase limit | ask |
| Paid plus held plus this purchase above the budget | ask |
| More purchases than allowed | ask |
Each request carries Wavly-Signature: t=<seconds>,v1=<hex>, the HMAC-SHA256 of t + "." + body with your endpoint secret. Reject anything older than five minutes.
A check that may proceed returns payment_token: a signed JWT for at most that amount, to that payee, until the 30-minute hold ends. The agent passes it to the payment provider. The provider needs no TheWavly key: it calls POST /v1/payment_tokens/redeem with the token, amount_paise, payee and payment_reference just before charging. TheWavly refuses a second use, a higher amount, another payee, or an expired or replaced token, and records the payment against the budget. TheWavly never moves money.
Send an open mandate as an SD-JWT presentation with the issuer’s keys: {"credential": "…~…~", "issuer_jwks": {"keys": […]}, "approved_by": "user_7f3"}, or issuer_jwks_url. TheWavly checks the issuer’s signature, the key that binds each later layer, and every disclosure against its digest. It maps amount range, budget, allowed payees and merchants, line items and agent recurrence onto its rules. A constraint it cannot enforce, or a currency other than INR, makes the import fail. Every check also returns ap2_receipt, an AP2 Mandate Receipt signed as a standard EdDSA JWT.
Price is rarely the whole instruction. A mandate can carry conditions on the terms the agent was shown: {"term": "refundable", "equals": true}, {"term": "free_cancellation_hours", "at_least": 24}, or one_of a list. The agent sends what it saw in purchase.terms. A term that fails the condition stops the check; a term the agent did not send makes it ask, and the approval page tells the user which condition could not be confirmed.
TheWavly never sees the money, so every paid check says who reported it in payment.confirmation: agent_reported (the outcome call), provider_redeemed (a payment token was redeemed: a charge requested), or debit_reconciled (a debit record reported to POST /v1/payments matched). If the charge fails after redemption, report failed on the check and it is released. None of these is a bank’s confirmation, and the API says so.
An API key says which company called; it does not say which agent. Register each agent’s public key with POST /v1/agents/shopbot/keys and {"jwk": {…}}, and have the agent sign every check. The signature goes in agent_signature: a compact JWS with typ wavly-check+jws over the mandate id, the SHA-256 of the purchase (keys sorted), the time and a one-time jti. Both SDKs do this for you (Wavly.signCheck, Wavly.sign_check). The check returns agent_verification, and the receipt names the agent and key. A forged, replayed or stale signature, or a revoked key, makes the check stop. Set require_agent_signature in a mandate’s rules to stop unsigned checks too. Ed25519 is the key type agents already publish for HTTP Message Signatures, so the same key can be reused.
A proceed is only useful if the money that moved matches it. Send each debit from your payment provider’s webhook, or from a bank statement, to POST /v1/payments with payment_reference, amount_paise and payee. TheWavly first matches it by reference, then to a check you name, then to a check that may proceed with the same payee and enough amount. The answer is matched, over_amount, or unchecked when money moved that no check allowed, including a second debit on a paid check. A matched debit marks its check paid. Every mandate also returns upi: the block amount, debit limit, validity and payees a matching UPI Reserve Pay block or One Time Mandate would use.
When a check answers ask, approval.share has ready links to send the approval page by WhatsApp or SMS, with the message in English and Hindi. The page itself is in Hindi when the phone’s language is Hindi, or with ?lang=hi, and the user can switch with one tap.
Every signed object TheWavly produces is documented at /spec: mandates, receipts, findings, evidence packs, payment tokens and agent signatures. Anyone may implement them. wavly-verify.mjs checks a whole evidence pack offline with no dependencies: node wavly-verify.mjs pack.json.
When a customer says an agent spent money it should not have, open a dispute on the check: {"check": "chk_…", "reason": "limit_breached", "description": "…", "charged_amount_paise": 260000}. Reasons follow the seven case types of TheWavly rulebook: no_authority, limit_breached, wrong_purchase, not_as_ordered, duplicate_payment, price_changed and unclear_instruction. TheWavly answers with a suggested finding, the facts behind it, and the next step: which party acts and through which channel, such as a merchant refund or a complaint in the payer’s UPI app. The first answer is due 24 hours after the complaint was received (pass received_at when a partner forwards it). A person then records the finding: agent_operator, merchant, payment_participant, shared, no_breach, insufficient_evidence or settled, with a remedy and who pays it. The finding is signed and lists the digest of every piece of evidence the reviewer had. Either side may appeal within 14 days; someone who did not take the first decision must decide the appeal. The evidence pack carries every dispute on the check.
Pass "agent": "shopbot-v2" on a mandate or a check. GET /v1/agents/shopbot-v2/score returns a score from 0 to 100 and the track record behind it, over the last 90 days of your own records. Only conduct that went wrong counts: 100 × (1 − (5 × final findings against the agent + 2.5 × final shared findings + 3 × debits above the checked amount + 5 × payments made against a stop or the user’s answer) ÷ (checks + 10)). A stop the agent obeyed, or an ask the user declined, is the system working and does not count. A finding still open to appeal is shown as provisional and not counted. It is a published formula, not a validated prediction. Every count comes with what it is out of. Scores are never pooled across organisations.
The full method, worked examples and a calculator. The weights are also at /v1/score/method.
POST /v1/end_users/erase with {"approved_by": "user_7f3"} revokes that person’s mandates and removes their instruction, delivery address, metadata and dispute statements, including copies in the audit log and webhook queue. Each signed token is replaced by its SHA-256, which is what the next version and every receipt already commit to, so the records stay verifiable. From the dashboard an admin can also export every record without secrets, and the owner can delete the organisation.
A webhook that fails is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours, then marked failed. Due retries go out on your organisation’s next API or dashboard request and on a scheduled sweep, and you can retry from the dashboard at any time. Webhook URLs and issuer key URLs must resolve to public addresses; TheWavly checks the address it connects to. Each key may make 100 requests per 10 seconds. Responses carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset; a 429 response includes Retry-After.
Give each system the narrowest key it needs. A key can carry scopes, chosen from presets in the dashboard: Agent (read mandates, create and read checks), Payments (report debits), Disputes and Read only. A call outside its scopes is refused with 403 insufficient_scope, naming the scope it needs. Each operation in the OpenAPI document lists its scope.
The whole API is described in /v1/openapi.json (OpenAPI 3.1), for generated clients, Postman and security reviews. Every response carries a Request-Id header, and errors repeat it as error.request_id; quote it when you contact us. Webhook delivery logs are kept for 90 days; the audit log is kept for the life of the organisation.
SDKs for JavaScript, Python, Java and Go, all without dependencies, that retry safely with idempotency keys and verify webhooks. The JavaScript and Python SDKs also verify receipts and findings. An MCP server lets agents call the check themselves, and TheWavly Guard holds an agent’s order tools until the check answers, in front of an MCP server or inside an agent framework. All are free to use in test mode.
Download the SDK bundle (Apache-2.0). It includes the clients, MCP server, Guard, offline verifier and working examples. Install from the extracted source:
curl -fL https://thewavly.com/sdk/thewavly-open.tar.gz -o thewavly-open.tar.gz tar -xzf thewavly-open.tar.gz npm install ./thewavly-open/sdk/js # Or the Python API client python3 -m pip install ./thewavly-open/sdk/python
Import Wavly from @thewavly/sdk in JavaScript or thewavly in Python after installation. Python offline verification uses the optional cryptography dependency: install './thewavly-open/sdk/python[verify]'. Java and Go build instructions are included in their SDK READMEs. Keep secret keys on your server.
{"error": {"code", "message", "field"}} with 401, 404, 409 (including idempotency_mismatch), 413, 415, 422 and 5xx. A 5xx response means nothing was applied, so it is safe to retry with the same Idempotency-Key.
How it fits
POSTThe user approves. Send the instruction, item, limit and recipient, and TheWavly signs it. An approved change becomes version 2, and both stay provable.
/api/v0/mandatesPOSTThe agent tries to pay. Each field comes back as match, ask or stop, with one overall decision and a signed receipt.
/api/v0/checkGETAnyone verifies a receipt offline with the published key, without asking TheWavly.
/api/v0/keysQuickstart
// Before the agent pays, check the purchase
const res = await fetch(WAVLY + "/api/v0/check", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
mandate: mandateToken,
purchase: {
item: "Bluetooth speaker",
amount_paise: 249900,
deliver_to: "Amma"
}
})
});
const { decision, receipt } = await res.json();
if (decision !== "proceed") askTheUser();
curl -X POST {{HOST}}/api/v0/check \
-H 'content-type: application/json' \
-d '{
"mandate": "<mandate token>",
"purchase": {
"item": "Bluetooth speaker",
"amount_paise": 249900,
"deliver_to": "Amma"
}
}'
{
"decision": "stop",
"results": [
{ "field": "item", "result": "stop" },
{ "field": "amount_paise", "result": "match" },
{ "field": "deliver_to", "result": "match" }
],
"receipt": "eyJ0eXAiOiJyZWNlaXB0Ii…"
}Sandbox v0 · no account needed
Every button makes a real API call. It uses this site’s sandbox and falls back to running the same code in your browser.
The decision and the response will appear here.
// The raw JSON response appears here.
Sandbox · v0
Issues a signed mandate, or a new version of one. Keep the returned token: it is the mandate. TheWavly keeps no copy in v0.
| Field | Type | Notes |
|---|---|---|
| instruction | string ≤ 500 | The user’s words, kept verbatim. Required. |
| item | string ≤ 200 | What may be bought. Required. |
| max_amount_paise | integer | Spending limit in paise. ₹2,500 is 250000. Required. |
| approved_by | string ≤ 200 | Your pseudonymous reference for the approving user. Not a phone number or name. Required. |
| deliver_to | string ≤ 200 | If set, purchases must name the same recipient. |
| currency | "INR" | Defaults to INR. The only currency in v0. |
| expires_in_seconds | integer | 60 to 7,776,000. Defaults to seven days. |
| previous | token | An earlier mandate token. The new one keeps its id, increments ver and records the old token’s hash in prev. |
curl -X POST {{HOST}}/api/v0/mandates \
-H 'content-type: application/json' \
-d '{
"instruction": "Buy Amma a saree for up to ₹2,500.",
"item": "Saree", "max_amount_paise": 250000,
"deliver_to": "Amma", "approved_by": "user_7f3"
}'Compares one proposed purchase with a mandate. Returns decision, a results entry per field, the mandate id and version, and a signed receipt.
| Field | Type | Notes |
|---|---|---|
| mandate | token | A mandate token. Required. |
| purchase.item | string ≤ 200 | Required. |
| purchase.amount_paise | integer | Required. |
| purchase.deliver_to | string ≤ 200 | Required when the mandate names a recipient. |
| purchase.currency | "INR" | Defaults to INR. |
| purchase.merchant | string ≤ 200 | Optional. Recorded in the receipt’s purchase hash. |
Returns the public signing key as a JWK (Ed25519, EdDSA). To verify a mandate or receipt, split the token at the dot and verify the second part as an Ed25519 signature over the bytes of the first part.
const { keys } = await (await fetch("{{HOST}}/api/v0/keys")).json();
const key = await crypto.subtle.importKey("jwk", keys[0], { name: "Ed25519" }, false, ["verify"]);
const [body, sig] = receipt.split(".");
const b64 = s => Uint8Array.from(atob(s.replace(/-/g, "+").replace(/_/g, "/")), c => c.charCodeAt(0));
const valid = await crypto.subtle.verify({ name: "Ed25519" }, key, b64(sig), new TextEncoder().encode(body));The decision is stop if any field stops, otherwise ask if any field asks, otherwise proceed.
| Field | Rule | If it fails |
|---|---|---|
| expiry | The check happens before the mandate expires. | stop |
| item | Same item, ignoring case and extra spaces. | stop |
| currency | Same currency. | stop |
| amount_paise | At or under the limit. On ask, the agent pauses. If the user approves, issue version 2 and check again. | ask |
| deliver_to | Same recipient, when the mandate names one. | stop |
Errors return { ok: false, error: { code, message } }.
| Code | Status | Meaning |
|---|---|---|
| invalid_token | 401 | The mandate is malformed, altered or signed by another key. |
| invalid_field | 422 | A field is missing, too long or the wrong type. The message names it. |
| json_required | 415 | Send Content-Type: application/json. |
| bad_json | 400 | The body is not a JSON object. |
| too_large | 413 | The body is over 4 KB. |
Know Your Agent · the public registry
With your secret key, or from the dashboard under Agents. The handle and name are public.
POST /v1/registry/agents
{ "handle": "acme-travelbot", "name": "Acme Travel Assistant",
"website": "acme.in", "description": "Books flights and hotels." }
Publish the file from the response at https://acme.in/.well-known/wavly-agents.json, then ask TheWavly to check it. The agent becomes a Verified agent.
{ "agents": [ { "id": "agt_…", "token": "wvt_…" } ] }
POST /v1/registry/agents/acme-travelbot/verify
Register the agent's Ed25519 or P-256 public key. Checks signed with it, by any organisation, are attributed to the agent and count toward its public record. Checks that only name it never do.
POST /v1/registry/agents/acme-travelbot/keys
{ "jwk": { "kty": "OKP", "crv": "Ed25519", "x": "…" } }
POST /v1/checks
{ "mandate": "mdt_…", "agent": "acme-travelbot", "purchase": { … },
"agent_signature": "<compact JWS, typ wavly-check+jws>" }
The SDKs sign for you: new Wavly(key, { agent: { id: "acme-travelbot", privateKey: jwk } }) in JavaScript, Wavly(key, agent={"id": …, "private_key": jwk}) in Python, or WAVLY_AGENT and WAVLY_AGENT_KEY_FILE for the MCP server.
At a store that takes TheWavly (it serves /.well-known/wavly-merchant.json), send Wavly-Agent and Wavly-Payment-Token with the order. Wavly.checkoutHeaders(check, agent) builds them. See For merchants for the store's side.
One call, no account needed: is this agent verified, and was this payment approved by its user?
POST /v1/registry/verify
{ "agent": "acme-travelbot", "payment_token": "…" }
→ { "accept": true,
"agent": { "verified": true, "publisher": "Acme Travel", … },
"payment": { "valid": true, "max_amount_paise": 549900, … },
"reasons": [] }
| Public endpoint | Returns |
|---|---|
GET /v1/registry/agents | Every verified agent, with its record |
GET /v1/registry/agents/:handle | One agent: publisher, website, keys and its 90-day record |
GET /v1/registry/agents/:handle/jwks | The agent's active public keys |
/agents/:handle/badge.svg | The Verified agent badge for your site |
For merchants · accept agent orders
An agent that checks out at your store adds two headers. It gets the token when TheWavly checks the purchase against what its user approved.
Wavly-Agent: acme-travelbot Wavly-Payment-Token: eyJhbGciOiJFZERTQSIs…
Upload the zip under Plugins → Add New → Upload Plugin, then open WooCommerce → Settings → TheWavly. It works with classic checkout, block checkout and the Store API, and notes TheWavly's answer on every agent order. Start in Record only, which never refuses an order, and switch to Require once you have seen the notes. Orders from people are never touched.
@thewavly/merchant is in the SDK download under sdk/merchant, with Express middleware. On Razorpay or Cashfree, agentCheckout in gateways.mjs creates the gateway order tagged with the check, and gives the approval back if the payment fails.
const wavly = wavlyMerchant({ payees: ["shop@okhdfc"] });
const order = wavly.read(req.headers); // null: a person
const ok = await wavly.check(order, { amount_paise });
if (wavly.refuse(ok)) return refuse(ok.reasons);
if (order) await wavly.redeem(order,
{ amount_paise, payment_reference: orderId });
| Check | Refused when |
|---|---|
| The agent | It is not in the registry, its publisher has not verified its website, or it is suspended |
| The approval | The token is forged, expired, replaced or already used |
| The amount | The order total is more than the user approved |
| The payee | The user approved paying someone else |
| The mode | A test token reaches a live store |
Then the token is redeemed once, for the order total. The same approval can never pay twice, and each paid order counts toward the agent's public record. No TheWavly account is needed: the token is the permission.
Publish /.well-known/wavly-merchant.json (the plugin does it for you) so agents know your store accepts TheWavly.
Status
approved_by is what you send. v0 cannot prove the user approved anything.