> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.withpaygent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withpaygent.com/_mcp/server.

# API Reference — Orders & Invoicing

Manage subscription orders, trial limits, and invoices via API.

## Create Order

**`cURL`**

```bash title="cURL"
curl --request POST \
  --url 'https://cp-api.withpaygent.com/api/v1/orders' \
  --header 'Content-Type: application/json' \
  --header 'paygent-api-key: YOUR_API_KEY' \
  --data '{
    "customerExternalId": "customer-id",
    "orderName": "order-name",
    "startDate": "YYYY-MM-DD",
    "lineItems": [{ "agentId": "agent-id" }]
  }'
```

## Get Order Invoices

Retrieve a list of invoices generated for a specific order.

**`cURL`**

```bash title="cURL"
curl --request GET \
  --url 'https://cp-api.withpaygent.com/api/v1/orders/YOUR_ORDER_ID/invoices' \
  --header 'paygent-api-key: YOUR_API_KEY'
```

## Mark Invoice Paid

Once an invoice is marked paid, any pending replacement orders tied to the invoice will be activated, and the old plan order will be set to superseded.

**`cURL`**

```bash title="cURL"
curl --request POST \
  --url 'https://cp-api.withpaygent.com/api/v1/invoices/YOUR_INVOICE_ID/mark-paid' \
  --header 'paygent-api-key: YOUR_API_KEY'
```