# Start a payment attempt

> POST /v0/checkout/{invoiceId}/attempts. Picks one asset and turns it into a core order: an exact-output quote for the invoice's net amount (`amountExpected` less the checkout fee), paying the merchant's settlement address, with the fee charged in route on top (§5.1, §11.53).


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

Picks one asset and turns it into a core order: an exact-output quote for the invoice's net amount (`amountExpected` less the checkout fee), paying the merchant's settlement address, with the fee charged in route on top (§5.1, §11.53).

`refundTo` is required in `transfer` mode and defaults to `payer` in `wallet` mode (§11.2). It must be valid on the origin chain, because a failed payment is returned there and nowhere else.

Creating an attempt supersedes the invoice's previous active one. The superseded deposit address can still be paid, and if it is, the money still reaches the merchant and is handled as a late payment (§3.2) — which is why the UI shows only the newest address.

## 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 |  |
| `x-client-secret` | header | no | The invoice's `clientSecret`, from `POST /v0/invoices` |

## Responses

| Status | Means |
|---|---|
| `201` | The attempt, with the steps that pay it |


## Request



```bash title="curl"
curl https://api.intents.fi/v0/checkout/inv_3QkR7mVt9zLpXdB2hJn6Yw/attempts \
  -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/attempts", {
  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/attempts",
    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-attempts · The whole corpus: https://intents.fi/docs/llms-full.txt
