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

# Create an API key

> Create a new API key. The plain-text token is only returned once in the response — store it securely.



## OpenAPI

````yaml POST /api-keys
openapi: 3.1.0
info:
  title: SendKit API
  description: The SendKit API allows you to send transactional emails programmatically.
  version: 1.0.0
servers:
  - url: https://api.sendkit.dev
security:
  - bearerAuth: []
paths:
  /api-keys:
    post:
      tags:
        - API Keys
      summary: Create an API key
      description: >-
        Create a new API key. The plain-text token is only returned once in the
        response — store it securely.
      operationId: createApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyRequest'
      responses:
        '201':
          description: >-
            API key created successfully. The `token` field contains the
            plain-text key.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiKey'
                  - type: object
                    properties:
                      token:
                        type: string
                        description: >-
                          The plain-text API key. Only returned once at creation
                          time.
                        example: sk_aBcDeFgHiJkLmNoPqRsTuVwXyZ012345678901234567
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateApiKeyRequest:
      type: object
      required:
        - name
        - permission
      properties:
        name:
          type: string
          maxLength: 255
          description: A descriptive name for the API key.
          example: Production Key
        permission:
          type: string
          enum:
            - full
            - send
          description: >-
            The permission level. `full` grants access to all endpoints, `send`
            only allows sending emails.
          example: full
        domain_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Scope the key to a specific domain. The domain must belong to your
            team.
          example: null
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When the API key should expire. Must be a future date. Null for no
            expiration.
          example: '2027-01-01 00:00:00'
    ApiKey:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier.
          example: 550e8400-e29b-41d4-a716-446655440000
        name:
          type: string
          description: The name of the API key.
          example: Production Key
        permission:
          type: string
          enum:
            - full
            - send
          description: >-
            The permission level. `full` grants access to all endpoints, `send`
            only allows sending emails.
          example: full
        domain_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The domain this key is scoped to. If null, the key can send from any
            verified domain.
          example: null
        status:
          type: string
          description: The current status of the API key.
          example: active
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the API key expires. Null if it does not expire.
          example: null
        last_used_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the API key was last used.
          example: '2026-03-03 10:00:00'
        created_at:
          type: string
          format: date-time
          description: When the API key was created.
          example: '2026-03-03 10:00:00'
    ErrorResponse:
      type: object
      properties:
        name:
          type: string
          description: Error type identifier.
          example: validation_error
        message:
          type: string
          description: Human-readable error message.
          example: The from address domain is not verified.
  responses:
    Unauthorized:
      description: Unauthorized — missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            message: Invalid API key.
    ValidationError:
      description: Validation error — invalid or missing parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            message: The email field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key from your SendKit dashboard. Pass it as a Bearer token in the
        Authorization header.

````