Agents and harnesses

Plain HTTP

Call the Abazi REST API from any language with curl or any HTTP client, using the agent credential as a Bearer token and an Idempotency-Key on every purchase.

View as .mdUpdated

Every MCP tool has a REST operation behind it. An agent that does not speak MCP calls these with any HTTP client: a Bearer token on every request, JSON in and out, and an Idempotency-Key on every purchase. To call the six tools themselves without an MCP client, send them as JSON-RPC requests instead.

Before you start

You needWhy
An agent credential (agk_test_...)Created in the Console under Agents > New agent. Shown once. Replace YOUR_AGENT_KEY with it. See Get an agent credential.
A signed mandate for that agentWithout one every purchase is denied with MANDATE_MISSING.
API base URLhttps://api.52-28-238-205.sslip.io

The operations

OperationRequestMCP tool
Search the catalogGETSearch servicessearch_catalog
BuyPOSTCreate payment intentrequest_purchase
Follow a purchaseGETGet payment intentget_purchase_status
Own budget and limitsGETGet spending statusget_spending_status
Signed receiptGETGet receiptget_receipt

Authentication is Authorization: Bearer agk_test_..., the agentKey scheme in the API reference.

Verify

Search the catalog. Searching spends nothing.

Terminal
curl -s 'https://api.52-28-238-205.sslip.io/v1/services?q=forecast&limit=5' \
  -H 'Authorization: Bearer YOUR_AGENT_KEY'
Response
{
  "services": [
    {
      "service_id": "svc_...",
      "name": "Weather forecast",
      "description": "Daily forecast for one city",
      "price_base_units": "50000",
      "asset": "USDC",
      "rail": "x402",
      "accepted_networks": ["solana:...", "eip155:..."],
      "merchant": { "name": "Forecast Co", "tier": "VERIFIED" },
      "tier": "VERIFIED"
    }
  ],
  "next_cursor": null
}

Prices are in base units: 50000 USDC base units is 0.05 USDC.

First purchase

Terminal
curl -s https://api.52-28-238-205.sslip.io/v1/payment-intents \
  -H 'Authorization: Bearer YOUR_AGENT_KEY' \
  -H 'Idempotency-Key: task-42-step-1' \
  -H 'Content-Type: application/json' \
  -d '{"service_id":"svc_...","task_id":"task-42","input":{"city":"Tbilisi"}}'
Body fieldMeaning
service_id or urlWhat to buy: a catalog service, or a paid URL. Exactly one.
task_idYour agent's task, for grouping and audit.
inputPassed to the merchant, for example the city for a forecast.
purposeUp to 500 characters, shown to the approver and screened by Shield.
wait_secondsHow long the call waits for settlement, 0 to 60. Default 20.

Idempotency-Key is required, in the header or as idempotency_key in the body. The same key with the same body returns the same purchase, so a retry after a dropped connection never pays twice.

ALLOW

HTTP 200 with status paid:

Response
{
  "status": "paid",
  "intent_id": "pi_...",
  "payment_status": "confirmed",
  "fulfillment_status": "delivered",
  "decision": "ALLOW",
  "reason_code": "WITHIN_POLICY",
  "receipt_id": "rcpt_...",
  "amount_base_units": "50000",
  "asset": "USDC",
  "rail": "x402",
  "merchant": { "name": "Forecast Co", "tier": "VERIFIED" },
  "resource": { "content_type": "application/json", "body": "..." }
}

If the payment is still settling, status is submitted with poll_after_ms of 2000. Follow it, with YOUR_INTENT_ID replaced by the intent_id from the response above:

Terminal
curl -s https://api.52-28-238-205.sslip.io/v1/payment-intents/YOUR_INTENT_ID -H 'Authorization: Bearer YOUR_AGENT_KEY'

REQUIRE_APPROVAL

HTTP 200 with status awaiting_approval, a reason_code such as ABOVE_AUTO_THRESHOLD or FIRST_PURCHASE, approval_expires_at and poll_after_ms of 5000. Abazi sends the approval link to the owner's approvers. Poll GET /v1/payment-intents/{intent_id} until status is paid or denied (APPROVAL_REJECTED, APPROVAL_EXPIRED). The link expires after 10 minutes.

DENY

HTTP 403 with the standard error body:

Response (403)
{
  "code": "POLICY_DENIED",
  "reason_code": "HARD_CAP_EXCEEDED",
  "message": "...",
  "details": { "intent_id": "pi_...", "retryable": false, "next_action": "...", "scope": "..." },
  "request_id": "req_..."
}

Follow details.next_action. For NO_FUNDED_CHAIN, details.candidates lists each network that was considered and why it did not qualify. Never retry a denial with a new key.

Troubleshooting

SymptomCause and fix
401 AGENT_CREDENTIAL_INVALIDThe credential is wrong, rotated or revoked (AGENT_CREDENTIAL_INVALID). Stop and get a new one.
400 VALIDATION_ERROR, "Idempotency-Key header is required"Add the header, or idempotency_key in the body.
403 FORBIDDEN, "Agent credential required"The request used an API key (sk_test_...). Purchases need the agent's own credential.
status stays awaiting_approvalA person has not decided yet. Keep polling the same intent.
409 IDEMPOTENCY_CONFLICTThe same key was sent with a different body. Use a new key for a different purchase. See Idempotency.

Next steps

On this page