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

# Create an API key

> Mint a key. The token is returned once. Console session only.

A person signed in to the console creates keys; a key cannot create keys. Choose `scopes` from `sites:read`, `sites:write`, `facts:read`, `facts:write`. Pass `site` to bind the key to one website: a bound key sees only that website and cannot create or delete websites. The `token` (`ni_live_...`) is in this response and nowhere else; store it.


## OpenAPI

````yaml openapi.json POST /keys
openapi: 3.1.0
info:
  title: NextIntent API
  version: 1.0.0
  description: >-
    Websites, switches, the facts sheet and API keys, per account. Authenticate
    with an API key (ni_live_...) or a console session as a Bearer token. A key
    is account-wide or bound to one website; a bound key sees only that website
    and cannot create or delete websites.
servers:
  - url: https://api.nextintent.ai/v1
security:
  - bearer: []
paths:
  /keys:
    post:
      summary: >-
        Create an API key; the token is returned once (console session only).
        Body: label, role, scopes[], expires_at, site (optional website id to
        bind the key to)
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - label
              properties:
                label:
                  type: string
                role:
                  type: string
                  enum:
                    - viewer
                    - admin
                scopes:
                  type: array
                  items:
                    type: string
                    enum:
                      - sites:read
                      - sites:write
                      - facts:read
                      - facts:write
                expires_at:
                  type: string
                  format: date-time
                site:
                  type: string
                  description: Optional website id to bind the key to
      responses:
        '201':
          description: The key, with the token shown once
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Key'
                  - type: object
                    properties:
                      token:
                        type: string
                        description: ni_live_... shown once
        '400':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Key:
      type: object
      properties:
        key_id:
          type: string
        label:
          type: string
        role:
          type: string
          enum:
            - viewer
            - admin
        scopes:
          type: array
          items:
            type: string
        expires_at:
          type: string
          nullable: true
        last_used_at:
          type: string
          nullable: true
        created_at:
          type: string
    Error:
      type: object
      properties:
        error:
          type: string
  securitySchemes:
    bearer:
      type: http
      scheme: bearer

````