Skip to content
Account and onboarding

Create a checkout link

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 /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). Set $COMPANY_ID first.

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

Response

API response (200):

{
  "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 first; for Shopify, connect the store with stores.connect). After the person completes checkout, call 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

NameTypeDescription
companyIdstring (uuid)Your workspace id, from productmetrics whoami or properties.list (company_id).

Body

NameTypeRequiredDescription
property_idstring (uuid)NoThe property id, from productmetrics whoami or 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.

{
  "error": {
    "code": "insufficient_scope",
    "message": "This operation needs the setup scope; connect again and allow it.",
    "details": {
      "required_scope": "setup"
    }
  },
  "request_id": "req_01JBEARMD374X4VKYEHC95BZTZ"
}
StatusCodeWhen
400invalid_requestA path, query or body value does not match this page. details.issues lists each location, path and message.
401invalid_tokenThe token is missing, expired or revoked: sign in again (productmetrics login). The WWW-Authenticate header says why.
403insufficient_scopeThe token lacks the setup scope (details.required_scope): sign in again and allow it.
404not_foundAn id in the path does not exist, or the signed-in person cannot open it.
409conflictA 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 first; for Shopify, connect the store with stores.connect).
429rate_limitedMore than 600 requests a minute for this person: wait the Retry-After seconds (60) and retry.

All Account and onboarding operations