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

# Fetch documents

> Lookup and return documents by document IDs from a collection.



## OpenAPI

````yaml post /collections/{collectionName}/docs/fetch
openapi: 3.1.1
info:
  title: LambdaDB API
  summary: LambdaDB Open API Spec
  version: 1.1.1
servers:
  - url: https://{projectHost}
    description: LambdaDB API endpoints
    variables:
      projectHost:
        description: The project-scoped URL of the API
        default: api.lambdadb.ai/projects/example-project
security: []
tags:
  - name: collections
    description: Create, describe, configure, list, and delete collections.
  - name: versioning
    description: Manage branches, tags, and aliases within a collection.
  - name: collections.docs
    description: Write, fetch, list, and bulk upload documents.
paths:
  /collections/{collectionName}/docs/fetch:
    post:
      tags:
        - collections.docs
      summary: Fetch Documents
      description: Lookup and return documents by document IDs from a collection.
      operationId: fetchDocs
      parameters:
        - $ref: '#/components/parameters/CollectionName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ids:
                  type: array
                  items:
                    type: string
                    minLength: 1
                    not:
                      pattern: >-
                        ^[\u0009-\u000d\u001c-\u0020\u1680\u2000-\u2006\u2008-\u200a\u2028\u2029\u205f\u3000]*$
                  description: >-
                    A list of 1 to 1000 nonblank document IDs to fetch. The
                    count limit does not guarantee that all requested document
                    bodies fit within response size limits.
                  minItems: 1
                  maxItems: 1000
                consistentRead:
                  $ref: '#/components/schemas/ConsistentRead'
                includeVectors:
                  $ref: '#/components/schemas/IncludeVectors'
                fields:
                  $ref: '#/components/schemas/FieldsSelector'
                partitionFilter:
                  $ref: '#/components/schemas/PartitionFilter'
                ref:
                  $ref: '#/components/schemas/RefContext'
              required:
                - ids
              additionalProperties: false
              if:
                required:
                  - consistentRead
                properties:
                  consistentRead:
                    const: true
              then:
                properties:
                  ref:
                    properties:
                      kind:
                        enum:
                          - branch
                          - alias
            examples:
              example:
                summary: Example request body for documents fetch
                value:
                  ids:
                    - example-doc-id-1
                    - example-doc-id-2
      responses:
        '200':
          description: Fetched documents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: integer
                    description: Total number of documents returned.
                  took:
                    type: integer
                    description: Elapsed time in milliseconds.
                  docs:
                    type: array
                    items:
                      type: object
                      properties:
                        collection:
                          type: string
                        doc:
                          type: object
                          additionalProperties: true
                      required:
                        - collection
                        - doc
                  isDocsInline:
                    type: boolean
                    description: >-
                      Whether docs are included inline. When false, docs is
                      empty and the result items must be downloaded from
                      docsUrl.
                  docsUrl:
                    type: string
                    description: >-
                      Presigned download URL when isDocsInline is false. GET the
                      complete URL without forwarding the LambdaDB API key.
                      Returns a JSON array of result items, not an object with a
                      docs field.
                required:
                  - total
                  - took
                  - docs
                  - isDocsInline
              examples:
                example:
                  summary: Example response for documents fetch
                  value:
                    total: 2
                    took: 10
                    docs:
                      - collection: example-collection-name
                        doc:
                          example-field1: example-value1
                          example-field2:
                            - 0.1
                            - 0.2
                            - 0.3
                      - collection: example-collection-name
                        doc:
                          example-field1: example-value2
                          example-field2:
                            - 0.4
                            - 0.5
                            - 0.6
                    isDocsInline: true
        '400':
          description: >-
            Bad request, including more than 1000 IDs or projected document
            bodies exceeding the 64 MiB per-node JSON size limit. Size-limit
            errors return no partial result; request fewer IDs or fields, or
            disable includeVectors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
              examples:
                example:
                  summary: Example response for bad request
                  value:
                    message: Invalid request
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthenticated'
              examples:
                example:
                  summary: Example response for authentication failure
                  value:
                    message: Authentication failed
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceNotFound'
              examples:
                example:
                  summary: Example response for resource not found
                  value:
                    message: Resource not found
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          description: >-
            Too many requests, or the pending-write payload exceeds the
            consistent-read limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequests'
              examples:
                example:
                  summary: Example response for too many requests
                  value:
                    message: Too many requests
          headers:
            Retry-After:
              description: >-
                Optional retry delay in seconds. Not present on every 429
                response.
              schema:
                type: string
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
              examples:
                example:
                  summary: Example response for internal server error
                  value:
                    message: Internal server error
        '502':
          $ref: '#/components/responses/BadGateway'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
          description: >-
            Service unavailable, including temporary result-storage admission
            failure. Retry with backoff.
        '504':
          $ref: '#/components/responses/GatewayTimeout'
      security:
        - ProjectApiKey: []
