> ## Documentation Index
> Fetch the complete documentation index at: https://docs.compose.market/llms.txt
> Use this file to discover all available pages before exploring further.

# Payment intents

> Prepare, settle, abort, and price metered payment intents.

Payment intent routes are used by gateway surfaces that reserve a budget before work and settle the final metered amount after work.

Amounts are USDC atomic units with 6 decimals.

## Routes

| Method | Path                        | Description                                    |
| ------ | --------------------------- | ---------------------------------------------- |
| `POST` | `/api/payments/prepare`     | Authorize a payment intent from a Compose Key. |
| `POST` | `/api/payments/settle`      | Settle a prepared intent.                      |
| `POST` | `/api/payments/abort`       | Abort a prepared intent without settlement.    |
| `POST` | `/api/payments/meter/model` | Compute metered cost for a model output.       |

## Prepare body

<ParamField body="service" type="string" required>
  Service namespace, such as `agent`, `workflow`, or `inference`.
</ParamField>

<ParamField body="action" type="string" required>
  Action name within the service.
</ParamField>

<ParamField body="resource" type="string" required>
  Resource URL or identifier being paid for.
</ParamField>

<ParamField body="method" type="string" required>
  HTTP method being paid for.
</ParamField>

<ParamField body="maxAmountWei" type="string">
  Maximum authorized USDC atomic amount.
</ParamField>

<ParamField body="meter" type="object">
  Metered settlement shape: `subject` plus `lineItems`.
</ParamField>

<ParamField body="runId" type="string">
  Optional caller run ID.
</ParamField>

<ParamField body="idempotencyKey" type="string">
  Optional caller idempotency key.
</ParamField>

## Headers

<ParamField header="Authorization" type="string" required>
  `Bearer compose-...`.
</ParamField>

<ParamField header="x-chain-id" type="number" required>
  Chain ID used for the payment intent.
</ParamField>

## Meter body

<ParamField body="modelId" type="string" required>
  Public catalog model ID.
</ParamField>

<ParamField body="provider" type="string">
  Optional provider override for exact provider billing resolution.
</ParamField>

<ParamField body="modality" type="string" required>
  Output modality to bill.
</ParamField>

<ParamField body="usage" type="object">
  Token or provider usage metadata.
</ParamField>

<ParamField body="media" type="object">
  Media evidence for image, audio, video, or other non-token billing.
</ParamField>
