> ## 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.

# Resolve a citation link (lazy)

> Citation resolver. Authorization is on the VECTOR STORE
(`reader`+), not on the underlying file: a caller who can
search the store already reads the content as chunks, so the
source follows the store's ACL. For `uploaded_file`, the
storage workspace (privileged) mints a short-lived native share
URL (~5 min) and returns it with `expires_at`; callers
re-resolve on expiry. For other source types, returns
`source_url` as-is; a document with no stored `source_url`, or an
`uploaded_file` whose native file is owned by another workspace,
resolves to `404 SOURCE_UNAVAILABLE`.

Frontends should call this lazily - when the user clicks a
citation - never eagerly for every search hit.




## OpenAPI

````yaml /api-reference/storage/swagger.yml get /v1/knowledge_bases/{knowledgeBaseId}/documents/{documentId}/source_url
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}/documents/{documentId}/source_url:
    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).
      - name: documentId
        in: path
        required: true
        schema:
          type: string
          pattern: ^vsf_[A-Za-z0-9-]+$
          maxLength: 128
        description: >-
          Document id. Legacy physical prefix `vsf_` (the `doc_` rename is
          deferred).
    get:
      tags:
        - Documents
      summary: Resolve a citation link (lazy)
      description: |
        Citation resolver. Authorization is on the VECTOR STORE
        (`reader`+), not on the underlying file: a caller who can
        search the store already reads the content as chunks, so the
        source follows the store's ACL. For `uploaded_file`, the
        storage workspace (privileged) mints a short-lived native share
        URL (~5 min) and returns it with `expires_at`; callers
        re-resolve on expiry. For other source types, returns
        `source_url` as-is; a document with no stored `source_url`, or an
        `uploaded_file` whose native file is owned by another workspace,
        resolves to `404 SOURCE_UNAVAILABLE`.

        Frontends should call this lazily - when the user clicks a
        citation - never eagerly for every search hit.
      operationId: resolveDocumentSourceUrl
      responses:
        '200':
          description: Resolved URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentSourceUrl'
              examples:
                uploaded:
                  value:
                    object: document.source_url
                    document_id: vsf_550e8400-e29b-41d4-a716-446655440000
                    source_type: uploaded_file
                    url: >-
                      https://api.studio.prisme.ai/v2/files/wsp_acme/nf_8GkX2p9QwLmZ4rTv1bCdE.report.pdf?token=temp_hmac
                    expires_at: 1717000300
                web:
                  value:
                    object: document.source_url
                    document_id: vsf_550e8400-e29b-41d4-a716-446655440000
                    source_type: web_page
                    url: https://example.com/pricing
                    expires_at: null
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '404':
          description: |
            Document not found, or the source is unavailable
            (`SOURCE_UNAVAILABLE`): the underlying native file was deleted
            out-of-band (native files emit no deletion events, so this
            surfaces at resolve time), the native file is owned by another
            workspace and cannot be shared from here, or a non-uploaded
            document carries no `source_url` to resolve.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                source_unavailable:
                  value:
                    error:
                      code: SOURCE_UNAVAILABLE
                      message: The underlying native file no longer exists.
                      details:
                        document_id: vsf_550e8400-e29b-41d4-a716-446655440000
                        native_file_id: nf_8GkX2p9QwLmZ4rTv1bCdE
        '502':
          $ref: '#/components/responses/Error502'
      security:
        - BearerAuth: []
components:
  schemas:
    DocumentSourceUrl:
      type: object
      description: |
        Result of the lazy citation resolver. For `uploaded_file`, the
        URL is a short-lived native share URL minted BY THE STORAGE
        WORKSPACE (not the user - a knowledge-base reader may have no
        rights on the underlying file; chunk text is already readable
        through search, so the source follows the knowledge base's ACL).
        For all other source types, `url` is the document's
        `source_url` as-is and `expires_at` is null.
      required:
        - object
        - document_id
        - source_type
        - url
      properties:
        object:
          type: string
          enum:
            - document.source_url
        document_id:
          type: string
          pattern: ^vsf_[A-Za-z0-9-]+$
        source_type:
          type: string
          enum:
            - uploaded_file
            - remote_file
            - web_page
            - connector_document
        url:
          type: string
          format: uri
        expires_at:
          type: integer
          description: |
            Unix seconds. Populated for minted short-lived URLs
            (`uploaded_file`) and null for every other source type. For a
            minted URL it is always set: if the file service's own expiry
            is missing or unparseable, a conservative request-time-plus-TTL
            estimate is returned rather than null, so callers always have a
            refresh signal. Re-resolve on expiry.
          nullable: true
    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:
    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
    Error502:
      description: >-
        Upstream provider failure (vector DB, LLM gateway, crawler, native files
        API).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            provider_failure:
              value:
                error:
                  code: PROVIDER_UNAVAILABLE
                  message: Upstream provider returned an error.
                  details:
                    provider: elasticsearch
  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.

````