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

# Prepare an invoice upload slot (API key)

> Creates a pending invoice and returns `invoiceId`. Attach the file with `POST /api/v1/invoices/upload/:invoiceId/file`. Credits are not deducted until the file is attached.



## OpenAPI

````yaml /openapi/programmatic.json post /api/v1/invoices/upload/init
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/upload/init:
    post:
      tags:
        - programmatic
      summary: Prepare an invoice upload slot (API key)
      description: >-
        Creates a pending invoice and returns `invoiceId`. Attach the file with
        `POST /api/v1/invoices/upload/:invoiceId/file`. Credits are not deducted
        until the file is attached.
      operationId: prepareUpload
      parameters: []
      responses:
        '202':
          description: Upload slot created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrepareUploadResponseDto'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponseDto'
      security:
        - api-key: []
components:
  schemas:
    PrepareUploadResponseDto:
      type: object
      properties:
        invoiceId:
          type: string
          format: uuid
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        processingStatus:
          type: string
          enum:
            - queued
            - processing
            - completed
            - failed
            - needs_review
          example: queued
          description: Always queued until a file is attached
      required:
        - invoiceId
        - processingStatus
    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
  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.