components:
  parameters:
    CollectionName:
      in: path
      name: collectionName
      description: Collection name.
      required: true
      schema:
        type: string
  schemas:
    ConsistentRead:
      title: ConsistentRead
      type: boolean
      default: false
      description: >-
        Overlay eligible pending writes on the selected branch's committed data.
        Defaults to false. Allowed when ref selects a branch directly or an
        alias that currently targets a branch; the alias is resolved to its
        branch when the request is admitted. Tag reads and an alias that targets
        a tag reject true with 400. Pending bulk imports are excluded. Returns
        429 if the pending payload exceeds the consistent-read limit.
    IncludeVectors:
      title: IncludeVectors
      type: boolean
      default: false
      description: >-
        If your application need to include vector values in the response, set
        includeVectors to true.
    FieldsSelector:
      type: object
      description: >-
        An object to specify a list of field names to include and/or exclude in
        the result.
      properties:
        include:
          type: array
          description: List of field names to include in the result.
          items:
            type: string
        exclude:
          type: array
          description: List of field names to exclude in the result.
          items:
            type: string
      anyOf:
        - required:
            - include
        - required:
            - exclude
    PartitionFilter:
      title: PartitionFilter
      type: object
      properties:
        field:
          type: string
          description: Partition field name.
        in:
          type: array
          description: Partition values to filter.
          items:
            type: string
      required:
        - field
        - in
    RefContext:
      title: RefContext
      type: object
      description: >-
        Read ref selector. A ref that does not exist returns 404
        ResourceNotFound; an alias whose target is dangling returns 400
        BadRequest.
      additionalProperties: false
      properties:
        kind:
          type: string
          enum:
            - branch
            - tag
            - alias
        name:
          type: string
          minLength: 3
          maxLength: 52
          pattern: ^[a-zA-Z0-9_-]{3,52}$
      required:
        - kind
        - name
    BadRequest:
      title: BadRequest
      type: object
      properties:
        message:
          type: string
    Unauthenticated:
      title: Unauthenticated
      type: object
      properties:
        message:
          type: string
    ResourceNotFound:
      title: ResourceNotFound
      type: object
      properties:
        message:
          type: string
    TooManyRequests:
      title: TooManyRequests
      type: object
      properties:
        message:
          type: string
    InternalServerError:
      title: InternalServerError
      type: object
      properties:
        message:
          type: string
    MessageResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
  responses:
    PayloadTooLarge:
      description: >-
        Request exceeds the Gateway transport limit. Reduce the request size or
        use bulk upsert when supported.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    BadGateway:
      description: >-
        Unexpected downstream failure. A failed write response may leave its
        outcome uncertain.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    ServiceUnavailable:
      description: >-
        Transient catalog or storage dependency failure. Use bounded retries
        where the operation permits.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    GatewayTimeout:
      description: >-
        Gateway request deadline exceeded. A write may have been applied; verify
        its outcome before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
  securitySchemes:
    ProjectApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Project API Key.
      x-speakeasy-example: <YOUR_PROJECT_API_KEY>

````

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