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

# Get extracted invoice JSON (API key)

> Poll after upload. While `ready` is false, extraction is still running and `data` is null. When `ready` is true, `data` is the structured invoice JSON (human corrections included).



## OpenAPI

````yaml /openapi/programmatic.json get /api/v1/invoices/{id}
openapi: 3.0.0
info:
  title: SnapIt Programmatic API
  description: >-
    Public API-key endpoints for invoice upload, extracted JSON, credit balance,
    and top-up. Authenticate with `Authorization: Bearer sk_live_…`. Full
    operator Swagger (including admin/JWT routes) remains at `/api/docs` on the
    API host.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.trysnapit.com
    description: Production
  - url: http://localhost:3000
    description: Local development
security:
  - api-key: []
tags:
  - name: programmatic
    description: API-key authenticated upload, invoice JSON, balance, and credit top-up
paths:
  /api/v1/invoices/{id}:
    get:
      tags:
        - programmatic
      summary: Get extracted invoice JSON (API key)
      description: >-
        Poll after upload. While `ready` is false, extraction is still running
        and `data` is null. When `ready` is true, `data` is the structured
        invoice JSON (human corrections included).
      operationId: getInvoice
      parameters:
        - name: id
          required: true
          in: path
          description: Invoice id returned from upload
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Processing status and extracted invoice JSON
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceJsonResponseDto'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
        '404':
          description: Invoice not found for this API key tenant
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
      security:
        - api-key: []
components:
  schemas:
    InvoiceJsonResponseDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
        processingStatus:
          type: string
          enum:
            - queued
            - processing
            - completed
            - failed
            - needs_review
          example: completed
        status:
          type: string
          enum:
            - pending
            - processing
            - extracted
            - reviewed
            - approved
            - rejected
            - duplicate
          example: extracted
        direction:
          type: string
          enum:
            - payable
            - receivable
          example: payable
          description: Payable (vendor bill) or receivable (customer invoice).
        ready:
          type: boolean
          example: true
          description: >-
            True when extraction has finished (completed, needs_review, or
            failed). Keep polling while false.
        data:
          nullable: true
          description: >-
            Extracted invoice fields. Null while queued/processing with no
            result yet.
          allOf:
            - $ref: '#/components/schemas/ExtractedInvoiceDataDto'
        ocrConfidence:
          type: number
          nullable: true
          example: 92.5
        extractionTier:
          type: number
          nullable: true
          example: 2
          description: Platform admin only. Omitted from tenant responses.
        extractionProvider:
          type: string
          nullable: true
          example: mistral
          description: Platform admin only. Omitted from tenant responses.
        routingReason:
          type: string
          nullable: true
          description: Platform admin only. Omitted from tenant responses.
        validationErrors:
          example: []
          type: array
          items:
            type: string
        processingError:
          type: string
          nullable: true
        isDuplicate:
          type: boolean
          example: false
        vendor:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/InvoiceJsonVendorDto'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - processingStatus
        - status
        - direction
        - ready
        - validationErrors
        - isDuplicate
        - createdAt
        - updatedAt
    ApiErrorResponseDto:
      type: object
      properties:
        statusCode:
          type: number
          example: 401
        message:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          example: Invalid or missing API key
        error:
          type: string
          example: Unauthorized
      required:
        - statusCode
        - message
    ExtractedInvoiceDataDto:
      type: object
      properties:
        invoice_number:
          type: string
          nullable: true
          example: INV-1042
        invoice_date:
          type: string
          nullable: true
          example: '2026-09-01'
        due_date:
          type: string
          nullable: true
          example: '2026-09-30'
        vendor_name:
          type: string
          nullable: true
          example: Acme Supplies
        vendor_address:
          type: string
          nullable: true
        vendor_tax_id:
          type: string
          nullable: true
        vendor_email:
          type: string
          nullable: true
        customer_name:
          type: string
          nullable: true
        currency:
          type: string
          nullable: true
          example: MYR
        payment_terms:
          type: string
          nullable: true
        subtotal:
          type: number
          nullable: true
          example: 100
        discount:
          type: number
          nullable: true
          example: 0
        tax_amount:
          type: number
          nullable: true
          example: 6
        service_charge:
          type: number
          nullable: true
          example: 0
        shipping_cost:
          type: number
          nullable: true
          example: 0
        total_amount:
          type: number
          nullable: true
          example: 106
        paid_amount:
          type: number
          nullable: true
          example: 0
        balance_amount:
          type: number
          nullable: true
          example: 106
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/ExtractedLineItemDto'
        raw_text:
          type: string
          nullable: true
          description: OCR raw text when available
    InvoiceJsonVendorDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
        vendorName:
          type: string
          example: Acme Supplies
      required:
        - id
        - vendorName
    ExtractedLineItemDto:
      type: object
      properties:
        line_no:
          type: number
          nullable: true
          example: 1
        description:
          type: string
          example: Coca Cola 330ml x24
        sku:
          type: string
          nullable: true
          example: CC-330-24
        quantity:
          type: number
          nullable: true
          example: 2
        unit:
          type: string
          nullable: true
          example: ctn
        unit_price:
          type: number
          nullable: true
          example: 50
        discount:
          type: number
          nullable: true
          example: 0
        tax:
          type: number
          nullable: true
          example: 6
        line_total:
          type: number
          nullable: true
          example: 100
      required:
        - description
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: Authorization
      description: Bearer sk_live_… (include the Bearer prefix)
      x-default: Bearer sk_live_…

````

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