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

# Get Document

> Retrieve the current state of a Document with full detail.

Returns the document with its current status, authorization information,
available actions, artifacts, SRI response, job status, related documents,
and complete status history.

RLS ensures the document belongs to the active tenant; an explicit
tenant_id filter is added as a defence-in-depth measure.



## OpenAPI

````yaml /openapi.json get /documents/{document_id}
openapi: 3.1.0
info:
  title: Factio SRI API
  description: >-
    Plataforma headless, multi-tenant, API-first para emitir comprobantes
    electrónicos válidos ante el SRI de Ecuador.


    ## Autenticación


    Soporta tres métodos:

    - **JWT Bearer por Google OAuth**: `/auth/google/callback`

    - **JWT Bearer por email/password**: `/auth/login`

    - **API Key**: header `X-API-Key` con clave generada en `/auth/api-keys`


    ## Multi-tenant


    El aislamiento por tenant combina PostgreSQL RLS y validaciones explícitas
    en backend. El `tenant_id` se resuelve desde el contexto de autenticación.


    ## Flujo de Emisión


    1. `POST /documents` — reserva secuencial y encola el documento (responde
    202)

    2. `GET /documents/{id}` — consulta el estado actual por polling

    3. Cuando `status = AUTHORIZED`, el campo `authorization_number` contiene la
    clave de autorización del SRI


    Documentación completa en https://docs.factioapp.com
  version: 0.1.0
servers:
  - url: http://localhost:8000
    description: Local
  - url: https://api.factioapp.com
    description: Producción
  - url: https://api.staging.factioapp.com
    description: Sandbox (datos de prueba, sin efecto fiscal real)
