# Pay an invoice as an agent, with no UI

> POST /v0/checkout/{invoiceId}/agent. For software that pays on someone's behalf (§12 C3). Call it with **no body** and it answers `402 Payment Required`, x402-style: the invoice, and in `accepts[]` every asset it can be paid with and the indicative all-in amount for each. Nothing is created.


`POST /v0/checkout/{invoiceId}/agent`

For software that pays on someone's behalf (§12 C3). Call it with **no body** and it answers `402 Payment Required`, x402-style: the invoice, and in `accepts[]` every asset it can be paid with and the indicative all-in amount for each. Nothing is created.

Call it again with `{ "asset", "mode": "transfer", "refundTo" }` and it creates a payment attempt, exactly like `POST …/attempts`, tagged `channel: "agent"`. The response carries the deposit address and the binding amount in `display`. Send exactly that amount, then poll `GET …/attempts/{id}` until `invoiceStatus` is `paid`. The merchant gets the same webhooks as for any other payment.

No client secret is needed: the invoice ID is the capability, as it is for the hosted page (§11.10), and the same per-invoice and per-IP attempt limits apply.

## Authentication

The invoice's client secret, in the `x-client-secret` header. It reaches this one invoice's public endpoints and nothing else, and expires with the invoice.

## Parameters

| Parameter | In | Required | Notes |
|---|---|---|---|
| `invoiceId` | path | yes |  |

## Responses

| Status | Means |
|---|---|
| `201` | The attempt, with the deposit address (transfer) or the steps (wallet) |
| `402` | Payment required: the invoice and what it accepts |


## Request



```bash title="curl"
curl https://api.intents.fi/v0/checkout/inv_3QkR7mVt9zLpXdB2hJn6Yw/agent \
  -X POST \
  -H 'x-client-secret: $CLIENT_SECRET' \
  -H 'content-type: application/json' \
  -d '{
       "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
       "mode": "wallet",
       "payer": "0xB47c2Ae95D0f1836cA9E7b240F5dC83a61E09b7D",
       "refundTo": "TRdG7wK2aXpL9oYcB5nVzQ4jMhF3sEuT6b"
     }'
```

```ts title="TypeScript"
const response = await fetch("https://api.intents.fi/v0/checkout/inv_3QkR7mVt9zLpXdB2hJn6Yw/agent", {
  method: "POST",
  headers: {
    "x-client-secret": clientSecret,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "mode": "wallet",
    "payer": "0xB47c2Ae95D0f1836cA9E7b240F5dC83a61E09b7D",
    "refundTo": "TRdG7wK2aXpL9oYcB5nVzQ4jMhF3sEuT6b"
  }),
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.code}: ${error.message}`);
}
const data = await response.json();
```

```python title="Python"
import httpx

response = httpx.post(
    "https://api.intents.fi/v0/checkout/inv_3QkR7mVt9zLpXdB2hJn6Yw/agent",
    headers={"x-client-secret": client_secret},
    json={
        "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "mode": "wallet",
        "payer": "0xB47c2Ae95D0f1836cA9E7b240F5dC83a61E09b7D",
        "refundTo": "TRdG7wK2aXpL9oYcB5nVzQ4jMhF3sEuT6b"
    },
)
response.raise_for_status()
data = response.json()
```



## Errors

```json
{ "error": { "code": "INVOICE_EXPIRED", "message": "This invoice has expired" } }
```

Switch on `code`, not on the message: every code has a page under [Error codes](/docs/errors/). Base URL `https://api.intents.fi`; the whole reference is on [one page](/docs/api).

---

Source: https://intents.fi/docs/api/post-checkout-invoiceid-agent · The whole corpus: https://intents.fi/docs/llms-full.txt
