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

# Create API key

> Generate a personal API key using root credentials and required name, access, includeAdmin and expiresAt settings. Null expiry means Never. Read keys read health data; Edit keys also write it; Administrative permissions also allow operator readiness and OpenAPI inspection. Keys cannot manage credentials or account settings. The complete key is returned once.



## OpenAPI

````yaml /openapi.json post /auth/api-keys
openapi: 3.1.1
info:
  title: Vitalog
  version: 1.0.1
  description: >-
    Single-user structured observations with equivalent REST and MCP domain
    services. Environment AUTH_KEY or revocable personal Bearer keys with
    required name, permissions and explicit expiry (including Never); Primary
    key management requires AUTH_KEY; the UI uses separate, root-verified
    30-minute management sessions. MCP clients use OAuth authorization code with
    S256 PKCE, issued after root sign-in. Clients are resolved through HTTPS
    metadata, pre-registration or dynamic registration. OAuth tokens grant MCP
    access only.
servers:
  - url: https://vitalog-api.example.com
    description: Production REST and MCP API
  - url: http://localhost:3000
    description: Loopback development; production requires TLS ingress
security: []
paths:
  /auth/api-keys:
    post:
      tags:
        - API keys
      summary: Create API key
      description: >-
        Generate a personal API key using root credentials and required name,
        access, includeAdmin and expiresAt settings. Null expiry means Never.
        Read keys read health data; Edit keys also write it; Administrative
        permissions also allow operator readiness and OpenAPI inspection. Keys
        cannot manage credentials or account settings. The complete key is
        returned once.
      operationId: create_api_key
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            format: uuid
          description: >-
            Reuse with identical settings for safe retries; replay returns
            api_key null.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $schema: https://json-schema.org/draft/2020-12/schema
              type: object
              properties:
                email:
                  $ref: '#/components/schemas/Schema_59820fdf7d5a___schema0'
                password:
                  $ref: '#/components/schemas/Schema_59820fdf7d5a___schema1'
                  format: password
                  writeOnly: true
                  maxLength: 256
                  description: >-
                    ROOT_PASSWORD; at most 256 UTF-8 bytes. Used only for this
                    request.
                name:
                  $ref: '#/components/schemas/Schema_59820fdf7d5a___schema2'
                access:
                  $ref: '#/components/schemas/Schema_59820fdf7d5a___schema3'
                includeAdmin:
                  $ref: '#/components/schemas/Schema_59820fdf7d5a___schema4'
                expiresAt:
                  $ref: '#/components/schemas/Schema_59820fdf7d5a___schema5'
              required:
                - email
                - password
                - name
                - access
                - includeAdmin
                - expiresAt
              additionalProperties: false
      responses:
        '201':
          description: >-
            Generate a personal API key using root credentials and required
            name, access, includeAdmin and expiresAt settings. Null expiry means
            Never. Read keys read health data; Edit keys also write it;
            Administrative permissions also allow operator readiness and OpenAPI
            inspection. Keys cannot manage credentials or account settings. The
            complete key is returned once.
          content:
            application/json:
              schema:
                $schema: https://json-schema.org/draft/2020-12/schema
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  token_hint:
                    type: string
                  name:
                    type:
                      - string
                      - 'null'
                  access:
                    anyOf:
                      - type: string
                        enum:
                          - read
                          - edit
                      - type: 'null'
                  includeAdmin:
                    type:
                      - boolean
                      - 'null'
                  oauth_client_id:
                    type:
                      - string
                      - 'null'
                  oauth_client_name:
                    type:
                      - string
                      - 'null'
                  oauth_scopes:
                    anyOf:
                      - type: array
                        items:
                          type: string
                      - type: 'null'
                  created_at:
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                  expires_at:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                      - type: 'null'
                  revoked_at:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                      - type: 'null'
                  status:
                    type: string
                    enum:
                      - active
                      - expired
                      - revoked
                  api_key:
                    anyOf:
                      - type: string
                        pattern: ^vlk_[A-Za-z0-9_-]{43}$
                      - type: 'null'
                required:
                  - id
                  - token_hint
                  - name
                  - access
                  - includeAdmin
                  - created_at
                  - expires_at
                  - revoked_at
                  - status
                  - api_key
                additionalProperties: false
        '401':
          description: UNAUTHORIZED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: FORBIDDEN
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: LIMIT_EXCEEDED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: VALIDATION_ERROR
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: RATE_LIMITED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: INTERNAL_ERROR
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: UNAVAILABLE
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security: []
components:
  schemas:
    Schema_59820fdf7d5a___schema0:
      type: string
      maxLength: 254
      format: email
      pattern: >-
        ^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
    Schema_59820fdf7d5a___schema1:
      type: string
      minLength: 1
    Schema_59820fdf7d5a___schema2:
      type: string
      minLength: 1
      maxLength: 120
    Schema_59820fdf7d5a___schema3:
      type: string
      enum:
        - read
        - edit
    Schema_59820fdf7d5a___schema4:
      type: boolean
    Schema_59820fdf7d5a___schema5:
      anyOf:
        - type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
        - type: 'null'
    Error:
      type: object
      additionalProperties: false
      required:
        - code
        - message
        - catalog_version
        - issues
      properties:
        code:
          type: string
          enum:
            - VALIDATION_ERROR
            - NOT_FOUND
            - VERSION_CONFLICT
            - IDEMPOTENCY_CONFLICT
            - DAILY_TOTAL_EXISTS
            - CATALOG_VERSION_MISMATCH
            - LIMIT_EXCEEDED
            - UNAUTHORIZED
            - FORBIDDEN
            - RATE_LIMITED
            - UNAVAILABLE
            - TIMEOUT
            - INTERNAL_ERROR
        message:
          type: string
        catalog_version:
          type: string
        issues:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              reason:
                type: string
              message:
                type: string
              suggested_keys:
                type: array
                items:
                  type: string
              discovery:
                type: object
        existing_id:
          type: string
        current_version:
          type: integer
        current_catalog_version:
          type: string

````

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