# Charge for a paywalled request (Intents Paywall)

> POST /v0/paywall/charge. Called by `@intents/paywall` on the merchant's server with its secret key. Without `payment`, returns the 402 to send the caller. With `payment`, verifies and settles it; `paid: true` means the merchant's handler may run. Routes are recorded on first use so the dashboard can


`POST /v0/paywall/charge`

Called by `@intents/paywall` on the merchant's server with its secret key. Without `payment`, returns the 402 to send the caller. With `payment`, verifies and settles it; `paid: true` means the merchant's handler may run. Routes are recorded on first use so the dashboard can list them.

## Authentication

A secret key (`ik_`) as a Bearer token. The prefix sets the mode: `_test_` or `_live_`. Publishable keys (`pk_`) cannot call it.

## Body parameters

| Field | Type | Required | Notes |
|---|---|---|---|
| `method` | string | yes | HTTP method of the paywalled route |
| `path` | string | yes | The route as declared in code, e.g. /report |
| `price` | string | yes | USD, up to 2 decimals |
| `currency` | `USD` | no |  |
| `resource` | string | yes | The URL the caller requested |
| `description` | string | no |  |
| `payment` | string | no | The caller's PAYMENT-SIGNATURE or X-PAYMENT header, as received |

## Responses

| Status | Means |
|---|---|
| `200` | What to answer the caller |


## Request



```bash title="curl"
curl https://api.intents.fi/v0/paywall/charge \
  -X POST \
  -H 'authorization: Bearer $INTENTS_SECRET_KEY' \
  -H 'content-type: application/json' \
  -d '{
       "method": "GET",
       "path": "/report",
       "price": "0.50",
       "resource": "https://api.example.com/report",
       "description": "Pro plan — 1 month"
     }'
```

```ts title="TypeScript"
const response = await fetch("https://api.intents.fi/v0/paywall/charge", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.INTENTS_SECRET_KEY}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "method": "GET",
    "path": "/report",
    "price": "0.50",
    "resource": "https://api.example.com/report",
    "description": "Pro plan — 1 month"
  }),
});

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

```python title="Python"
import os
import httpx

response = httpx.post(
    "https://api.intents.fi/v0/paywall/charge",
    headers={"authorization": f"Bearer {os.environ['INTENTS_SECRET_KEY']}"},
    json={
        "method": "GET",
        "path": "/report",
        "price": "0.50",
        "resource": "https://api.example.com/report",
        "description": "Pro plan — 1 month"
    },
)
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-paywall-charge · The whole corpus: https://intents.fi/docs/llms-full.txt
