Quickstart
Record what a user approved, check a purchase against it, and report the payment. Everything here runs in test mode, which is free and never moves money.
1. Get a test key
- Create an account at thewavly.com/app and confirm your email.
- Open Developers → API keys. Your organisation starts with a test key,
sk_test_…. Create one if you need another. - Keep it in an environment variable. Secret keys belong on your servers, never in a browser or an app.
export WAVLY_API_KEY=sk_test_…2. Install an SDK (optional)
The API is plain JSON over HTTPS, so curl works everywhere. The SDKs add retries with idempotency keys, webhook verification and signing. Download them from the SDK bundle.
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
import { Wavly } from "@thewavly/sdk";
const wavly = new Wavly(process.env.WAVLY_API_KEY);# python3 -m pip install ./thewavly-open/sdk/python
import os
from thewavly import Wavly
wavly = Wavly(os.environ["WAVLY_API_KEY"])3. Record what the user approved
When the user approves a task, create a mandate. It holds their words and the rules a purchase must meet.
curl https://thewavly.com/v1/mandates \
-H "Authorization: Bearer $WAVLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"instruction": "Buy Amma a silk saree for up to ₹2,500",
"approved_by": "user_7f3",
"rules": { "items": ["Silk saree"], "max_amount_paise": 250000, "payees": ["sarees@okhdfc"] }
}'const mandate = await wavly.mandates.create({
instruction: "Buy Amma a silk saree for up to ₹2,500",
approved_by: "user_7f3",
rules: { items: ["Silk saree"], max_amount_paise: 250000, payees: ["sarees@okhdfc"] },
});mandate = wavly.mandates.create({
"instruction": "Buy Amma a silk saree for up to ₹2,500",
"approved_by": "user_7f3",
"rules": {"items": ["Silk saree"], "max_amount_paise": 250000, "payees": ["sarees@okhdfc"]},
})The response includes the mandate's id (mdt_…), its signed token, and upi: the matching parameters for a UPI Reserve Pay block. approved_by is your own reference for the user. Never put a name or phone number in it.
4. Check the purchase, just before paying
curl https://thewavly.com/v1/checks \
-H "Authorization: Bearer $WAVLY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042" \
-d '{ "mandate": "mdt_…", "purchase": { "item": "Silk saree", "amount_paise": 249900, "payee": "sarees@okhdfc" } }'const check = await wavly.checks.create(
{ mandate: mandate.id, purchase: { item: "Silk saree", amount_paise: 249900, payee: "sarees@okhdfc" } },
{ idempotencyKey: "order-1042" },
);check = wavly.checks.create(
{"mandate": mandate["id"], "purchase": {"item": "Silk saree", "amount_paise": 249900, "payee": "sarees@okhdfc"}},
idempotency_key="order-1042",
)The answer is in decision:
| Decision | Meaning | What your agent does |
|---|---|---|
proceed | Every field matches the mandate | Pay. The amount is held against the budget for 30 minutes. |
ask | It goes beyond what was approved, for example above the limit | Do not pay yet. Send the user approval.url and wait for their answer. |
stop | It breaks a rule, for example another payee | Do not pay. Tell the user why, using results. |
Every check has a signed receipt and a verify_url, a public page that verifies the receipt in the browser.
5. Report what happened to the money
curl https://thewavly.com/v1/checks/chk_…/outcome \
-H "Authorization: Bearer $WAVLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "status": "paid", "payment_reference": "UPI-RRN-4416" }'await wavly.checks.reportOutcome(check.id, { status: "paid", payment_reference: "UPI-RRN-4416" });wavly.checks.report_outcome(check["id"], {"status": "paid", "payment_reference": "UPI-RRN-4416"})Report failed or cancelled if no money moved, so the hold is released and the budget stays correct. If the store or payment provider redeems the check's payment token instead, you do not need to report the outcome yourself.