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

# Create API key

> Create a new API key for programmatic access

<Note>**Required scope:** `admin`</Note>


## OpenAPI

````yaml /openapi.json post /{org}/api-keys
openapi: 3.1.0
info:
  title: Depot API
  description: Depot HTTP API v1
  version: 1.0.0
servers:
  - url: https://api.mesa.dev/v1
security:
  - apiKey: []
paths:
  /{org}/api-keys:
    post:
      tags:
        - Org
      summary: Create API key
      description: Create a new API key for programmatic access
      operationId: createApiKey
      parameters:
        - schema:
            type: string
          in: path
          name: org
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                scopes:
                  type: array
                  items:
                    type: string
                    enum:
                      - read
                      - write
                      - admin
                repo_ids:
                  type: array
                  items:
                    type: string
                    minLength: 1
                expires_in_seconds:
                  type: integer
                  minimum: 100
                  maximum: 31536000
                  description: >-
                    Expiration time in seconds. Must be between 100 and 31536000
                    (365 days).
                tags:
                  description: >-
                    API key tags. Keys must not start with "$" (reserved for tag
                    filter operators).
                  type: object
                  propertyNames:
                    type: string
                    maxLength: 64
                  additionalProperties:
                    type: string
                    maxLength: 256
      responses:
        '201':
          description: API key created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  key:
                    type: string
                  name:
                    anyOf:
                      - type: string
                      - type: 'null'
                  scopes:
                    type: array
                    items:
                      type: string
                  repo_ids:
                    anyOf:
                      - type: array
                        items:
                          type: string
                      - type: 'null'
                  tags:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type: string
                  created_at:
                    type: string
                    format: date-time
                required:
                  - id
                  - key
                  - name
                  - scopes
                  - repo_ids
                  - tags
                  - created_at
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '406':
          description: Not acceptable
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key

````