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

# Attach a document (PDF)

> Attaches a PDF document to an existing invoice entry in the accounting system as a linked attachment.

**Learn more:**

* How to attach and retrieve documents on entries? [↗](/unified-apis/accounting/guides-and-behaviours/attachments-retrieval)


## OpenAPI

````yaml post /consumers/{consumer_id}/accounting/invoices/pdf/{invoice_id}
openapi: 3.1.0
info:
  title: Chift API
  description: >-
    The Chift API is a universal API giving you access to financial data from
    the software of your clients. It helps software companies to offer native
    integrations to their clients without the effort needed to maintain those
    native integrations. By using the APIs (Accounting, POS, eCommerce) of
    Chift, you connect once and allow your clients to use their software
    packages.
  version: 1.0.0
servers:
  - url: https://api.chift.eu
    description: Chift
security:
  - bearerAuth: []
paths:
  /consumers/{consumer_id}/accounting/invoices/pdf/{invoice_id}:
    post:
      tags:
        - Accounting
        - Attachments
      summary: Attach a document (PDF)
      description: >-
        Attaches a PDF document to an existing invoice entry in the accounting
        system as a linked attachment.
      operationId: accounting_add_attachment
      parameters:
        - name: consumer_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Consumer Id
        - name: invoice_id
          in: path
          required: true
          schema:
            type: string
            title: Invoice Id
        - name: folder_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Folder Id
          description: >-
            Id of the accounting folder instance. A folder represents a legal
            entity within the system. Required when the multiple folders feature
            is enabled.
        - name: overwrite_existing
          in: query
          required: false
          schema:
            anyOf:
              - $ref: '#/components/schemas/BoolParam'
              - type: 'null'
            default: 'false'
            title: Overwrite Existing
          description: Indicate what to do if a document is already attched to the invoice.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachmentItem'
      responses:
        '204':
          description: Successful Response
        '400':
          content:
            application/json:
              examples:
                ERROR_INVALID_BASE64_STRING:
                  value:
                    message: >-
                      The document is not a valid base64 string representing a
                      PDF.
                    status: error
                    error_code: ERROR_INVALID_BASE64_STRING
                ERROR_ATTACHMENT_ALREADY_EXISTS:
                  value:
                    message: An attachment already exists for this invoice.
                    status: error
                    error_code: ERROR_ATTACHMENT_ALREADY_EXISTS
              schema:
                $ref: '#/components/schemas/ChiftError'
          description: Bad Request
        '404':
          content:
            application/json:
              examples:
                ERROR_INVOICE_NOT_FOUND:
                  value:
                    message: The invoice doesn't exist in the accounting system.
                    status: error
                    error_code: ERROR_INVOICE_NOT_FOUND
                ERROR_INVOICE_NOT_FOUND_2:
                  value:
                    message: >-
                      The invoice '${invoice_id}' doesn't exist in the
                      accounting system.
                    status: error
                    error_code: ERROR_INVOICE_NOT_FOUND
              schema:
                $ref: '#/components/schemas/ChiftError'
          description: Not Found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - mcp_auth:
            - accounting
            - accounting.attachments
            - '200'
            - 200.attachments
components:
  schemas:
    BoolParam:
      type: string
      enum:
        - 'true'
        - 'false'
      title: BoolParam
    AttachmentItem:
      properties:
        base64_string:
          type: string
          title: Base64 String
        name:
          anyOf:
            - type: string
              maxLength: 200
              minLength: 1
              pattern: ^[a-zA-Z0-9\-_ ]{1,196}(?:.pdf)?$
            - type: 'null'
          title: Name
          description: >-
            A name for the PDF file to be created for accounting software that
            support it.
      type: object
      required:
        - base64_string
      title: AttachmentItem
    ChiftError:
      properties:
        message:
          type: string
          title: Message
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
          default: error
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
          default: ''
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
      type: object
      required:
        - message
      title: ChiftError
    HTTPValidationError:
      title: Validation Error
      required:
        - message
      type: object
      properties:
        message:
          title: Message
          type: string
          default: Validation error
        status:
          title: Status
          type: string
          default: error
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    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
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        This access token needs to be included in each of your request to the
        Chift API.

````