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

# Create an API key

> Creates an API key and returns its secret once. Dashboard sessions with
the owner or admin role only.




## OpenAPI

````yaml /compute/api-reference/anona-openapi.yaml post /v1/api-keys
openapi: 3.0.3
info:
  title: Anona Compute API (Anona routes)
  version: 0.1.0
  description: >
    Routes the Anona Compute gateway serves next to the E2B-compatible API:

    live-view viewer tokens, SSH certificates, network policy, the credential

    vault, usage and billing, webhooks and telemetry export, thumbnails, preview
    links,

    public ports, pause when idle, template builds, and API key management.


    Written from the gateway handlers
    (`gateway/internal/stream/token/handlers.go`,

    `gateway/internal/sshca/handler.go`,
    `gateway/internal/handlers/apikeys/apikeys.go`)

    and checked against a running gateway by
    `docs-site/scripts/verify_openapi.py`.
servers:
  - url: https://api.compute.anonalabs.com
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: Live view
  - name: SSH
  - name: Sandbox access
  - name: Templates
  - name: Network
  - name: Credential vault
  - name: Usage and billing
  - name: Webhooks and telemetry
  - name: API keys
  - name: Service
paths:
  /v1/api-keys:
    post:
      tags:
        - API keys
      summary: Create an API key
      description: |
        Creates an API key and returns its secret once. Dashboard sessions with
        the owner or admin role only.
      operationId: createApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyCreate'
            example:
              name: ci
              preset: create_and_use
              expiresInDays: 90
      responses:
        '201':
          description: The new key. `key` is the secret, shown only in this response.
          content:
            application/json:
              schema:
                type: object
                required:
                  - apiKey
                  - key
                properties:
                  apiKey:
                    $ref: '#/components/schemas/ApiKey'
                  key:
                    type: string
                    pattern: ^e2b_[0-9a-f]+$
                    description: The secret. Store it now; it cannot be shown again.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          description: The organization reached its API key limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - DashboardBearer: []
components:
  schemas:
    ApiKeyCreate:
      type: object
      required:
        - name
        - preset
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 64
        preset:
          type: string
          enum:
            - read_only
            - use_existing
            - create_and_use
            - full_access
            - custom
          description: >
            `read_only`: sandboxes:read, templates:read, usage:read.

            `use_existing`: sandboxes:read, sandboxes:use.

            `create_and_use`: sandboxes:read, use, create, delete;
            templates:read.

            `full_access`: sandboxes:*, templates:*, usage:read, billing:read.

            `custom`: the scopes you list.
        scopes:
          type: array
          description: Only with `preset` `custom`.
          items:
            type: string
            enum:
              - sandboxes:read
              - sandboxes:use
              - sandboxes:create
              - sandboxes:delete
              - templates:read
              - templates:write
              - usage:read
              - billing:read
              - integrations:manage
        sandboxIds:
          type: array
          items:
            type: string
          description: Limit the key to these sandbox IDs.
        expiresInDays:
          type: integer
          nullable: true
          enum:
            - 7
            - 30
            - 90
            - 365
          description: Omit or null for a key that never expires.
    ApiKey:
      type: object
      required:
        - id
        - name
        - prefix
        - preset
        - scopes
        - sandboxIds
        - createdAt
        - lastUsedAt
        - expiresAt
        - revokedAt
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        prefix:
          type: string
          description: The first 8 characters of the secret, for recognising it.
        preset:
          type: string
          enum:
            - read_only
            - use_existing
            - create_and_use
            - full_access
            - custom
        scopes:
          type: array
          items:
            type: string
        sandboxIds:
          type: array
          items:
            type: string
          description: When not empty, the key works only on these sandboxes.
        createdAt:
          type: string
          format: date-time
        lastUsedAt:
          type: string
          format: date-time
          nullable: true
        expiresAt:
          type: string
          format: date-time
          nullable: true
        revokedAt:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          description: The HTTP status code.
        message:
          type: string
        error_code:
          type: string
          description: >-
            Machine-readable reason, on some errors (for example
            `invalid_request`).
  responses:
    BadRequest:
      description: The request body is invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: No valid API key or session.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The key's scopes or the caller's role do not allow this.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: An Anona Compute API key (`e2b_` followed by lowercase hex).
    BearerAuth:
      type: http
      scheme: bearer
      description: 'The same API key, sent as `Authorization: Bearer e2b_...`.'
    DashboardBearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        A dashboard session token (EdDSA JWT issued by
        app.compute.anonalabs.com). API keys are refused.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.