> ## Documentation Index
> Fetch the complete documentation index at: https://dc9c767-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://dc9c767-productmetrics.manicule.dev/docs/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://dc9c767-productmetrics.manicule.dev/docs/api/mcp.
> Every agent surface: https://dc9c767-productmetrics.manicule.dev/docs/.well-known/llms-manifest.json

# Create workspace (/docs/api/account/companies-create)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1169 · updated: 2026-11-16 -->
Related: [Create a checkout link](/docs/api/account/billing-create-checkout-link.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)

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

`POST https://prod-backend.productmetrics.io/api/public/v1/companies`

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

## Try it

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



**productmetrics CLI:**

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

**curl:**

```bash
curl -X POST "https://prod-backend.productmetrics.io/api/public/v1/companies" \
  -H "Authorization: Bearer $PM_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name":"Example Store"}'
```

## Response

API response (200):

```json
{
  "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`](/docs/api/account/onboarding-set-account-type) `direct_advertiser` and [`onboarding.complete`](/docs/api/account/onboarding-complete) first, or this answers 403. Next, in the same execute run: [`stores.select_platform`](/docs/api/stores-and-tracking/stores-select-platform), then [`billing.create_checkout_link`](/docs/api/account/billing-create-checkout-link). Connecting Google Ads ([`google.get_connect_link`](/docs/api/account/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`.

```json
{
  "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.                           |

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