# Create payment intent

An agent asks to buy a catalog service or a paid URL; Abazi quotes, runs the policy, reserves budget and pays, waiting up to wait_seconds for the result. Agent credential only; requires an Idempotency-Key (header or body).

`POST /v1/payment-intents`

An agent asks to buy a catalog service or a paid URL; Abazi quotes, runs the policy, reserves budget and pays, waiting up to wait_seconds for the result. Agent credential only; requires an Idempotency-Key (header or body).

MCP tool: `request_purchase`.

Accepts `Idempotency-Key`.

Policy decision: ALLOW, REQUIRE_APPROVAL, DENY.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header | no | Required (header, or idempotency_key in the body). A retry with the same key returns the first result instead of paying twice. |

## Request body

```json
{
  "service_id": "svc_01jd2x3k4m5n6p7q8r9s0t1v2w",
  "task_id": "weekly-report-42",
  "idempotency_key": "weekly-report-42-forecast",
  "purpose": "Forecast for the weekly report"
}
```

## Responses

- **200**: Success.
- **400**: Invalid request: a field is missing or malformed (VALIDATION_ERROR).
- **401**: No valid session, API key or agent credential (UNAUTHENTICATED, AGENT_CREDENTIAL_INVALID).

Example 200 response:

```json
{
  "status": "active",
  "intent_id": "pi_01jd2x3k4m5n6p7q8r9s0t1v2w",
  "payment_status": "string",
  "fulfillment_status": "string",
  "decision": "ALLOW",
  "reason_code": "WITHIN_POLICY",
  "receipt_id": "rcpt_01jd2x3k4m5n6p7q8r9s0t1v2w",
  "amount_base_units": "50000",
  "asset": "USDC",
  "network": "eip155:84532",
  "rail": "x402",
  "merchant": {
    "id": "id_01jd2x3k4m5n6p7q8r9s0t1v2w",
    "name": "Example",
    "tier": "VERIFIED",
    "domain": "merchant.example.com"
  },
  "resource": {
    "content_type": "string",
    "body": "string",
    "status_code": 1
  },
  "approval_expires_at": "2026-11-16T12:00:00Z"
}
```
