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

# Create API Key

> Create a new API key scoped to this workspace.

The full `api_key` secret is returned **only once** in the create response. Store it securely — it cannot be retrieved later.




## OpenAPI

````yaml POST /v1/{workspace}/ws_api_key/
openapi: 3.1.1
info:
  title: SuprSend API
  description: APIs supported on suprsend platform
  version: 1.2.2
servers:
  - url: https://hub.suprsend.com
security:
  - sec0: []
  - BearerAuth: []
paths:
  /v1/{workspace}/ws_api_key/:
    post:
      summary: Create Workspace API Key
      description: >
        Create a new API key scoped to this workspace.


        The full `api_key` secret is returned **only once** in the create
        response. Store it securely — it cannot be retrieved later.
      operationId: create-workspace-api-key
      parameters:
        - in: path
          name: workspace
          required: true
          schema:
            type: string
          description: Workspace slug (e.g. `staging`, `production`).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkspaceApiKeyCreateRequest'
            example:
              name: backend-prod
              description: Primary backend key
      responses:
        '201':
          description: >-
            API key created. `api_key` is returned only once — store it
            securely.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagementWorkspaceApiKeyCreateResponse'
              example:
                id: ws_apik_exampleId01
                masked_api_key: SS.XXXXXXX*****
                is_deleted: false
                name: backend-prod
                allowed_domains: []
                created_at: '2026-04-21T12:19:00.148846Z'
                created_by:
                  name: System User
                  email: org_XXXXXXXXXXXXXXXXXXXXXX@systemuser.suprsend.com
                deleted_at: null
                deleted_by: null
                api_key: SS.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/AuthenticationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      security:
        - ServiceTokenAuth: []
      servers:
        - url: https://management-api.suprsend.com
      x-codeSamples:
        - lang: cURL
          label: Create API Key
          source: >
            curl -X POST
            "https://management-api.suprsend.com/v1/{workspace}/ws_api_key/" \
              --header 'Authorization: ServiceToken <SERVICE_TOKEN>' \
              --header 'Content-Type: application/json' \
              --data '{"name":"backend-prod","description":"Primary backend key"}'
components:
  schemas:
    WorkspaceApiKeyCreateRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Label for the API key.
          example: backend-prod
        description:
          type: string
          nullable: true
          description: Optional notes for operators.
    ManagementWorkspaceApiKeyCreateResponse:
      allOf:
        - $ref: '#/components/schemas/ManagementWorkspaceApiKey'
        - type: object
          properties:
            api_key:
              type: string
              description: >-
                Full secret API key. Returned only once at creation — store it
                securely and never commit to source control.
              example: SS.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    ManagementWorkspaceApiKey:
      type: object
      description: Workspace-scoped REST API key (server-side secret).
      properties:
        id:
          type: string
          example: ws_apik_exampleId01
        masked_api_key:
          type: string
          description: Masked preview of the API key used in list responses.
          example: SS.XXXXXXX*****
        is_deleted:
          type: boolean
        name:
          type: string
          example: backend-prod
        allowed_domains:
          type: array
          items:
            type: string
          description: Domains allowed to use this key.
        created_at:
          type: string
          format: date-time
        created_by:
          $ref: '#/components/schemas/ManagementActor'
        deleted_at:
          type: string
          format: date-time
          nullable: true
        deleted_by:
          $ref: '#/components/schemas/ManagementActor'
    ErrorResponse:
      type: object
      properties:
        code:
          type: integer
          description: HTTP status code
        error_code:
          type: string
          description: Specific error code identifier
        type:
          type: string
          description: Error type classification
        message:
          type: string
          description: Human-readable error message
        detail:
          type: string
          description: Additional error details
    ManagementActor:
      type: object
      description: >-
        Identity that performed an action (created, updated, rolled, deleted,
        rotated).
      nullable: true
      properties:
        name:
          type: string
          description: Display name of the actor.
          example: System User
        email:
          type: string
          description: Email address of the actor.
          example: user@example.com
  responses:
    ValidationError:
      description: Validation error - data validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    AuthenticationError:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 401
            error_code: authentication_failed
            type: AuthenticationFailed
            message: Invalid service token.
            detail: Invalid service token.
    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 404
            error_code: not_found
            type: NotFound
            message: workspace 'demo' not found
            detail: workspace 'demo' not found
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: Authorization
      x-bearer-format: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where <token>
        is your auth token.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API_Key
      description: >-
        Pass as `Bearer <API_KEY>`. Get API Key from SuprSend dashboard
        Developers -> API Keys section.
    ServiceTokenAuth:
      type: apiKey
      in: header
      name: ServiceToken <token>
      description: >-
        You can get Service Token from [SuprSend dashboard -> Account Settings
        -> Service
        Tokens](https://app.suprsend.com/en/account-settings/service-tokens)
        section.

````