# A Stripe Customer Portal link: card, invoices, billing details and eligible plan changes

`POST` `/api/v1/workspaces/{workspace}/billing/portal`

`openBillingPortal`

During unexpired prepaid access the Portal allows payment methods, invoices and billing details only: no plan change or undo-cancel. Cancellation stays available through cancelPlan and the Billing Cancel button. Earlier issued Portal URLs keep Stripe's own lifetime. Who can call it: An API token with the "billing" scope, or an owner of this workspace, signed in.

**Scopes:** `billing`

An illustrative, nonworking customer-portal link. The person manages card details on Stripe's page.

**Parameters**

| Name | In | Required | Type and constraints | Description / example |
| --- | --- | --- | --- | --- |
| `workspace` | path | Yes | `string`; pattern: `"^ws_[a-z0-9]{16}$"` |  Example: `"ws_aaaaaaaaaaaaaaaa"` |

**Request example**

```http
POST https://app.flaghand.com/api/v1/workspaces/ws_aaaaaaaaaaaaaaaa/billing/portal
Authorization: Bearer tok_<your workspace token>
```

**Response example**

```json
{
  "portal_url": "https://app.flaghand.com/pay#SYNTHETIC_DO_NOT_USE_00000000000"
}
```

Success: HTTP 200. Content-Type: application/json.

**Errors:** `invalid_request` (400), `internal` (500), `unauthorized` (401), `invalid_token` (401), `session_expired` (401), `bad_origin` (403), `scope_missing` (403), `owner_session_required` (403), `not_found` (404). See the [error codes](https://app.flaghand.com/docs/errors.md) for meanings and the shared default error response. Other domain errors from that catalog may apply; the response's code and message are authoritative.

**CLI:** `flaghand billing open-portal`

```sh
flaghand billing open-portal --workspace ws_aaaaaaaaaaaaaaaa --json
```

**MCP tool:** `openBillingPortal` (also reachable through `callWriteOperation`; use `getOperation` to load its full schema).

```json
{
  "name": "callWriteOperation",
  "arguments": {
    "operation_id": "openBillingPortal",
    "arguments": {
      "workspace": "ws_aaaaaaaaaaaaaaaa"
    }
  }
}
```

Base URL: `https://app.flaghand.com/api/v1`. Part of the [API reference](https://app.flaghand.com/docs/api.md); every error code is in [errors](https://app.flaghand.com/docs/errors.md).