security: []
paths:
  /documents/{document_id}:
    get:
      tags:
        - documents
      summary: Get Document
      description: >-
        Retrieve the current state of a Document with full detail.


        Returns the document with its current status, authorization information,

        available actions, artifacts, SRI response, job status, related
        documents,

        and complete status history.


        RLS ensures the document belongs to the active tenant; an explicit

        tenant_id filter is added as a defence-in-depth measure.
      operationId: get_document_documents__document_id__get
      parameters:
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Document Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
        - name: x-tenant-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Tenant-Id
        - name: factio_access_token
          in: cookie
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Factio Access Token
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentDetailResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DocumentDetailResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        tenant_id:
          type: string
          format: uuid
          title: Tenant Id
        issuer_id:
          type: string
          format: uuid
          title: Issuer Id
        establishment_id:
          type: string
          format: uuid
          title: Establishment Id
        emission_point_id:
          type: string
          format: uuid
          title: Emission Point Id
        document_type:
          type: string
          title: Document Type
        sequential:
          anyOf:
            - type: integer
            - type: 'null'
          title: Sequential
        access_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Access Key
        status:
          type: string
          title: Status
        idempotency_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Idempotency Key
        issue_date:
          type: string
          format: date
          title: Issue Date
        subtotal:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Subtotal
        total_discount:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total Discount
        total_tax:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total Tax
        total:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total
        buyer_id_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Buyer Id Type
        buyer_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Buyer Id
        buyer_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Buyer Name
        buyer_email:
          anyOf:
            - type: string
            - type: 'null'
          title: Buyer Email
        buyer_address:
          anyOf:
            - type: string
            - type: 'null'
          title: Buyer Address
        modified_document_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Modified Document Id
        modified_document_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Modified Document Type
        modified_document_number:
          anyOf:
            - type: string
            - type: 'null'
          title: Modified Document Number
        modified_document_issue_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Modified Document Issue Date
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
        authorization_number:
          anyOf:
            - type: string
            - type: 'null'
          title: Authorization Number
        authorization_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Authorization Date
        sri_environment:
          type: string
          title: Sri Environment
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        available_actions:
          $ref: '#/components/schemas/AvailableActionsSchema'
        cancellation_info:
          $ref: '#/components/schemas/CancellationInfoSchema'
        artifacts:
          $ref: '#/components/schemas/ArtifactsSchema'
        sri_response:
          $ref: '#/components/schemas/SRIResponseSchema'
        job_status:
          $ref: '#/components/schemas/JobStatusSchema'
        related_documents:
          items:
            $ref: '#/components/schemas/RelatedDocumentSchema'
          type: array
          title: Related Documents
        status_history:
          items:
            $ref: '#/components/schemas/StatusHistoryEntrySchema'
          type: array
          title: Status History
        lines:
          items:
            $ref: '#/components/schemas/DocumentLineResponse'
          type: array
          title: Lines
        taxes:
          items:
            $ref: '#/components/schemas/DocumentTaxResponse'
          type: array
          title: Taxes
        payments:
          items:
            $ref: '#/components/schemas/DocumentPaymentResponse'
          type: array
          title: Payments
      type: object
      required:
        - id
        - tenant_id
        - issuer_id
        - establishment_id
        - emission_point_id
        - document_type
        - sequential
        - access_key
        - status
        - idempotency_key
        - issue_date
        - subtotal
        - total_discount
        - total_tax
        - total
        - buyer_id_type
        - buyer_id
        - buyer_name
        - buyer_email
        - buyer_address
        - modified_document_id
        - modified_document_type
        - modified_document_number
        - modified_document_issue_date
        - reason
        - authorization_number
        - authorization_date
        - sri_environment
        - created_at
        - updated_at
        - available_actions
        - cancellation_info
        - artifacts
        - sri_response
        - job_status
        - related_documents
        - status_history
        - lines
        - taxes
        - payments
      title: DocumentDetailResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AvailableActionsSchema:
      properties:
        can_edit:
          type: boolean
          title: Can Edit
        can_submit:
          type: boolean
          title: Can Submit
        can_cancel:
          type: boolean
          title: Can Cancel
        can_retry:
          type: boolean
          title: Can Retry
        can_reconcile:
          type: boolean
          title: Can Reconcile
        can_mark_failed:
          type: boolean
          title: Can Mark Failed
        can_resend_email:
          type: boolean
          title: Can Resend Email
        can_create_credit_note:
          type: boolean
          title: Can Create Credit Note
      type: object
      required:
        - can_edit
        - can_submit
        - can_cancel
        - can_retry
        - can_reconcile
        - can_mark_failed
        - can_resend_email
        - can_create_credit_note
      title: AvailableActionsSchema
    CancellationInfoSchema:
      properties:
        requested_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Requested At
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
        cancelled_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Cancelled At
      type: object
      required:
        - requested_at
        - reason
        - cancelled_at
      title: CancellationInfoSchema
    ArtifactsSchema:
      properties:
        xml_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Xml Url
        pdf_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Pdf Url
        ride_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Ride Url
      type: object
      required:
        - xml_url
        - pdf_url
        - ride_url
      title: ArtifactsSchema
    SRIResponseSchema:
      properties:
        reception_state:
          anyOf:
            - type: string
            - type: 'null'
          title: Reception State
        authorization_state:
          anyOf:
            - type: string
            - type: 'null'
          title: Authorization State
        authorization_number:
          anyOf:
            - type: string
            - type: 'null'
          title: Authorization Number
        authorization_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Authorization Date
        messages:
          items:
            $ref: '#/components/schemas/SRIMessageSchema'
          type: array
          title: Messages
      type: object
      required:
        - reception_state
        - authorization_state
        - authorization_number
        - authorization_date
        - messages
      title: SRIResponseSchema
    JobStatusSchema:
      properties:
        last_attempt_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Attempt At
        next_retry_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Next Retry At
        attempt_count:
          type: integer
          title: Attempt Count
        worker_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Worker Id
      type: object
      required:
        - last_attempt_at
        - next_retry_at
        - attempt_count
        - worker_id
      title: JobStatusSchema
    RelatedDocumentSchema:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        document_type:
          type: string
          title: Document Type
        sequential:
          anyOf:
            - type: integer
            - type: 'null'
          title: Sequential
        access_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Access Key
        status:
          type: string
          title: Status
        relationship:
          type: string
          title: Relationship
      type: object
      required:
        - id
        - document_type
        - sequential
        - access_key
        - status
        - relationship
      title: RelatedDocumentSchema
    StatusHistoryEntrySchema:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        previous_status:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Status
        new_status:
          type: string
          title: New Status
        changed_by_user_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Changed By User Id
        changed_by_worker_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Changed By Worker Id
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - previous_status
        - new_status
        - changed_by_user_id
        - changed_by_worker_id
        - detail
        - created_at
      title: StatusHistoryEntrySchema
    DocumentLineResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        line_number:
          type: integer
          title: Line Number
        description:
          type: string
          title: Description
        main_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Main Code
        aux_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Aux Code
        quantity:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Quantity
        unit_price:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Unit Price
        discount:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Discount
        subtotal:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Subtotal
        tax_code:
          type: string
          title: Tax Code
        tax_rate_code:
          type: string
          title: Tax Rate Code
      type: object
      required:
        - id
        - line_number
        - description
        - main_code
        - aux_code
        - quantity
        - unit_price
        - discount
        - subtotal
        - tax_code
        - tax_rate_code
      title: DocumentLineResponse
    DocumentTaxResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        tax_code:
          type: string
          title: Tax Code
        tax_rate_code:
          type: string
          title: Tax Rate Code
        taxable_base:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Taxable Base
        rate:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Rate
        tax_amount:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Tax Amount
      type: object
      required:
        - id
        - tax_code
        - tax_rate_code
        - taxable_base
        - rate
        - tax_amount
      title: DocumentTaxResponse
    DocumentPaymentResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        line_number:
          type: integer
          title: Line Number
        payment_method_code:
          type: string
          title: Payment Method Code
        total:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total
        term:
          anyOf:
            - type: integer
            - type: 'null'
          title: Term
        time_unit:
          anyOf:
            - type: string
            - type: 'null'
          title: Time Unit
      type: object
      required:
        - id
        - line_number
        - payment_method_code
        - total
        - term
        - time_unit
      title: DocumentPaymentResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    SRIMessageSchema:
      properties:
        identifier:
          anyOf:
            - type: string
            - type: 'null'
          title: Identifier
        message:
          type: string
          title: Message
        additional_info:
          anyOf:
            - type: string
            - type: 'null'
          title: Additional Info
        message_type:
          type: string
          title: Message Type
      type: object
      required:
        - identifier
        - message
        - additional_info
        - message_type
      title: SRIMessageSchema

````