# 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.

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](/docs/agents/json-rpc) requests instead.

## Before you start [#before-you-start]

| You need | Why |
| --- | --- |
| An agent credential (`agk_test_...`) | Created in the [Console](https://app.52-28-238-205.sslip.io) under **Agents > New agent**. Shown once. Replace `YOUR_AGENT_KEY` with it. See [Get an agent credential](/docs/agents#get-an-agent-credential). |
| A signed mandate for that agent | Without one every purchase is denied with <ReasonCode code="MANDATE_MISSING" />. |
| API base URL | `https://api.52-28-238-205.sslip.io` |

## The operations [#the-operations]

| Operation | Request | MCP tool |
| --- | --- | --- |
| Search the catalog | <ApiOperation id="listServices" /> | `search_catalog` |
| Buy | <ApiOperation id="createPaymentIntent" /> | `request_purchase` |
| Follow a purchase | <ApiOperation id="getPaymentIntent" /> | `get_purchase_status` |
| Own budget and limits | <ApiOperation id="getSpending" /> | `get_spending_status` |
| Signed receipt | <ApiOperation id="getReceipt" /> | `get_receipt` |

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

## Verify [#verify]

Search the catalog. Searching spends nothing.

```bash title="Terminal"
curl -s 'https://api.52-28-238-205.sslip.io/v1/services?q=forecast&limit=5' \
  -H 'Authorization: Bearer YOUR_AGENT_KEY'
```

```json title="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 [#first-purchase]

```bash title="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 field | Meaning |
| --- | --- |
| `service_id` or `url` | What to buy: a catalog service, or a paid URL. Exactly one. |
| `task_id` | Your agent's task, for grouping and audit. |
| `input` | Passed to the merchant, for example the city for a forecast. |
| `purpose` | Up to 500 characters, shown to the approver and screened by Shield. |
| `wait_seconds` | How 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 [#allow]

HTTP 200 with `status` `paid`:

```json title="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:

```bash title="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 [#require_approval]

HTTP 200 with `status` `awaiting_approval`, a `reason_code` such as <ReasonCode code="ABOVE_AUTO_THRESHOLD" /> or <ReasonCode code="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` (<ReasonCode code="APPROVAL_REJECTED" />, <ReasonCode code="APPROVAL_EXPIRED" />). The link expires after <Limit name="approvalTtl" />.

### DENY [#deny]

HTTP 403 with the standard error body:

```json title="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 <ReasonCode code="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 [#troubleshooting]

| Symptom | Cause and fix |
| --- | --- |
| 401 `AGENT_CREDENTIAL_INVALID` | The credential is wrong, rotated or revoked (<ReasonCode code="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_approval` | A person has not decided yet. Keep polling the same intent. |
| 409 `IDEMPOTENCY_CONFLICT` | The same key was sent with a different body. Use a new key for a different purchase. See [Idempotency](/docs/api/idempotency). |

## Next steps [#next-steps]

<Cards>
  <Card title="API reference" href="/docs/api" description="Every operation, generated from the OpenAPI contract." />
  <Card title="TypeScript" href="/docs/agents/typescript" description="The same calls with generated types." />
  <Card title="Errors and reason codes" href="/docs/api/errors-and-reason-codes" description="The error body and every reason code." />
  <Card title="All harnesses" href="/docs/agents" description="Compare the other ways to connect." />
</Cards>

