# Kazza for AI agents

You can act on a Kazza account holder's behalf: read their balance, create
payment links, and pay their saved recipients in naira (NGN).

You do not need an API key, a developer account or any setup. You ask for
access, the account holder approves on Kazza's own page, and you receive a
token. There is no OAuth client to register.

Base address: https://agents.mykazza.com/api/agent/v1

## Two ways to connect. Both end with the same approval by the holder.

1. Connector (MCP): https://agents.mykazza.com/mcp
   Every action below as a ready-made tool. Sign-in opens in a browser window
   and returns to you. Use this if you can add connectors and your sign-in
   window works.

2. API with an approval link: the steps in this document.
   You make the calls yourself and show the holder a link to open in their
   own browser. Use this if you cannot add connectors, or if the connector's
   sign-in window fails, closes or never returns. Do not keep retrying a
   sign-in window that failed: switch to this method.

## Rules

- Never ask the holder for their Kazza password or transaction PIN. They enter
  those only on Kazza's page. No endpoint accepts them from you.
- Show the holder the approval link and the match code, and tell them to check
  the code on the page is the same.
- Keep the access token in secure storage. It is given once. Never show it.
- Amounts are strings. Send a new unique Idempotency-Key header with every
  POST below; to retry the same call after an error, send the same key again.
- Limits are enforced by Kazza. You cannot approve your own requests.

## 1. Ask for access (no authentication)

POST https://agents.mykazza.com/api/agent/v1/access-requests
Content-Type: application/json
{"agent_name": "<your name, shown to the holder>",
  "scopes": ["account:read", "payment_links:write", "payouts:request", "payouts:auto"]}

Ask only for the scopes you need. The holder may grant fewer.
  account:read          balances, transactions, saved recipients, events
  payment_links:write   create payment links and check if they are paid
  payouts:request       ask to pay a saved recipient; the holder approves each
  payouts:auto          pay recipients the holder chooses, within limits the
                        holder sets, without asking each time

Response 201, under "data": request_id, poll_secret, approval_url, match_code,
expires_at (15 minutes). Open approval_url for the holder or show it as a link,
and tell them the match_code.

## 2. Collect the token (no authentication)

GET https://agents.mykazza.com/api/agent/v1/access-requests/<request_id>
X-Poll-Secret: <poll_secret>

"data.state" is pending, approved, denied, expired or locked. Check every few
seconds while pending. When approved, "data.access_token" is present.
"data.grant" shows what you were given and when it ends.

Store the token before you do anything else. If you lose it within 10 minutes
of the approval, make this same call again: you get a replacement and the
earlier token stops working. After 10 minutes you must ask for access again.

## 3. Act (Authorization: Bearer <access_token>)

GET    https://agents.mykazza.com/api/agent/v1/grant                 what you may do, and your limits
DELETE https://agents.mykazza.com/api/agent/v1/grant                 give up access
GET    https://agents.mykazza.com/api/agent/v1/balance               balances
GET    https://agents.mykazza.com/api/agent/v1/transactions?limit=20 recent activity
GET    https://agents.mykazza.com/api/agent/v1/recipients            saved recipients; each has an id and
                                    can_be_paid_without_asking
GET    https://agents.mykazza.com/api/agent/v1/events?after=<id>     what changed since event <id>; keep last_id
POST   https://agents.mykazza.com/api/agent/v1/payment-links         {"name": "...", "description": "..."}
GET    https://agents.mykazza.com/api/agent/v1/payment-links/<id>    "paid" is true once it has been paid
POST   https://agents.mykazza.com/api/agent/v1/payouts               {"recipient_id": "...", "amount": "1500", "currency": "NGN"}
GET    https://agents.mykazza.com/api/agent/v1/payouts/<payout_id>   where a payout stands

## Response shapes

Every success is {"status": "success", "data": ...}. "data" is:

  /balance        {"balances": [{"currency_code": "USDC", "total_available_balance": 1.99,
                    "fiat_value": "2828.11", "fiat_currency": "NGN", "wallets": [...]}]}
  /recipients     a list: [{"id": "<uuid>", "name": "...", "account_number": "...",
                    "bank": "...", "currency": "NGN", "country": "NG",
                    "can_be_paid_without_asking": false}]
  /transactions   a list of activity items
  /events         {"events": [{"id": 12, "type": "payout.released", "data": {...}, "at": "..."}],
                    "last_id": 12}
  /payment-links  {"id", "short_id", "name", "description", "url", "status", "paid",
                    "created_at", "expires_at"}
  /payouts        {"payout_id", "status", "amount", "currency",
                    "recipient": {"id", "name"}, "released_by", "reason",
                    "approval_url", "match_code", "approval_expires_at"}
                  (the last three only while awaiting_approval)

Payouts are taken from the holder's USDC balance. Only recipients with
currency NGN can be paid.

## Payouts

Only saved recipients can be paid. You cannot add a recipient. The answer to
POST /payouts has "data.status":

  released           paid, within the limits the holder set
  awaiting_approval  open or show data.approval_url, tell the holder
                     data.match_code; they approve with their PIN on that
                     page. Then check GET /payouts/<payout_id>
  failed             nothing was sent; see data.reason

## Errors

{"status": "error", "error_code": "...", "message": "..."}
401 means access has ended or was removed by the holder: start again at step 1.
