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

# Create Key



## OpenAPI

````yaml post /api/vm/api-keys
openapi: 3.1.0
info:
  title: Axion Backend API
  description: Backend API for Axion platform with desktop automation capabilities
  version: 1.0.0
servers:
  - url: https://api.getgranite.ai
    description: Production server
  - url: http://localhost:8000
    description: Local development server
security: []
tags:
  - name: Authentication
    description: User authentication and session management
  - name: Organizations
    description: Organization management and membership
  - name: Health
    description: API health and status monitoring
  - name: Automations
    description: Automation planning and execution
  - name: MIG
    description: Managed Instance Group operations
  - name: Agent
    description: Agent execution and streaming
  - name: Onboarding
    description: Organization onboarding flow
  - name: Organization Automations
    description: Organization automation endpoint management
  - name: Organization Endpoints
    description: Public endpoints for organization automations
  - name: Analytics
    description: Analytics and reporting endpoints
paths:
  /api/vm/api-keys:
    post:
      tags:
        - VM API Keys
      summary: Create Vm Api Key
      operationId: create_vm_api_key_api_vm_api_keys_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateVmApiKeyRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateVmApiKeyResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateVmApiKeyRequest:
      properties:
        key_label:
          type: string
          title: Key Label
          description: Human-friendly name for the API key
        prefix:
          anyOf:
            - type: string
            - type: 'null'
          title: Prefix
          description: Optional key prefix
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional metadata description
      type: object
      required:
        - key_label
      title: CreateVmApiKeyRequest
    CreateVmApiKeyResponse:
      properties:
        api_key:
          $ref: '#/components/schemas/VmApiKeyResponse'
          description: Stored key metadata
        plaintext_key:
          type: string
          title: Plaintext Key
          description: Plaintext API key (only returned once)
      type: object
      required:
        - api_key
        - plaintext_key
      title: CreateVmApiKeyResponse
      description: Response containing the stored metadata and plaintext key.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    VmApiKeyResponse:
      properties:
        vm_api_key_id:
          type: string
          title: Vm Api Key Id
          description: Unique identifier for the VM API key
        key_label:
          type: string
          title: Key Label
          description: Label assigned to the API key
        key_prefix:
          anyOf:
            - type: string
            - type: 'null'
          title: Key Prefix
          description: Configured prefix
        key_last_four:
          anyOf:
            - type: string
            - type: 'null'
          title: Key Last Four
          description: Last four characters
        status:
          type: string
          title: Status
          description: API key status (active, revoked)
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Last update timestamp
        last_used_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Used At
          description: Last time the key was used by a driver
        last_used_ip:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Used Ip
          description: Most recent IP observed
        machine_count:
          type: integer
          title: Machine Count
          description: Number of machines currently linked to this key
          default: 0
        last_machine_seen_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Machine Seen At
          description: Most recent heartbeat across linked machines
      type: object
      required:
        - vm_api_key_id
        - key_label
        - status
        - created_at
        - updated_at
      title: VmApiKeyResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````