# Billing API

> Open a Stripe billing portal session (or the in-app premium URL) for plan management.

Source: https://xbeast.io/docs/api-billing

Open the Stripe billing portal to change plan, update a payment method, download invoices or cancel. The same action is available in the app under `/premium`.

### Create a portal session

**`POST /api/v1/billing/portal`**

```bash
curl -X POST "https://xbeast.io/api/v1/billing/portal" \
  -H "Authorization: Bearer xb_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Response: `{ data: { url, fallback, reason?, instructions? } }`. Open the URL in a browser where the user is signed in. When Stripe is unavailable, `fallback` is true and the URL points to the in-app `/premium` page instead.

The portal session grants plan-management access, so it requires a full-access key. Read-only keys receive `403 read_only_key`.

## Related

- [Read plan, credits and limits](https://xbeast.io/docs/api-workspace.md)
- [Manage API keys](https://xbeast.io/docs/api-keys.md)
- [Open the billing portal from an AI agent over MCP](https://xbeast.io/docs/mcp.md)
