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 \
--jsonResponse
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
Read companies.list first; create a workspace only when it returns none. 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. Next, in the same execute run: stores.select_platform, then billing.create_checkout_link. Connecting Google Ads (google.get_connect_link) is optional and can come later.
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Idempotency-Key | string (uuid) | Yes | A new UUID per intended change, the same one to retry it. Without it the API answers 400 idempotency_key_required. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The 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"
}| 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. |
| 400 | idempotency_key_required | No Idempotency-Key header with a UUID. |
| 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. |
| 429 | rate_limited | More than 600 requests a minute for this person: wait the Retry-After seconds (60) and retry. |