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

# Create an API key

> Create a key, limited to `scopes`, bound to one sandbox with `resource`, and expiring after `expires_in_sec`. The key is in the answer once; only a digest is kept. A key can create keys only with `keys.write`, and never one broader or longer-lived than itself.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/auth/api-keys
openapi: 3.1.0
info:
  title: Fibre API
  version: 0.2.0
  description: >-
    Sandboxes for agents and the code they write. Authenticate with
    `Authorization: Bearer <API key>`.
servers:
  - url: https://api.fibre.dev
security:
  - bearer: []
tags:
  - name: Sandboxes
    description: >-
      Create, find, change and delete sandboxes, run a command and wait, and
      save a sandbox's files as an image. Guide: [create and
      configure](/sandboxes/overview).
  - name: Commands
    description: >-
      Run commands in the background: stream their output, write to their input,
      stop them, keep servers running across sleep. Guide: [run
      commands](/sandboxes/running-commands).
  - name: Files
    description: >-
      Read, write, list, inspect and delete a sandbox's files. The body is the
      file's bytes; the path is a query parameter. Guide:
      [files](/sandboxes/files).
  - name: Browser and desktop
    description: >-
      Links to a sandbox's browser (for Playwright, Puppeteer or any DevTools
      client, and a live view) and to its desktop. Guides:
      [browser](/connect/browser), [desktop](/connect/desktop).
  - name: Snapshots
    description: >-
      Take a snapshot of a running sandbox, its whole state with memory, and
      start new sandboxes from it, already running. Each snapshot answers its
      size and what it costs a month. Guide: [snapshots](/setup/snapshots).
  - name: Secrets
    description: >-
      Store secrets, encrypted, and give them to sandboxes by name: to one
      command, or to a whole sandbox. Values are write-only: once set, only the
      name, version and times come back. Guide: [secrets](/production/secrets).
  - name: API keys
    description: >-
      Create keys limited to some areas, one sandbox or a lifetime; list and
      revoke them. Guide: [API keys](/get-started/api-keys).
  - name: Webhooks
    description: >-
      Signed notifications when sandboxes start, sleep, crash or are deleted,
      and when builds finish. Guide: [webhooks](/production/webhooks).
  - name: Billing
    description: >-
      Spend, plan, credit, limits and the ledger; links to pay. Guide: [usage
      and billing](/production/usage).
  - name: Pricing
    description: Sizes and their prices, plans and storage, without authentication.
paths:
  /v1/auth/api-keys:
    post:
      tags:
        - API keys
      summary: Create an API key
      description: >-
        Create a key, limited to `scopes`, bound to one sandbox with `resource`,
        and expiring after `expires_in_sec`. The key is in the answer once; only
        a digest is kept. A key can create keys only with `keys.write`, and
        never one broader or longer-lived than itself.
      operationId: create-an-api-key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: Its name.
                scopes:
                  type: array
                  items:
                    type: string
                    maxLength: 64
                  minItems: 1
                  maxItems: 32
                  description: >-
                    What the key may do: `<area>.read`, `<area>.write`,
                    `<area>.*` or `*`.
                resource:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    A sandbox the key is bound to: it works on that sandbox
                    only.
                expires_in_sec:
                  type: integer
                  minimum: 60
                  maximum: 31536000
                  description: >-
                    Seconds until the key stops working: 60 to 365 days. Never,
                    unless set.
              required:
                - name
              additionalProperties: false
            example:
              name: ci
              scopes:
                - sandboxes.*
              expires_in_sec: 86400
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Its ID.
                  name:
                    type: string
                    description: Its name.
                  key:
                    type: string
                    description: Shown once
                  scopes:
                    type: array
                    items:
                      type: string
                    description: >-
                      What the key may do: `<area>.read`, `<area>.write`,
                      `<area>.*` or `*`.
                  resource:
                    type:
                      - string
                      - 'null'
                    description: >-
                      A sandbox the key is bound to: it works on that sandbox
                      only.
                  expires_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                    description: >-
                      When its lifetime ends and it is deleted; `null` when it
                      has none (kept until you delete it).
                required:
                  - id
                  - name
                  - key
                  - scopes
                  - resource
                  - expires_at
                additionalProperties: true
        '400':
          description: >-
            `validation_failed`: The body does not match the route's schema;
            `details` names the fields; `unknown_scope`: A requested scope does
            not exist; `areas` lists the valid areas
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            `missing_credentials`, `invalid_api_key`: no key, or a wrong,
            revoked or expired one
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: '`key_broader`: A key cannot grant more than the key that creates it'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: '`key_resource_not_found`: No sandbox with this ID to bind the key to'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: What went wrong, for people
        code:
          type: string
          enum:
            - invalid_request
            - unauthorized
            - forbidden
            - not_found
            - conflict
            - payload_too_large
            - rate_limited
            - internal
            - unavailable
            - invalid_json
            - validation_failed
            - missing_credentials
            - invalid_api_key
            - invalid_token
            - invalid_credentials
            - email_taken
            - insufficient_scope
            - key_resource_bound
            - key_broader
            - unknown_scope
            - api_key_not_found
            - key_resource_not_found
            - sandbox_not_found
            - exec_timeout
            - sandbox_limit
            - size_too_large
            - needs_vm
            - init_needs_vm
            - vm_unavailable
            - invalid_cursor
            - invalid_idempotency_key
            - idempotency_key_reused
            - idempotency_key_in_progress
            - runtime_conflict
            - snapshot_fields_fixed
            - create_failed
            - start_failed
            - engine_error
            - no_capacity
            - host_disk_full
            - already_running
            - not_running
            - command_required
            - exec_failed
            - engine_unreachable
            - command_not_found
            - path_required
            - invalid_path
            - file_not_found
            - file_is_directory
            - file_not_directory
            - file_permission_denied
            - file_exists
            - directory_not_empty
            - file_too_large
            - upload_aborted
            - disk_full
            - files_unsupported
            - restart_required
            - secret_not_found
            - snapshot_not_found
            - snapshot_exists
            - snapshot_source_not_found
            - snapshot_source_unsupported
            - snapshot_in_use
            - snapshot_failed
            - snapshot_timeout
            - image_required
            - image_not_owned
            - keep_unavailable
            - desktop_unavailable
            - browser_unavailable
            - browser_unreachable
            - image_registry_refused
            - image_not_found
            - image_access_denied
            - image_too_large
            - image_rate_limited
            - image_pull_failed
            - image_pull_timeout
            - image_ref_mismatch
            - image_ref_conflict
            - build_limit
            - payment_required
            - subscription_required
            - trial_limit
            - spend_limit
            - org_limit
            - billing_error
            - billing_not_configured
            - billing_provider_error
            - invalid_plan
            - invalid_amount
            - webhook_url
          description: 'Stable: programs branch on it'
        request_id:
          type: string
          description: As in the X-Request-Id header
        docs_url:
          type: string
          format: uri
          description: The code's entry in the error list.
      required:
        - error
        - code
        - request_id
        - docs_url
      additionalProperties: true
      description: Every non-2xx answer
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: An API key (fb_live_…)

````

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