# One visit to a payment link: an invoice at the link's price, or the customer's amount

> POST /v0/links/{id}/invoices. Takes the merchant's publishable key (pk_), or no key: the link ID is its capability, and a link can only create the invoice the merchant priced, or, on a `custom` link, one at an amount the customer chose inside the merchant's bounds. A key must match the link's accoun


`POST /v0/links/{id}/invoices`

Takes the merchant's publishable key (pk_), or no key: the link ID is its capability, and a link can only create the invoice the merchant priced, or, on a `custom` link, one at an amount the customer chose inside the merchant's bounds. A key must match the link's account and mode. Body (optional JSON, schema `PaymentLinkInvoiceRequest`): `quantity`, `amount` (custom links, required there), `customerEmail`.

## Authentication

None. The payment link's ID is the capability, so this runs in a customer's browser with no key at all.

## Parameters

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

## Responses

| Status | Means |
|---|---|
| `201` | Created; send the customer to `url` |
| `400` | A bad quantity or amount, or a key from the other mode |
| `404` | Unknown or off |
| `422` | AMOUNT_OUT_OF_RANGE: outside the link's minimum and maximum |
| `429` | Too many from this IP, or on this custom-amount link |


## Request



```bash title="curl"
curl https://api.intents.fi/v0/links/plink_Vb3kT9qLmZ2xR8wNc4HfJpYs6dGa1uEo/invoices \
  -X POST
```

```ts title="TypeScript"
const response = await fetch("https://api.intents.fi/v0/links/plink_Vb3kT9qLmZ2xR8wNc4HfJpYs6dGa1uEo/invoices", {
  method: "POST",
});

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/links/plink_Vb3kT9qLmZ2xR8wNc4HfJpYs6dGa1uEo/invoices",
)
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-links-id-invoices · The whole corpus: https://intents.fi/docs/llms-full.txt
