> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pilotstatus.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a named workspace key

> Mints a NAMED `ps_workspace_` key (never the primary), returned **only in this response**. Owner or Admin (`apikeys:rotate`). The key is recorded as created by the account key's user and is revoked if that user leaves the workspace. Up to 50 live (non-revoked) workspace keys per workspace, primary included (`409 WORKSPACE_KEY_LIMIT_REACHED`, with `limit`).

**Requires an account key** (`ps_account_`, created in Profile → API). Workspace keys, number keys and OAuth/MCP tokens get `403 ACCOUNT_KEY_REQUIRED`. Sent with `Cache-Control: no-store`.

> [!WARNING]
>
> **This mints a real key.** The raw key comes **only in this response** — copy it before leaving the page.


## OpenAPI

````yaml openapi.json POST /v1/workspaces/{workspaceId}/api-keys
openapi: 3.1.0
info:
  title: Pilot Status API
  version: 1.0.0
  license:
    name: Pilot Status Terms of Service
    url: https://pilotstatus.com.br/terms
  description: >-
    Public REST API for Pilot Status. Authenticate with the `x-api-key: ps_...`
    header (or `x-api-key-id`). Base URL: https://pilotstatus.com.br
servers:
  - url: https://pilotstatus.com.br
security:
  - apiKey: []
  - apiKeyId: []
paths:
  /v1/workspaces/{workspaceId}/api-keys:
    post:
      tags:
        - Workspace
      summary: Create a named workspace key
      description: >-
        Mints a NAMED `ps_workspace_` key (never the primary), returned **only
        in this response**. Owner or Admin (`apikeys:rotate`). The key is
        recorded as created by the account key's user and is revoked if that
        user leaves the workspace. Up to 50 live (non-revoked) workspace keys
        per workspace, primary included (`409 WORKSPACE_KEY_LIMIT_REACHED`, with
        `limit`).


        **Requires an account key** (`ps_account_`, created in Profile → API).
        Workspace keys, number keys and OAuth/MCP tokens get `403
        ACCOUNT_KEY_REQUIRED`. Sent with `Cache-Control: no-store`.
      operationId: post_workspaces_api_keys
      parameters:
        - name: workspaceId
          in: path
          required: true
          schema:
            type: string
          description: Workspace id, from `GET /v1/workspaces`.
          example: cmh2a9z8y0002ws8example1q
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: >-
                    1 to 60 characters, after trimming. Tells which integration
                    holds the key.
                  example: Bakery Downtown
              required:
                - name
              additionalProperties: false
      responses:
        '201':
          description: Created — `apiKey.key` is returned only this once
          content:
            application/json:
              example:
                apiKey:
                  id: cmh2ab7770004ak8example9m
                  name: Billing integration
                  key: >-
                    ps_workspace_4e8b0d2f6a1c3e5b7d9f0a2c4e6b8d0f1a3c5e7b9d0fa1c0
                  prefix: ps_workspace_
                  last4: a1c0
                  isPrimary: false
                  createdAt: '2026-10-28T09:15:00.000Z'
          headers:
            Cache-Control:
              schema:
                type: string
              example: no-store
        '400':
          description: '`NAME_REQUIRED`, `NAME_TOO_LONG` or `UNKNOWN_FIELDS`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: The name is required | O nome é obrigatório
                code: NAME_REQUIRED
        '401':
          description: Missing, invalid or revoked API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Invalid API key
        '403':
          description: >-
            Not an account key (`ACCOUNT_KEY_REQUIRED`), not an active member of
            the workspace (`WORKSPACE_MEMBERSHIP_REQUIRED`), or a role below
            Admin (`PERMISSION_DENIED`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: >-
                  This endpoint requires an account API key (ps_account_…),
                  created in Profile → API. Workspace keys, number keys and
                  OAuth tokens cannot use it | Este endpoint exige uma API key
                  de conta (ps_account_…), criada em Perfil → API. Chaves de
                  workspace, de número e tokens OAuth não podem usá-lo
                code: ACCOUNT_KEY_REQUIRED
        '409':
          description: The workspace already has 50 live workspace keys
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  limit:
                    type: integer
              example:
                error: >-
                  This workspace already has 50 API keys, which is the limit |
                  Este workspace já tem 50 API keys, que é o limite
                code: WORKSPACE_KEY_LIMIT_REACHED
                limit: 50
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Your ps_ API key
    apiKeyId:
      type: apiKey
      in: header
      name: x-api-key-id
      description: API key id (alternative to x-api-key)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.