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

# Mint an API key

> Creates an API key (minted scope `storage:vector_stores:{id}` -
the `knowledge_bases` rename is deferred with the platform
allowlist). The secret is returned ONCE in this response and
never again. `expires_at` is **required** - the platform key
service rejects a key with no expiry. Requires `admin`+ (or owner).




## OpenAPI

````yaml /api-reference/storage/swagger.yml post /v1/knowledge_bases/{knowledgeBaseId}/api-keys
openapi: 3.0.3
info:
  version: 1.0.0
  title: Knowledges API
  description: >
    Public REST API for the Prisme.ai Knowledges (storage) workspace: knowledge
    bases, documents (uploaded files, web pages, remote files, connector
    documents), recurring web-crawl sources, semantic search, access control,
    per-knowledge-base API keys, and skills.


    Resource identifiers use the physical prefixes emitted by the implementation
    (`vs_` knowledge base, `vsf_` document, `seed_` web source, `kb-` API-key
    slug).


    This spec documents the public REST surface only. Internal helpers (private
    automations prefixed with `_`) and admin/GDPR lifecycle operations are not
    part of the public contract.
  contact:
    name: Prisme.ai
    url: https://prisme.ai
servers:
  - url: https://{host}/v2/workspaces/slug:storage/webhooks
    description: Prisme.ai workspace webhooks
    variables:
      host:
        default: api.studio.prisme.ai
        description: API host (override for self-hosted or sandbox)
security:
  - BearerAuth: []
  - WorkspaceApiKeyAuth: []
tags:
  - name: Knowledge Bases
    description: >-
      Create, list, read, update, and delete knowledge bases (vector-backed
      document stores).
  - name: Documents
    description: >-
      Ingest and manage documents (uploaded files, web pages, remote files,
      connector documents) and their indexing.
  - name: Web Sources
    description: >-
      Recurring web crawl seeds that discover and index pages into a knowledge
      base.
  - name: Search
    description: Semantic search over a knowledge base.
  - name: Access
    description: Per-knowledge-base access bindings (user, group, org, agent principals).
  - name: API Keys
    description: Per-knowledge-base API keys for connector authentication.
  - name: Stats
    description: Aggregate dashboard statistics.
  - name: Skills
    description: Prompt/instruction registry entries.
paths:
  /v1/knowledge_bases/{knowledgeBaseId}/api-keys:
    parameters:
      - name: knowledgeBaseId
        in: path
        required: true
        schema:
          type: string
          pattern: ^vs_[A-Za-z0-9-]+$
          maxLength: 128
        description: >-
          Knowledge base id. Legacy physical prefix `vs_` (the `kb_` rename is
          deferred).
    post:
      tags:
        - API Keys
      summary: Mint an API key
      description: |
        Creates an API key (minted scope `storage:vector_stores:{id}` -
        the `knowledge_bases` rename is deferred with the platform
        allowlist). The secret is returned ONCE in this response and
        never again. `expires_at` is **required** - the platform key
        service rejects a key with no expiry. Requires `admin`+ (or owner).
      operationId: createKnowledgeBaseApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - expires_at
              properties:
                name:
                  type: string
                  maxLength: 256
                slug:
                  type: string
                  description: |
                    Optional path-safe id. Auto-generated as
                    `kb-{knowledge_base_id}-{uuid}` when omitted.
                permissions:
                  type: array
                  items:
                    type: string
                  description: |
                    Optional `storage:`-prefixed permission strings.
                    Falls back to `config.api_key_default_permissions`.
                expires_at:
                  type: integer
                  description: Unix seconds. **Required.**
      responses:
        '201':
          description: Key created; `secret` present (once).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyWithSecret'
        '400':
          $ref: '#/components/responses/Error400'
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '404':
          $ref: '#/components/responses/Error404'
      security:
        - BearerAuth: []
components:
  schemas:
    ApiKeyWithSecret:
      allOf:
        - $ref: '#/components/schemas/ApiKey'
        - type: object
          required:
            - secret
          properties:
            secret:
              type: string
              writeOnly: true
              description: |
                The full API key, returned ONCE at mint and on rotate.
                Never retrievable afterwards - store it securely.
    ApiKey:
      type: object
      description: |
        Per-knowledge-base API key metadata (no secret).
      required:
        - id
        - object
        - knowledge_base_id
        - scope
        - created_at
      properties:
        id:
          type: string
          pattern: ^kb-[A-Za-z0-9_-]+$
          description: The key slug (also exposed as `slug`).
        object:
          type: string
          enum:
            - knowledge_base.api_key
        knowledge_base_id:
          type: string
          pattern: ^vs_[A-Za-z0-9-]+$
        name:
          type: string
          maxLength: 256
          nullable: true
        slug:
          type: string
          description: |
            Path-safe key identifier (`kb-{knowledge_base_id}-{uuid}`, or
            caller-supplied at mint). Equal to `id`.
          nullable: true
        scope:
          type: string
          description: |
            Currently `storage:vector_stores:{knowledge_base_id}` (the
            `storage:knowledge_bases:{id}` rename is deferred with the
            platform allowlist change).
        permissions:
          type: array
          items:
            type: string
          description: >
            The `storage:`-prefixed permission strings the key grants

            (caller-provided at mint, else
            `config.api_key_default_permissions`).
        prefix:
          type: string
          description: Non-secret leading characters, for identification in lists.
          nullable: true
        last_used_at:
          type: integer
          nullable: true
        expires_at:
          type: integer
          nullable: true
        created_by:
          type: string
          nullable: true
        created_at:
          type: integer
        updated_at:
          type: integer
    Error:
      type: object
      description: |
        Single error envelope shared by every non-2xx response. `code`
        is the stable machine-readable identifier; `message` is the
        human-readable text; `details` is optional structured context.
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: VALIDATION_ERROR
            message:
              type: string
            details:
              type: object
              additionalProperties: true
      required:
        - error
  responses:
    Error400:
      description: Caller validation failure.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missing_source:
              summary: No identifiable source
              value:
                error:
                  code: MISSING_SOURCE
                  message: Provide native_file_id, source_url, or fetch_url.
            conflicting_type:
              summary: source_type conflicts with native_file_id
              value:
                error:
                  code: VALIDATION_ERROR
                  message: >-
                    source_type must be uploaded_file when native_file_id is
                    provided
                  details:
                    field: source_type
    Error401:
      description: Authentication missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthenticated:
              value:
                error:
                  code: UNAUTHENTICATED
                  message: Authentication required.
    Error403:
      description: Authentication present, authorization denied.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            forbidden:
              value:
                error:
                  code: FORBIDDEN
                  message: Caller is not allowed to access this resource.
            hook_rejected:
              summary: An external content hook blocked ingestion (sync)
              value:
                error:
                  code: HOOK_REJECTED
                  message: Content was rejected by a compliance hook.
                  details:
                    rejected_by: hook_pii_filter
                    rejection_reason: detected_unmasked_pii
    Error404:
      description: Resource does not exist or is not visible to the caller.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            not_found:
              value:
                error:
                  code: NOT_FOUND
                  message: knowledge_base.document not found.
                  details:
                    resource: knowledge_base.document
                    id: vsf_unknown
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User session JWT or instance API key (`iak_*`). Send as `Authorization:
        Bearer <token>`.
    WorkspaceApiKeyAuth:
      type: apiKey
      in: header
      name: x-prismeai-api-key
      description: Workspace- or knowledge-base-scoped API key.

````