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

# Mint the first admin api key

> Mint the first admin api key behind the secure-by-default token gate.

Only meaningful on an access-controlled install: with the gate OFF there is nothing to
protect, so the door refuses loudly with a 501 rather than minting. The per-IP backoff
is consulted BEFORE the token, so a wrong-token flood escalates a lockout that turns
further attempts away without ever comparing; a wrong/absent token is a generic 403 (no
oracle for the initialized state). The existence-check-and-mint runs under one mutex, so
two concurrent bootstraps can never both mint — the loser gets a 409. On a passing gate
a condition-free ``["*"]`` admin key — the ``is_admin_policy`` discriminator — is minted
through the shared mint and returned ONCE.

Response mirrors the login result wire shape: ``{"data": {"token": <raw key>,
"user_id": ...}}``.



## OpenAPI

````yaml /openapi.json post /api/keys/bootstrap
openapi: 3.1.0
info:
  description: The operator HTTP surface served under /api/*.
  title: tai42-skeleton API
  version: 14.0.2
servers: []
security: []
paths:
  /api/keys/bootstrap:
    post:
      tags:
        - access-control
      summary: Mint the first admin api key
      description: >-
        Mint the first admin api key behind the secure-by-default token gate.


        Only meaningful on an access-controlled install: with the gate OFF there
        is nothing to

        protect, so the door refuses loudly with a 501 rather than minting. The
        per-IP backoff

        is consulted BEFORE the token, so a wrong-token flood escalates a
        lockout that turns

        further attempts away without ever comparing; a wrong/absent token is a
        generic 403 (no

        oracle for the initialized state). The existence-check-and-mint runs
        under one mutex, so

        two concurrent bootstraps can never both mint — the loser gets a 409. On
        a passing gate

        a condition-free ``["*"]`` admin key — the ``is_admin_policy``
        discriminator — is minted

        through the shared mint and returned ONCE.


        Response mirrors the login result wire shape: ``{"data": {"token": <raw
        key>,

        "user_id": ...}}``.
      operationId: post_api_keys_bootstrap
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BootstrapKeyBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/BootstrapKeyResult'
                required:
                  - data
                type: object
          description: Success.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Conflict with the current resource state.
        '501':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error.
components:
  schemas:
    BootstrapKeyBody:
      description: First-admin-key creation for ``POST /api/keys/bootstrap``.
      properties:
        bootstrap_token:
          default: ''
          title: Bootstrap Token
          type: string
        description:
          minLength: 1
          title: Description
          type: string
        user_id:
          minLength: 1
          title: User Id
          type: string
      required:
        - user_id
        - description
      title: BootstrapKeyBody
      type: object
    BootstrapKeyResult:
      description: >-
        The one-time bootstrap result: the raw ``sk-…`` admin key and its user
        id.
      properties:
        token:
          title: Token
          type: string
        user_id:
          title: User Id
          type: string
      required:
        - token
        - user_id
      title: BootstrapKeyResult
      type: object
    Error:
      properties:
        code:
          description: >-
            Stable machine-readable reason a client keys a dedicated error state
            on, present on refusals that opt in (e.g. a 501 not-configured
            refusal). Optional: absent when the error carries only a
            human-readable message.
          type: string
        error:
          type: string
      required:
        - error
      type: object

````