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

# List documents

> List documents matching a subject query.

Document subjects live under `ms.document.document.>` and mirror the sanitised output filepath, with folders as subject tokens (a document written to `contracts/acme-nda-2024.pdf` lives under `contracts.acme-nda-2024.pdf` within that namespace). The required `query` parameter is appended to the namespace and supports stream wildcard patterns:
- `contracts.*` — direct children of `contracts` (single level)
- `contracts.>` — everything under `contracts` at any depth
- `invoices.2026.*` — documents in the `invoices/2026` folder

Missing `query` returns `400` with `` `query` query param is required ``.



## OpenAPI

````yaml /api-reference/endpoint/documents/openapi.json get /file-generator/documents
openapi: 3.1.0
info:
  title: Documents API
  description: >-
    Document templates, generated documents, e-signature requests, and checkbox
    approvals. Template and document routes are served under `/file-generator`,
    approval routes under `/workspaces/approvals`.
  version: 1.2.0
servers:
  - url: https://api.quiva.ai
    description: Production API server
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Templates
    description: >-
      Template lifecycle — create, read, publish, validate, trigger, and delete
      document templates. Templates follow a **draft → published** model: writes
      (`POST`, `PATCH`) always target the draft version, and `POST
      /templates/{key}/publish` promotes the draft. Document generation only
      ever uses the published version, so drafts can be edited safely without
      affecting production output. A template's `source` is a DOCX file
      containing angular-expression tags rendered at trigger time.
  - name: Documents
    description: >-
      Document lifecycle — read, update, and delete generated documents. A
      document record is created immediately when a template is triggered and is
      updated asynchronously: first with the generated `output.key` (an `obj://`
      or `kv://` storage URI) or `errors`, then with `signatures` progress as
      signatories sign.
  - name: Signatures
    description: >-
      E-signature workflows powered by HelloSign (Dropbox Sign). Signature
      requests are created automatically when a triggered template defines
      `signatories`. Each signatory tracks a status lifecycle of `DRAFT → SENT →
      SIGNED`, with `EXPIRED` (validity window elapsed) and `FAILED`
      (delivery/signing error) as terminal failure states. Embedded signing URLs
      can be generated for signatures created in embedded mode.
  - name: Approvals
    description: Checkbox approval of a workspace file, recorded as e-signature evidence.
  - name: Generation
  - name: Template Source
paths:
  /file-generator/documents:
    get:
      tags:
        - Documents
      summary: List documents
      description: >-
        List documents matching a subject query.


        Document subjects live under `ms.document.document.>` and mirror the
        sanitised output filepath, with folders as subject tokens (a document
        written to `contracts/acme-nda-2024.pdf` lives under
        `contracts.acme-nda-2024.pdf` within that namespace). The required
        `query` parameter is appended to the namespace and supports stream
        wildcard patterns:

        - `contracts.*` — direct children of `contracts` (single level)

        - `contracts.>` — everything under `contracts` at any depth

        - `invoices.2026.*` — documents in the `invoices/2026` folder


        Missing `query` returns `400` with `` `query` query param is required
        ``.
      operationId: listDocuments
      parameters:
        - name: query
          in: query
          required: true
          description: Stream subject query filter, e.g. `contracts.*` or `contracts.>`.
          schema:
            type: string
            example: contracts.*
      responses:
        '200':
          description: Documents listed successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentListResponse'
              example:
                body:
                  results:
                    - created_at: '2024-03-15T10:30:00Z'
                      name: acme-nda-2024.docx
                      output:
                        key: >-
                          obj://microstrate-documents/contracts.acme-nda-2024.pdf
                      template:
                        key: nda-template
                      signatures: null
                      errors: null
                  results_total: 1
                  next_sequence: 99
                  total_messages: 1
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    DocumentListResponse:
      type: object
      properties:
        body:
          type: object
          properties:
            results:
              type: array
              items:
                $ref: '#/components/schemas/Document'
            results_total:
              type: integer
              description: Number of results in this response.
              example: 5
            next_sequence:
              type: integer
              description: Sequence number to use for the next page.
              example: 99
            total_messages:
              type: integer
              description: Total number of messages in the stream for this subject.
              example: 5
    Document:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
          description: ISO 8601 datetime when the document was created.
          example: '2024-03-15T10:30:00Z'
        name:
          type: string
          description: Human-readable filename.
          example: acme-nda-2024.pdf
        output:
          type:
            - object
            - 'null'
          description: Reference to the generated output file in object storage.
          properties:
            key:
              type: string
              description: Object store URI for the generated file.
              example: obj://microstrate-documents/contracts/acme-nda-2024.pdf
        template:
          type: object
          description: Reference to the template used to generate this document.
          properties:
            key:
              type: string
              example: nda-template
        signatures:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/DocumentSignatory'
        errors:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Generation errors, if the document failed to produce output.
          example: null
        modified:
          type: integer
          readOnly: true
          description: Server-set last-modified unix timestamp (read-only).
        sequence:
          type: integer
          readOnly: true
          description: Event-stream sequence number (read-only).
        subject:
          type: string
          readOnly: true
          description: Messaging subject of the aggregate (read-only).
        type:
          type: string
          readOnly: true
          description: Last event type, e.g. created/upserted/published (read-only).
      description: >-
        A generated (or registered) document record. `output.key` is the storage
        URI of the rendered file; `signatures` tracks per-signatory e-signature
        state; `errors` is populated when generation fails.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: '"key" is required'
    DocumentSignatory:
      type: object
      required:
        - name
        - email
        - expiry
        - status
      properties:
        name:
          type: string
          example: Jane Smith
        email:
          type: string
          format: email
          example: jane@acme.com
        expiry:
          type: string
          format: date-time
          description: ISO 8601 datetime after which the signing request expires.
          example: '2024-03-22T10:30:00Z'
        status:
          type: string
          enum:
            - DRAFT
            - SENT
            - SIGNED
            - EXPIRED
            - FAILED
          description: Current signing status.
          example: SIGNED
        order:
          type: integer
          description: Signing order index (0-based).
          example: 0
        signed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: ISO 8601 datetime when the signatory signed. Null if not yet signed.
          example: '2024-03-16T14:22:10Z'
        request:
          allOf:
            - $ref: '#/components/schemas/DocumentSignatoryRequest'
        error:
          type:
            - string
            - 'null'
          description: Error message if the signature request failed.
          example: null
      description: >-
        Per-signatory e-signature state on a document. Status lifecycle: `DRAFT`
        (created at trigger time, request not yet sent) → `SENT` (HelloSign
        request dispatched; `request` populated) → `SIGNED`, or `EXPIRED`
        (validity window elapsed — an expiry cron marks the signature and
        cancels the HelloSign request) / `FAILED` (delivery or signing error —
        see `error`). The `expiry` timestamp is computed at trigger time as now
        + the template signatory's `validity`.
    DocumentSignatoryRequest:
      type: object
      description: >-
        Signature request object attached to the signatory after a HelloSign
        request is sent.
      properties:
        id:
          type: string
          description: HelloSign signature request ID.
          example: sr_abc123
        signature_id:
          type: string
          description: HelloSign per-signatory signature ID.
          example: hs_sig_xyz789
        is_embedded:
          type: boolean
          description: Whether the signing is done via an embedded iframe.
          example: true
  responses:
    BadRequest:
      description: Invalid or missing request parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: '"key" is required'
    Unauthorized:
      description: Missing or invalid Authorization header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Authorization header with a bearer token is required
    ServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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