> ## Documentation Index
> Fetch the complete documentation index at: https://e328d4e-productmetrics.manicule.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://e328d4e-productmetrics.manicule.dev/docs/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://e328d4e-productmetrics.manicule.dev/docs/api/mcp.
> Every agent surface: https://e328d4e-productmetrics.manicule.dev/docs/.well-known/llms-manifest.json

# Create a checkout link (/docs/api/account/billing-create-checkout-link)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 2169 · updated: 2026-11-16 -->
Related: [Create workspace](/docs/api/account/companies-create.md), [Send feedback](/docs/api/account/feedback-send.md), [Get the Google connect link](/docs/api/account/google-get-connect-link.md), [Invite teammates](/docs/api/account/invitations-send.md), [Complete onboarding](/docs/api/account/onboarding-complete.md), [Get onboarding state](/docs/api/account/onboarding-get-state.md)

> A Stripe-hosted checkout page for the workspace's Product Metrics subscription (with its trial when the workspace never had one), for the person to open in a browser.

`POST https://prod-backend.productmetrics.io/api/public/v1/companies/{companyId}/billing/checkout-link`

**Scope** `setup` · **Access** Changes data · **Operation id** `billing.create_checkout_link`

## Try it

`productmetrics` runs after `productmetrics login`; curl needs `PM_TOKEN` (see [Authentication](/docs/api/overview#authentication)). Set `$COMPANY_ID` first.



**productmetrics CLI:**

```bash
productmetrics billing create-checkout-link --company-id $COMPANY_ID --json
```

**curl:**

```bash
curl -X POST "https://prod-backend.productmetrics.io/api/public/v1/companies/$COMPANY_ID/billing/checkout-link" \
  -H "Authorization: Bearer $PM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Response

API response (200):

```json
{
  "data": {
    "checkoutUrl": "https://example-store.com"
  },
  "request_id": "req_01JR2Z4MZJAZ5V4KG05E3MFSAJ"
}
```

**CLI output:** `productmetrics billing create-checkout-link --json` prints `{ "ok": true, "data": …, "request_id": "…" }` with the same `data`, plus `"next_action": { "type": "browser", "url": "…" }` when a person must open a link (exit code 4).

## Before you call

Nothing is charged by this call; only completing the page starts the subscription. Send property_id when the subscription is for one property's setup. Needs company admin. A 409 explains in `details.status` why checkout is not the next step: `active` or `trialing` (already subscribed), `payment_failed` (fixed in the billing portal), `shopify` (billed through the Shopify app), `needs_admin` (ask an admin), `needs_invoice_subscription` (invoiced; an admin starts it in the app), `needs_billing_account`, or `needs_store_setup` (choose the store platform with [`stores.select_platform`](/docs/api/stores-and-tracking/stores-select-platform) first; for Shopify, connect the store with [`stores.connect`](/docs/api/stores-and-tracking/stores-connect)). After the person completes checkout, call [`setup.get_status`](/docs/api/account/setup-get-status) and read `company.billing`.

> **Browser step:** the result can hold a URL the person must open in a browser. An agent cannot finish that step itself: give the person the URL (the CLI prints it and exits 4).

## Path parameters

| Name        | Type          | Description                                                                                                          |
| ----------- | ------------- | -------------------------------------------------------------------------------------------------------------------- |
| `companyId` | string (uuid) | Your workspace id, from `productmetrics whoami` or [`properties.list`](/docs/api/account/properties-list) (`company_id`). |

## Body

| Name          | Type          | Required | Description                                                                                         |
| ------------- | ------------- | -------- | --------------------------------------------------------------------------------------------------- |
| `property_id` | string (uuid) | No       | The property id, from `productmetrics whoami` or [`properties.list`](/docs/api/account/properties-list). |

## Errors

A failure answers with its HTTP status and `{ error: { code, message, details? }, request_id }`. Branch on `code` (stable, lower_snake); show `message` to the person. The CLI prints the same `error` with `"ok": false`.

```json
{
  "error": {
    "code": "insufficient_scope",
    "message": "This operation needs the setup scope; connect again and allow it.",
    "details": {
      "required_scope": "setup"
    }
  },
  "request_id": "req_01JBEARMD374X4VKYEHC95BZTZ"
}
```

| Status | Code                 | When                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | `invalid_request`    | A path, query or body value does not match this page. `details.issues` lists each `location`, `path` and `message`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 401    | `invalid_token`      | The token is missing, expired or revoked: sign in again (`productmetrics login`). The `WWW-Authenticate` header says why.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 403    | `insufficient_scope` | The token lacks the `setup` scope (`details.required_scope`): sign in again and allow it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 404    | `not_found`          | An id in the path does not exist, or the signed-in person cannot open it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 409    | `conflict`           | A 409 explains in `details.status` why checkout is not the next step: `active` or `trialing` (already subscribed), `payment_failed` (fixed in the billing portal), `shopify` (billed through the Shopify app), `needs_admin` (ask an admin), `needs_invoice_subscription` (invoiced; an admin starts it in the app), `needs_billing_account`, or `needs_store_setup` (choose the store platform with [`stores.select_platform`](/docs/api/stores-and-tracking/stores-select-platform) first; for Shopify, connect the store with [`stores.connect`](/docs/api/stores-and-tracking/stores-connect)). |
| 429    | `rate_limited`       | More than 600 requests a minute for this person: wait the `Retry-After` seconds (60) and retry.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

[All Account and onboarding operations](/docs/api/account)
