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

# Add an invoice PDF attachment

> Add an invoice PDF attachment through the public API.

Send the PDF as the `file` part of a multipart request with a `title` field. The response contains the uploaded file under `attachment`.

You can attach up to ten PDFs to an invoice. Each file may be at most 10 MiB (10,485,760 bytes). Infinity checks the actual file contents and rejects PDFs whose pages cannot be rendered.

Issued invoices allow attachment changes only while they have no payments, have not been annulled, belong to an editable fiscal year, and are outside settled VAT periods. Draft attachments remain editable.

Attachments added through the API also appear in the invoice editor and generated invoice PDF.


## OpenAPI

````yaml POST /v1/invoices/{invoiceId}/pdf-attachments
openapi: 3.1.0
info:
  title: infinity.swiss Open API
  version: '1.0'
  summary: ''
servers:
  - url: https://api.infinity.swiss
security:
  - apiKey: []
paths:
  /v1/invoices/{invoiceId}/pdf-attachments:
    parameters:
      - name: invoiceId
        in: path
        required: true
        schema:
          type: string
    post:
      summary: Add an invoice PDF attachment
      description: >-
        Uploads one PDF of at most 10 MiB. An invoice can have up to ten
        attachments. Requires invoice write access and an editable invoice.
      operationId: add-invoice-pdf-attachment-v1
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - title
              properties:
                file:
                  type: string
                  format: binary
                  description: A valid PDF file. Its actual contents determine its type.
                title:
                  type: string
                  description: >-
                    Required upload title. The attachment name comes from the
                    file's original filename.
      responses:
        '201':
          description: The uploaded attachment.
          content:
            application/json:
              schema:
                type: object
                required:
                  - attachment
                properties:
                  attachment:
                    $ref: '#/components/schemas/InvoicePdfAttachment'
        '400':
          description: >-
            Missing upload fields, malformed PDF, or the invoice already has ten
            attachments.
        '401':
          $ref: '#/components/responses/Unauthorised'
        '403':
          $ref: '#/components/responses/InvoiceAttachmentForbidden'
        '404':
          $ref: '#/components/responses/CustomerInvoiceNotFound'
        '413':
          description: The PDF exceeds 10,485,760 bytes.
        '415':
          description: The file contents are not PDF.
components:
  schemas:
    InvoicePdfAttachment:
      type: object
      required:
        - id
        - url
        - name
        - type
        - size
      properties:
        id:
          type: string
        url:
          type: string
          format: uri
        name:
          type: string
        type:
          type: string
          enum:
            - application/pdf
        size:
          type: integer
          description: File size in bytes.
          maximum: 10485760
  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
    InvoiceAttachmentForbidden:
      description: >-
        Invoice-module access is missing, or attachments are read-only. Issued
        invoices and estimates become read-only when annulled, paid, outside an
        editable fiscal year, or in a settled VAT period. Draft attachments
        remain editable.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                enum:
                  - rest-api/insufficient-scope
                  - customer-invoices/attachments-read-only
    CustomerInvoiceNotFound:
      description: >-
        No invoice or estimate with the given id could be found in this
        organisation. Also returned when the id refers to the other kind of
        document, e.g. an estimate id on an invoice endpoint.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                description: Specific error code.
          examples:
            Not found:
              value:
                code: customer-invoices/not-found
  securitySchemes:
    apiKey:
      name: x-api-token
      type: apiKey
      in: header
      description: >-
        API token for authentication. Obtain from your Infinity account
        settings.

````

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