---
title: "Mint a billing-portal token"
---

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

# Mint a billing-portal token

Path: CloudRaker Workspace API › Billing

`POST /billing/portal-token`

Mints the 15-minute company-scoped token the embedded billing portal renders with. Authorization: a human org admin — an org API key carries `role: admin` but must not be able to change the plan or the card.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.cloudraker.com/billing/portal-token \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/billing/portal-token';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/billing/portal-token"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
```

## Responses

### 200

A billing-portal token and its component id.

#### Example

```json
{
  "token": "token_…",
  "componentId": "cmpn_…"
}
```

- `token` (`createBillingPortalToken.response.200.token`; string, required)
  - example `"token_…"`
- `componentId` (`createBillingPortalToken.response.200.componentId`; string, required)
  - example `"cmpn_…"`

### 503

`not_configured` — billing is not wired in this environment; `metering_unavailable` — the billing service did not answer.

#### Example

```json
{
  "error": "not_configured"
}
```

- `error` (`createBillingPortalToken.response.503.error`; string, required)
  - one of `"not_configured"`, `"metering_unavailable"`


Source: https://docs.cloudraker.com/workspace/api/billing/create-billing-portal-token/index.md
