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

# Create Api Key



## OpenAPI

````yaml https://agentex.dev-sgp.scale.com/openapi.json post /agent_api_keys
openapi: 3.1.0
info:
  title: Agentex API
  version: 0.1.0
servers: []
security: []
paths:
  /agent_api_keys:
    post:
      tags:
        - Agent APIKeys
      summary: Create Api Key
      operationId: create_api_key_agent_api_keys_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAPIKeyRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateAPIKeyResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateAPIKeyRequest:
      properties:
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: The UUID of the agent
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Name
          description: The name of the agent - if not provided, the agent_id must be set.
        name:
          type: string
          title: Name
          description: The name of the agent's API key.
        api_key_type:
          $ref: '#/components/schemas/AgentAPIKeyType'
          description: The type of the agent API key (external by default).
          default: external
        api_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Key
          description: >-
            Optionally provide the API key value - if not set, one will be
            generated.
      type: object
      required:
        - name
      title: CreateAPIKeyRequest
    CreateAPIKeyResponse:
      properties:
        id:
          type: string
          title: Id
          description: The unique identifier of the agent API key.
        agent_id:
          type: string
          title: Agent Id
          description: The UUID of the agent
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the agent API key was created
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: The optional name of the agent API key.
        api_key_type:
          $ref: '#/components/schemas/AgentAPIKeyType'
          description: The type of the created agent API key (external).
        api_key:
          type: string
          title: Api Key
          description: The value of the newly created API key.
      type: object
      required:
        - id
        - agent_id
        - created_at
        - name
        - api_key_type
        - api_key
      title: CreateAPIKeyResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentAPIKeyType:
      type: string
      enum:
        - internal
        - external
        - github
        - slack
      title: AgentAPIKeyType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````