TheWavly

TheWavly API · v1

Check an agent’s purchase before it pays.

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

The production API, for your organisation.

Create an account

Authenticate

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_…

Record what the user approved

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
}

Check, just before paying

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.

Report what happened to the money

POST /v1/checks/chk_…/outcome
{ "status": "paid", "payment_reference": "UPI RRN 4416 2209" }

Guides

How each part of the API behaves, one card per topic. Open one, or read the full guides in the documentation.

Rules a check applies

FieldIf it fails
Mandate active (not revoked, expired or superseded)stop
Item, UPI payee, merchant, deliver to, currencystop
Amount above the per-purchase limitask
Paid plus held plus this purchase above the budgetask
More purchases than allowedask

Webhook signatures

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.

Payment tokens

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.

AP2 and Verifiable Intent

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.

Conditions beyond price

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.

Who says money moved

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.

Which agent asked

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.

Reconciliation

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.

Reaching the user

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.

Open formats

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.

Disputes

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.

TheWavly Score

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.

Personal data

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.

Retries and limits

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.

Restricted keys

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.

OpenAPI and request ids

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

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.

Errors

{"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

Three calls, three parties.

Try them live
01POST

Record

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
Reference
02POST

Check

The agent tries to pay. Each field comes back as match, ask or stop, with one overall decision and a signed receipt.

Endpoint
/api/v0/check
Called by
Payment provider or builder
Reference
03GET

Prove

Anyone verifies a receipt offline with the published key, without asking TheWavly.

Endpoint
/api/v0/keys
Called by
Banks, merchants, reviewers
Reference

Quickstart

  1. 1Issue a mandate when the user approves.
  2. 2Call the check with the mandate and the purchase, just before paying.
  3. 3Pay on proceed. On ask, pause and ask the user. On stop, do not pay. Keep the receipt.
// 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();
{
  "decision": "stop",
  "results": [
    { "field": "item", "result": "stop" },
    { "field": "amount_paise", "result": "match" },
    { "field": "deliver_to", "result": "match" }
  ],
  "receipt": "eyJ0eXAiOiJyZWNlaXB0Ii…"
}

Sandbox v0 · no account needed

Run the saree example.

Every button makes a real API call. It uses this site’s sandbox and falls back to running the same code in your browser.

1Issue a mandateNot issued

2Check a purchase

Issue a mandate first.

3Result

The decision and the response will appear here.

No request yet—
// The raw JSON response appears here.

Sandbox · v0

The sandbox API, for trying without an account.

Open the console
Show the sandbox (v0) reference: the no-account endpoints the console above uses

POST/api/v0/mandates

Issues a signed mandate, or a new version of one. Keep the returned token: it is the mandate. TheWavly keeps no copy in v0.

FieldTypeNotes
instructionstring ≤ 500The user’s words, kept verbatim. Required.
itemstring ≤ 200What may be bought. Required.
max_amount_paiseintegerSpending limit in paise. ₹2,500 is 250000. Required.
approved_bystring ≤ 200Your pseudonymous reference for the approving user. Not a phone number or name. Required.
deliver_tostring ≤ 200If set, purchases must name the same recipient.
currency"INR"Defaults to INR. The only currency in v0.
expires_in_secondsinteger60 to 7,776,000. Defaults to seven days.
previoustokenAn earlier mandate token. The new one keeps its id, increments ver and records the old token’s hash in prev.
curl
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"
  }'

POST/api/v0/check

Compares one proposed purchase with a mandate. Returns decision, a results entry per field, the mandate id and version, and a signed receipt.

FieldTypeNotes
mandatetokenA mandate token. Required.
purchase.itemstring ≤ 200Required.
purchase.amount_paiseintegerRequired.
purchase.deliver_tostring ≤ 200Required when the mandate names a recipient.
purchase.currency"INR"Defaults to INR.
purchase.merchantstring ≤ 200Optional. Recorded in the receipt’s purchase hash.

GET/api/v0/keys

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.

JavaScript
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));

Decision rules

The decision is stop if any field stops, otherwise ask if any field asks, otherwise proceed.

FieldRuleIf it fails
expiryThe check happens before the mandate expires.stop
itemSame item, ignoring case and extra spaces.stop
currencySame currency.stop
amount_paiseAt or under the limit. On ask, the agent pauses. If the user approves, issue version 2 and check again.ask
deliver_toSame recipient, when the mandate names one.stop

Errors

Errors return { ok: false, error: { code, message } }.

CodeStatusMeaning
invalid_token401The mandate is malformed, altered or signed by another key.
invalid_field422A field is missing, too long or the wrong type. The message names it.
json_required415Send Content-Type: application/json.
bad_json400The body is not a JSON object.
too_large413The body is over 4 KB.

Know Your Agent · the public registry

Register your agent once. Merchants can check it everywhere.

Open the registry

1. Register the agent

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." }

2. Prove the website is yours

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

3. Register its key, and sign every check

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.

4. At checkout, send two headers

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.

For merchants and payment providers

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 endpointReturns
GET /v1/registry/agentsEvery verified agent, with its record
GET /v1/registry/agents/:handleOne agent: publisher, website, keys and its 90-day record
GET /v1/registry/agents/:handle/jwksThe agent's active public keys
/agents/:handle/badge.svgThe Verified agent badge for your site

For merchants · accept agent orders

Take orders from AI agents. Only the ones a person approved.

WooCommerce plugin

What the agent sends

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…

WooCommerce

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.

Any other store, in Node

@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 });

What is checked, before you charge

CheckRefused when
The agentIt is not in the registry, its publisher has not verified its website, or it is suspended
The approvalThe token is forged, expired, replaced or already used
The amountThe order total is more than the user approved
The payeeThe user approved paying someone else
The modeA 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

What v0 is, and what it is not yet.

Shape v1 with us

Sandbox today

  • Public sandbox keyTokens are signed with a key derived from a public phrase, so anyone can mint one. Do not use it for real payments.
  • Nothing storedThe mandate travels with the agent. Version history is a chain you hold, not a register TheWavly keeps.
  • Approval is assertedapproved_by is what you send. v0 cannot prove the user approved anything.
  • Literal matching“Saree” and “silk saree” do not match. INR only, whole paise, 4 KB bodies.

On the platform API

  • A private key per deploymentRotated and published at the keys endpoint.
  • Proof of approvalTied to a user-held key or a UPI mandate reference.
  • Category rulesItem attributes, merchants, delivery dates and cancellation terms agreed per workflow.
  • A stored registerMandates and receipts, which become the evidence for disputes and the basis of TheWavly Score.