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

# Upload a receipt

> Uploads a receipt or other document to the organisation's documents, and optionally attaches it to an existing ledger entry.

The request must be sent as `multipart/form-data` with the file contents in the `file` field.

## Uploading a receipt

Send the request as `multipart/form-data` with the file contents in the `file` field. For example, the following request uploads a receipt PDF and attaches it to an existing ledger entry:

```bash theme={null}
curl -X POST https://api.infinity.swiss/v1/receipts \
  -H "x-api-token: your-api-token" \
  -F "file=@receipt.pdf" \
  -F "title=Coffee receipt 2025-01-30" \
  -F "note=Team breakfast" \
  -F "transactionId=682338d9e9500b3ffe4baa5a"
```

If `transactionId` is omitted, the document lands in the organisation's document inbox, where it can be processed later — just like a manual upload in the app.

## Supported file types

Files can be at most **10 MB** in size, and must be one of the following types:

| Content type      | Format        |
| ----------------- | ------------- |
| `application/pdf` | PDF documents |
| `image/png`       | PNG images    |
| `image/jpeg`      | JPEG images   |
| `image/gif`       | GIF images    |
| `image/tiff`      | TIFF images   |
| `image/heic`      | HEIC images   |
| `image/heif`      | HEIF images   |

<Note>
  The actual contents of the uploaded file are validated. Files whose content
  does not match one of the supported types are rejected with a
  `415 Unsupported Media Type` response and the error code
  `files/unsupported-file-type`, even if a supported content type or file
  extension is claimed in the request.
</Note>

## Live Capture analysis

If Live Capture is enabled for the organisation and analysis quota is available, an automatic document analysis starts after the upload, similar to uploading a receipt manually in the app. The analysis runs in the background and does not delay the response.

To skip the automatic analysis for an upload, set the `suppressAnalysis` field to `true`.

## Rate limits

Because uploads are materially more expensive to process than other requests, this endpoint has a stricter rate limit than the rest of the API: at most **100 requests per hour**. When the limit is exceeded, you'll receive a `429 Too Many Requests` response with error code `general/too-many-requests`.

Uploads are also processed in a background queue, so bursts of uploads within the rate limit (for example, an automation submitting dozens of receipts in a short window) are handled gracefully. Analyses from a large batch are processed a few at a time, so it can take several minutes until every document in the batch has finished analysing.


## OpenAPI

````yaml POST /v1/receipts
openapi: 3.1.0
info:
  title: infinity.swiss Open API
  version: '1.0'
  summary: ''
servers:
  - url: https://api.infinity.swiss
security:
  - apiKey: []
paths:
  /v1/receipts:
    post:
      tags: []
      summary: Upload a receipt
      description: >-
        Uploads a receipt or other document to the organisation's documents, and
        optionally attaches it to an existing ledger entry.


        The request must be sent as `multipart/form-data` with the file contents
        in the `file` field.
      operationId: post-receipt-v1
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - title
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    The file to upload (maximum 10 MB). Supported content types:

                    - `application/pdf`

                    - `image/png`

                    - `image/jpeg`

                    - `image/gif`

                    - `image/tiff`

                    - `image/heic`

                    - `image/heif`


                    The actual file content is validated, so the file must
                    really be one of these types regardless of the declared
                    content type or file extension.
                title:
                  type: string
                  maxLength: 200
                  description: A title or file name for the document.
                  example: Coffee receipt 2025-01-30
                note:
                  type: string
                  maxLength: 1000
                  description: An optional note to store with the document.
                transactionId:
                  type: string
                  description: >-
                    The id of an existing ledger entry transaction to attach the
                    receipt to. If set, the document is filed to the `receipts`
                    location. If unset, the document lands in the `inbox`.
                  example: 682338d9e9500b3ffe4baa5a
                suppressAnalysis:
                  type: string
                  enum:
                    - 'true'
                    - 'false'
                  description: >-
                    If `true`, no automatic Live Capture document analysis is
                    started for this upload. By default, analysis starts after
                    upload if Live Capture is enabled for the organisation and
                    analysis quota is available.
        description: The receipt file and its metadata as multipart/form-data.
      responses:
        '201':
          description: The receipt was uploaded successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - receipt
                properties:
                  receipt:
                    $ref: '#/components/schemas/Receipt'
        '400':
          description: >-
            A bad request is thrown if the provided form fields are invalid or
            no file was included in the request.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      May be:
                      - `general/missing-fields`
                      - `general/malformed-request`
                      - `files/no-file-uploaded`
                  invalidFields:
                    type: array
                    uniqueItems: true
                    description: A list of the fields which were invalid, if applicable.
                    items:
                      type: string
                      example: title
        '401':
          $ref: '#/components/responses/Unauthorised'
        '404':
          description: >-
            A 404 error is received when the ledger entry referenced by
            `transactionId` does not exist in this organisation. Nothing is
            uploaded or stored in this case.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `transactions/not-found`
        '413':
          description: The uploaded file exceeds the maximum allowed file size of 10 MB.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `files/file-too-large`
        '415':
          description: >-
            The uploaded file is not one of the supported file types. The file's
            actual content is inspected, so uploads of unsupported or malicious
            files are blocked even if they claim a supported content type or
            file extension.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `files/unsupported-file-type`
                  supportedTypes:
                    type: array
                    description: A list of the supported content types.
                    items:
                      type: string
                      example: application/pdf
        '429':
          description: >-
            The rate limit for receipt uploads was exceeded. Receipt uploads
            have a stricter rate limit of 100 requests per hour, since they are
            more expensive to process than other requests.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: |-
                      The specific error code for this request.
                      Can be:
                      - `general/too-many-requests`
components:
  schemas:
    Receipt:
      title: Receipt
      type: object
      description: A receipt document that was uploaded to the organisation.
      required:
        - id
        - title
        - location
        - uploadedAt
      properties:
        id:
          type: string
          description: A unique hex identifier for the document.
          example: 686f1b2ce9500b3ffe4bbc71
        title:
          type: string
          description: The title of the document.
          example: Coffee receipt 2025-01-30
        note:
          type: string
          description: The note stored with the document, if one was provided.
        location:
          type: string
          enum:
            - inbox
            - receipts
          description: >-
            The location of the document. Documents attached to a ledger entry
            are filed to `receipts`, all others land in the `inbox`.
        transactionId:
          type: string
          description: >-
            The id of the ledger entry transaction the document was attached to,
            if attachment was requested.
          example: 682338d9e9500b3ffe4baa5a
        analysisStatus:
          type: string
          description: >-
            The status of the Live Capture document analysis, if one was
            started.
        uploadedAt:
          type: string
          format: date-time
          description: The time at which the document was uploaded.
          example: '2025-01-30T12:00:00.000Z'
  responses:
    Unauthorised:
      description: >-
        An unauthorised request was submitted. You may be using an incorrect or
        expired API token, or are attempting to access a document outside of the
        scope of the token.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                x-stoplight:
                  id: 08hkw8ukmi2lp
                description: Specific error code
          examples:
            Unauthorised request:
              value:
                code: general/unauthorised
  securitySchemes:
    apiKey:
      name: x-api-token
      type: apiKey
      in: header
      description: >-
        API token for authentication. Obtain from your Infinity account
        settings.

````