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

# Get document

> Retrieve a single document by key.

Documents created by `POST /templates/trigger` progress through states observable here:
- **Queued**: `output: null`, `errors: null` — rendering in progress.
- **Generated**: `output.key` set to the storage URI (`obj://bucket/path` or `kv://bucket/path`) of the rendered file.
- **Failed**: `errors` populated with rendering errors; `output` stays null.
- **Signing**: `signatures` array populated once a HelloSign request is sent; each signatory's `status` advances `SENT → SIGNED` (or `EXPIRED`/`FAILED`) as webhook events arrive.



## OpenAPI

````yaml /api-reference/endpoint/documents/openapi.json get /file-generator/documents/{key}
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/{key}:
    get:
      tags:
        - Documents
      summary: Get document
      description: >-
        Retrieve a single document by key.


        Documents created by `POST /templates/trigger` progress through states
        observable here:

        - **Queued**: `output: null`, `errors: null` — rendering in progress.

        - **Generated**: `output.key` set to the storage URI
        (`obj://bucket/path` or `kv://bucket/path`) of the rendered file.

        - **Failed**: `errors` populated with rendering errors; `output` stays
        null.

        - **Signing**: `signatures` array populated once a HelloSign request is
        sent; each signatory's `status` advances `SENT → SIGNED` (or
        `EXPIRED`/`FAILED`) as webhook events arrive.
      operationId: getDocument
      parameters:
        - $ref: '#/components/parameters/DocumentKey'
      responses:
        '200':
          description: Document retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentResponse'
              example:
                body:
                  created_at: '2026-03-15T10:30:00Z'
                  name: acme-nda-2024.pdf
                  output:
                    key: obj://microstrate-documents/contracts.acme-nda-2024.pdf
                  template:
                    key: nda-template
                  signatures:
                    - name: Jane Smith
                      email: jane@acme.com
                      expiry: '2026-03-22T10:30:00Z'
                      status: SIGNED
                      order: 0
                      signed_at: '2026-03-16T14:22:10Z'
                      request:
                        id: sr_abc123
                        signature_id: hs_sig_xyz789
                        is_embedded: true
                      error: null
                  errors: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    DocumentKey:
      name: key
      in: path
      required: true
      description: Unique document key, typically a file path.
      schema:
        type: string
        example: contracts/acme-nda-2024.docx
  schemas:
    DocumentResponse:
      type: object
      properties:
        body:
          $ref: '#/components/schemas/Document'
        metadata:
          type:
            - object
            - 'null'
          description: Optional data-point metadata about the aggregate.
    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.