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

# Create API key

> Creates a domain-scoped API key tied to a specific verified domain.
No authentication required — provide your `workspaceId`.
The plain key is returned **once only** — store it securely.




## OpenAPI

````yaml /openapi.yaml post /api/v1/auth/keys
openapi: 3.0.3
info:
  title: Torpedo API
  version: '1.0'
  description: |
    Torpedo is a transactional email API built for developers.
    Send emails from your own verified domain with a single HTTP call.
  contact:
    email: support@torpedo.co.mz
  termsOfService: https://torpedo.co.mz/terms
servers:
  - url: https://api.torpedo.co.mz
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/v1/auth/keys:
    post:
      tags:
        - API Keys
      summary: Create API key
      description: |
        Creates a domain-scoped API key tied to a specific verified domain.
        No authentication required — provide your `workspaceId`.
        The plain key is returned **once only** — store it securely.
      operationId: createApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspaceId
                - name
                - domainId
              properties:
                workspaceId:
                  type: string
                  format: uuid
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                  example: Production
                domainId:
                  type: string
                  format: uuid
                  description: Must be a verified domain in your workspace
      responses:
        '201':
          description: API key created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    allOf:
                      - $ref: '#/components/schemas/ApiKey'
                      - type: object
                        properties:
                          key:
                            type: string
                            description: Plain key — returned once only
                            example: tor_abc123xyz...
        '404':
          description: Workspace not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Domain not found or not verified
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security: []
components:
  schemas:
    ApiKey:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          example: Production
        domainId:
          type: string
          format: uuid
          nullable: true
        createdAt:
          type: string
          format: date-time
        lastUsedAt:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
                example: Domain not verified
              field:
                type: string
                example: from
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        Prefix `tor_` followed by a base64url-encoded random key.
        Obtain one from `POST /api/v1/workspaces` or `POST /api/v1/auth/keys`.

````