TheWavlyDocs
DocsGet started

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

  1. Create an account at thewavly.com/app and confirm your email.
  2. Open Developers → API keys. Your organisation starts with a test key, sk_test_…. Create one if you need another.
  3. Keep it in an environment variable. Secret keys belong on your servers, never in a browser or an app.
Shell
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

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"] }
  }'

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

The answer is in decision:

DecisionMeaningWhat your agent does
proceedEvery field matches the mandatePay. The amount is held against the budget for 30 minutes.
askIt goes beyond what was approved, for example above the limitDo not pay yet. Send the user approval.url and wait for their answer.
stopIt breaks a rule, for example another payeeDo 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" }'

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.

Next steps