Skip to content
Account and onboarding

Create workspace

Creates the signed-in person's own workspace (a company) as a direct advertiser, with its billing customer.

POST /companies

Scope setup · Access Changes data · Operation id companies.create

Try it

productmetrics runs after productmetrics login; curl needs PM_TOKEN (see Authentication).

productmetrics companies create \
  --name 'Example Store' \
  --auto-idempotency-key \
  --json

Response

API response (200):

{
  "data": {
    "agencyId": "6f1c2a7e-3b4d-4e8f-9a01-2c3d4e5f6a7b",
    "companyId": "2a7d9b3c-1e4f-4a5b-8c6d-7e8f9a0b1c2d",
    "agencyName": "Example Agency",
    "companyName": "Example Store"
  },
  "request_id": "req_01J1TH48YVDEB20FZQNQE8HGG7"
}

CLI output: productmetrics companies create --json prints { "ok": true, "data": …, "request_id": "…" } with the same data.

Before you call

Send an Idempotency-Key header with a new UUID for each workspace you mean to create; it is required. The call is safe to retry: sending it again with the same Idempotency-Key returns the workspace the first call made and finishes any step that failed, instead of creating a second one. Returns companyId and companyName (agencyId and agencyName are null). Not for agencies or their clients. Needs the account type saved: a new account runs onboarding.set_account_type direct_advertiser and onboarding.complete first, or this answers 403. The next step is connecting Google Ads to this workspace (google_ads.create_property_connection with this companyId).

Headers

NameTypeRequiredDescription
Idempotency-Keystring (uuid)YesA new UUID per intended change, the same one to retry it. Without it the API answers 400 idempotency_key_required.

Body

NameTypeRequiredDescription
namestringYesThe workspace’s name, usually the business or store name.

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_01JQ7HMB8WBYVBCVBGS4JNZPM5"
}
StatusCodeWhen
400invalid_requestA path, query or body value does not match this page. details.issues lists each location, path and message.
400idempotency_key_requiredNo Idempotency-Key header with a UUID.
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.
429rate_limitedMore than 600 requests a minute for this person: wait the Retry-After seconds (60) and retry.

All Account and onboarding operations