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

# Upload invoice PDF

> Upload the PDF of an invoice the claim is based on. A new invoice is created for it; its amount adds to the
claim's `total_claim_amount`. Fields you send are stored on that invoice; the PDF is read automatically for
the ones you leave out.

**Only PDF files** (`multipart/form-data`, a `file` part). The fields may come before or after the file part.
Field names: `total_amount` is stored as `invoice_amount_gross`, `maturity_date` as `invoice_due_date`,
`issue_date` as `invoice_issue_date`. Files over 50 MB answer `413`.

An invoice partly paid before handover: send `total_amount` (the amount on the invoice) and `amount_paid`
(optionally `last_payment_date`); the rules are those of the manual invoice endpoint. A refused combination
answers `400` and stores nothing.

Required fields and the health-data check of your partner agreement (see *Partner intake rules*) are applied
before the PDF is stored: a refused upload stores nothing. `description` / `subject` is checked as the subject.


> [!NOTE]
>
> This endpoint requires `multipart/form-data` with a PDF file upload.
> The interactive playground cannot send file uploads; use Insomnia/Postman for testing.

## Overview

Upload a PDF invoice and attach it to a claim. When you upload a PDF, it is stored and linked to the claim, and OCR attempts to extract invoice data and populate the invoice record.

> [!WARNING]
>
> **PDF files only**: Only PDF format is accepted. Other file formats (images, Word, Excel, etc.) will be rejected.

### Request Format

* Content-Type: `multipart/form-data`
* Required field: `file` (**PDF only**)
* Optional text fields: `invoice_number`, `total_amount`, `maturity_date`, `issue_date`, `invoice_issuer`, `invoice_recipient`, `subject`, `invoice_amount_net`, `creditor_reminder_fees_incurred`, `amount_paid`, `last_payment_date`

## Authentication

Requires API Token authentication via Bearer token.

## Path Parameters

**claim\_id** `string` *required*

UUID of the claim you are attaching an invoice to

## Request Body (Multipart Form)

**file** `file` *required*

PDF invoice file to upload. Only PDF format is accepted.

**invoice\_number** `string`

Invoice number

**total\_amount** `string`

Gross amount of the invoice (maps to `invoice_amount_gross`)

**maturity\_date** `string`

Due date in ISO 8601 format (maps to `invoice_due_date`)

**issue\_date** `string`

Issue date in ISO 8601 format (maps to `invoice_issue_date`)

**invoice\_issuer** `string`

Invoice issuer name

**invoice\_recipient** `string`

Invoice recipient name

**subject** `string`

Optional subject/description

**invoice\_amount\_net** `string`

Net amount

**creditor\_reminder\_fees\_incurred** `string`

Reminder fees (still unpaid)

**amount\_paid** `string`

Amount the debtor already paid you on this invoice before handover. Requires `total_amount` and must be less than it. We collect only the rest; it is not recorded as a payment. A refused combination answers `400` and stores nothing. See the manual invoice endpoint for details.

**last\_payment\_date** `string`

Date of that payment (`YYYY-MM-DD`, not in the future). Requires `amount_paid`.

## Testing Instructions

1. Create a new request: Method `POST`, URL `/openapi/claims//invoices`
2. Auth tab: Type `Bearer`, Token = your API token
3. Body tab: Type `Multipart Form`
   * Add field `file` with type `File`, select your `.pdf` (original filename is automatically preserved)
   * Optional text fields: `invoice_number`, `total_amount`, `maturity_date`, `issue_date`, `invoice_issuer`, `invoice_recipient`, `subject`, `invoice_amount_net`, `creditor_reminder_fees_incurred`, `amount_paid`, `last_payment_date`
4. Send request and verify `201` response

> [!NOTE]
>
> **Filename Preservation**: When using `multipart/form-data`, the original PDF filename is automatically preserved.
>
> The Mintlify playground cannot send `multipart/form-data` with files. Use Insomnia/Postman for testing.

## Examples

```bash cURL theme={null}
curl -X POST \
  'https://<host>/openapi/claims/3c90c3cc-0d44-4b50-8888-8dd257363052/invoices' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -F 'file=@/path/to/invoice.pdf' \
  -F 'invoice_number=INV-2025-001' \
  -F 'total_amount=123.45' \
  -F 'maturity_date=2025-10-01' \
  -F 'issue_date=2025-09-15' \
  -F 'invoice_issuer=Acme GmbH' \
  -F 'invoice_recipient=John Doe' \
  -F 'subject=Original invoice PDF'
```

```javascript JavaScript theme={null}
const formData = new FormData()
formData.append('file', yourFileInput.files[0])
formData.append('invoice_number', 'INV-2025-001')
formData.append('total_amount', '123.45')
formData.append('maturity_date', '2025-10-01')
formData.append('issue_date', '2025-09-15')
formData.append('invoice_issuer', 'Acme GmbH')
formData.append('invoice_recipient', 'John Doe')
formData.append('subject', 'Original invoice PDF')

const res = await fetch('https://<host>/openapi/claims/3c90c3cc-0d44-4b50-8888-8dd257363052/invoices', {
  method: 'POST',
  headers: { Authorization: 'Bearer YOUR_API_TOKEN' },
  body: formData,
})
const json = await res.json()
```

```python Python theme={null}
import requests

url = 'https://<host>/openapi/claims/3c90c3cc-0d44-4b50-8888-8dd257363052/invoices'
headers = { 'Authorization': 'Bearer YOUR_API_TOKEN' }

files = { 'file': ('invoice.pdf', open('invoice.pdf', 'rb'), 'application/pdf') }
data = {
  'invoice_number': 'INV-2025-001',
  'total_amount': '123.45',
  'maturity_date': '2025-10-01',
  'issue_date': '2025-09-15',
  'invoice_issuer': 'Acme GmbH',
  'invoice_recipient': 'John Doe',
  'subject': 'Original invoice PDF',
}

response = requests.post(url, headers=headers, files=files, data=data)
print(response.status_code, response.text)
```

## Responses

```json Success theme={null}
{
  "success": true,
  "data": {
    "id": "b7c2d6ba-9d2c-42b6-8e1f-4a8e3d9e9c77",
    "claim_id": "3c90c3cc-0d44-4b50-8888-8dd257363052",
    "invoice_number": "INV-2025-001",
    "invoice_amount_gross": 123.45,
    "invoice_due_date": "2025-10-01",
    "invoice_issue_date": "2025-09-15",
    "invoice_issuer": "Acme GmbH",
    "invoice_recipient": "John Doe",
    "subject": "Original invoice PDF",
    "created_at": "2025-10-11T10:30:00Z"
  }
}
```

```json Error - Claim Not Found theme={null}
{
  "success": false,
  "message": "Claim not found"
}
```

```json Error - Invalid File Type theme={null}
{
  "success": false,
  "message": "Invalid file type. Only PDF files are allowed for invoice uploads."
}
```

```json Error - No File Uploaded theme={null}
{
  "success": false,
  "message": "Invalid request. This endpoint only supports PDF invoice uploads via multipart/form-data. Please use multipart/form-data with a file field. The original filename will be automatically preserved."
}
```

## Notes

* This endpoint **only accepts PDF file uploads** via `multipart/form-data`
* OCR runs on uploaded PDFs and may populate invoice fields automatically
* The invoice amount will automatically update the claim's total\_claim\_amount via database triggers


## OpenAPI

````yaml post /openapi/claims/{claim_id}/invoices
openapi: 3.0.3
info:
  title: incaseof.law Partner API
  version: 1.0.0
  description: >
    The incaseof.law partner API (`/openapi/*`): create claims and debtors,
    attach invoices and documents, record

    payments, follow a claim through collection and take the judicial-step
    decision.


    This document is the contract the API is tested against: every path, request
    body and response field here is

    compared with the implementation on each change. A field that is not listed
    here is not part of the API.


    ## Authentication


    Every `/openapi` request carries `Authorization: Bearer <api key>`. API keys
    are opaque strings starting with

    `ico_live_` (not JWTs). Request a key at https://app.incaseof.law/openapi;
    incaseof.law reviews the request and

    sends the key by e-mail.


    - **Organisation keys** act for one creditor organisation.

    - **Partner keys** act for a partner (software vendor, reseller) and its
    customers. Requests that create a claim
      or a debtor name the customer with `customer_id`; reads and updates reach every object of the partner's own
      customers without it. A `customer_id` that does not exist answers `400`, one of another partner `403`.

    ## Errors


    Every error answers `{ "success": false, "message": "…" }`, some with an
    `error` code. Validation errors list the

    failed fields in `details` (see `BadRequest`). Every response carries the
    rate-limit headers (see

    `TooManyRequests`).


    ## Partner intake rules


    Some partner agreements require more than the API's own required fields, and
    some prohibit data. They apply to

    partner keys only, are set per partner account by incaseof.law, and are
    checked **before anything is stored** — a

    refused request leaves no claim, invoice, PDF, payment, document or customer
    behind.


    - **Required fields.** The fields marked *optional unless your partner
    agreement requires it* exist for every
      caller. When your agreement requires one, a request without it answers `400` naming each missing field
      (`"message": "default_date required"`, one `details` entry per field). They are checked on creation only: on
      `POST /openapi/claims` (`creditor_confirmation`), both invoice endpoints (`default_date`,
      `creditor_reminder_dates` — not with `default_basis: bgb_286_3` —, `contract_date`, `subject`),
      `POST /openapi/debtors` (`legal_representative`) and `POST /openapi/customers` (`legal_form`,
      `legal_representative` — `owner` for a sole trader —, `billing_email`, `payout_account`, `vat_deductible`).
    - **Prohibited data (health data).** When your agreement prohibits health
    data, these free-text fields are checked:
      invoice `subject` (on the PDF upload also `description`), `invoice_issuer`, `invoice_recipient`; payment `notes`;
      document `description`; customer `metadata`. A value that looks like a health insurance number (KVNR: a capital
      letter and nine digits), an institution code (IK: a nine-digit number on its own), the word `PZN`, `Pflegegrad`,
      `Diagnose`, the word `ICD` or an ICD code with its dot (`F32.1`) answers `400` with
      `"error": "PROHIBITED_DATA"` and the field in `details` (the value is never echoed). Use neutral wording, e.g.
      "Privatärztliche Leistung vom 01.09.2026".

    ## Webhooks


    incaseof.law can push events to a partner-controlled HTTPS endpoint whenever
    a claim's lifecycle changes:

    `claim.collection_stage_changed` and `claim.status_changed`. See the
    **Webhooks** section at the bottom of this

    document for the payload shape, header reference, signature scheme and retry
    policy.
servers:
  - url: https://service.incaseof.law
    description: Production API
  - url: https://sandbox.incaseof.law
    description: Partner sandbox (test data only, sandbox keys — see "Partner sandbox")
security:
  - bearerAuth: []
tags:
  - name: Health
    description: Service availability
  - name: Claims
    description: Claims, their status and the judicial-step decision
  - name: Debtors
    description: Debtors of your claims
  - name: Invoices
    description: The invoices a claim is based on
  - name: Payments
    description: Payments the debtor made
  - name: Documents
    description: Supporting documents of a claim
  - name: Customers
    description: A partner's customers (the creditors it works for)
paths:
  /openapi/claims/{claim_id}/invoices:
    post:
      tags:
        - Invoices
      summary: Upload invoice PDF
      description: >
        Upload the PDF of an invoice the claim is based on. A new invoice is
        created for it; its amount adds to the

        claim's `total_claim_amount`. Fields you send are stored on that
        invoice; the PDF is read automatically for

        the ones you leave out.


        **Only PDF files** (`multipart/form-data`, a `file` part). The fields
        may come before or after the file part.

        Field names: `total_amount` is stored as `invoice_amount_gross`,
        `maturity_date` as `invoice_due_date`,

        `issue_date` as `invoice_issue_date`. Files over 50 MB answer `413`.


        An invoice partly paid before handover: send `total_amount` (the amount
        on the invoice) and `amount_paid`

        (optionally `last_payment_date`); the rules are those of the manual
        invoice endpoint. A refused combination

        answers `400` and stores nothing.


        Required fields and the health-data check of your partner agreement (see
        *Partner intake rules*) are applied

        before the PDF is stored: a refused upload stores nothing. `description`
        / `subject` is checked as the subject.
      operationId: uploadInvoice
      parameters:
        - in: path
          name: claim_id
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The invoice PDF
                invoice_number:
                  type: string
                total_amount:
                  type: number
                  description: Gross amount in EUR
                maturity_date:
                  type: string
                  format: date
                issue_date:
                  type: string
                  format: date
                invoice_issuer:
                  type: string
                  description: The creditor's name on the invoice
                invoice_recipient:
                  type: string
                  description: The debtor's name on the invoice
                subject:
                  type: string
                description:
                  type: string
                  description: Stored as the subject when `subject` is not sent
                invoice_amount_net:
                  type: number
                creditor_reminder_fees_incurred:
                  type: number
                  description: >-
                    Reminder fees the creditor already charged and that are
                    still unpaid
                amount_paid:
                  type: number
                  minimum: 0.01
                  description: >-
                    Paid by the debtor to the creditor before handover. Requires
                    `total_amount` and must be less than it; see the manual
                    invoice endpoint
                last_payment_date:
                  type: string
                  format: date
                  description: Date of that payment; requires `amount_paid`
                default_date:
                  type: string
                  format: date
                  description: The date the debtor fell into default
                creditor_reminder_dates:
                  type: string
                  description: >-
                    The dates of your own reminders: comma-separated
                    (`2026-10-01,2026-10-15`), a JSON array, or the field
                    repeated once per date; see the manual invoice endpoint
                default_basis:
                  type: string
                  enum:
                    - reminder
                    - bgb_286_3
                  description: See the manual invoice endpoint
                contract_date:
                  type: string
                  format: date
                  description: The date of the contract the invoice is based on
                documentType:
                  type: string
                  default: invoice
            encoding:
              file:
                contentType: application/pdf
      responses:
        '201':
          description: Invoice created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    Invoice:
      type: object
      properties:
        id:
          type: string
          format: uuid
        claim_id:
          type: string
          format: uuid
        invoice_number:
          type: string
          nullable: true
          example: INV-1001
        invoice_issuer:
          type: string
          nullable: true
        invoice_recipient:
          type: string
          nullable: true
        subject:
          type: string
          nullable: true
        invoice_amount_net:
          type: number
          nullable: true
        invoice_amount_gross:
          type: number
          nullable: true
          description: The amount on the invoice
        invoice_issue_date:
          type: string
          format: date
          nullable: true
        invoice_due_date:
          type: string
          format: date
          nullable: true
        creditor_reminder_fees_incurred:
          type: number
          nullable: true
        amount_paid:
          type: number
          nullable: true
          description: >-
            Paid by the debtor to the creditor before handover, as you reported
            it; `null` when nothing was reported
        last_payment_date:
          type: string
          format: date
          nullable: true
          description: Date of that payment, when reported
        amount_open:
          type: number
          nullable: true
          description: >-
            The part of the invoice amount we collect: `invoice_amount_gross` −
            `amount_paid`
        default_date:
          type: string
          format: date
          nullable: true
          description: The date the debtor fell into default, as you sent it
        creditor_reminder_dates:
          type: array
          nullable: true
          items:
            type: string
            format: date
          description: The dates of your own reminders before handover, as you sent them
        default_basis:
          type: string
          enum:
            - reminder
            - bgb_286_3
          nullable: true
          description: >-
            How the default arose, as you sent it; `null` when not sent (read as
            `reminder`)
        contract_date:
          type: string
          format: date
          nullable: true
          description: The date of the contract the invoice is based on
        data_extraction_status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
            - manual
          description: >-
            State of the automatic reading of an uploaded PDF; `manual` for an
            invoice created from data.
        data_extraction_confidence:
          type: number
          nullable: true
          description: 0–100
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  responses:
    BadRequest:
      description: >
        The request is invalid. A body that fails validation answers `error:
        VALIDATION_ERROR` with one entry per

        problem in `details` (`path` — the field, as a list of keys and indexes;
        `message`; `code`). Other `400`s carry

        only `message`.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                example: VALIDATION_ERROR
              message:
                type: string
                example: Validation failed
              details:
                type: array
                items:
                  type: object
                  properties:
                    path:
                      type: array
                      items:
                        oneOf:
                          - type: string
                          - type: integer
                    message:
                      type: string
                    code:
                      type: string
                      example: invalid_type
          examples:
            validationError:
              value:
                success: false
                error: VALIDATION_ERROR
                message: Validation failed
                details:
                  - code: invalid_type
                    expected: string
                    received: undefined
                    path:
                      - invoice_number
                    message: Required
            businessRule:
              value:
                success: false
                message: >-
                  Payment invoice number must match an active collection letter
                  or cost invoice. Active document numbers: ICO-2026-000123
    Unauthorized:
      description: The `Authorization` header is missing, or the key is invalid or expired.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                example: Unauthorized
              message:
                type: string
                example: >-
                  Invalid API token. Please check your token or request a new
                  one.
    NotFound:
      description: The object does not exist or is not reachable with this key.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Claim not found
    PayloadTooLarge:
      description: The file is larger than 50 MB.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                example: FST_REQ_FILE_TOO_LARGE
              message:
                type: string
                example: request file too large
    TooManyRequests:
      description: >
        The key's hourly limit is used up — every `/openapi` request can answer
        this. Requests are counted per key and

        clock hour (UTC); the limit is agreed per key (default 1 000 per hour).
        Retry after `Retry-After` seconds.

        Every answer — not only this one — carries `X-RateLimit-Limit`,
        `X-RateLimit-Remaining` and `X-RateLimit-Reset`.
      headers:
        Retry-After:
          description: Seconds until the next hour starts and requests are admitted again.
          schema:
            type: integer
            example: 1260
        X-RateLimit-Limit:
          description: Requests allowed per hour for this key.
          schema:
            type: integer
            example: 1000
        X-RateLimit-Remaining:
          description: Requests left in the current hour (0 here).
          schema:
            type: integer
            example: 0
        X-RateLimit-Reset:
          description: Unix time (seconds) at which the count starts again.
          schema:
            type: integer
            example: 1790002800
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                example: Too Many Requests
              message:
                type: string
                example: >-
                  Rate limit exceeded. Your limit is 1000 requests per hour.
                  Please try again later.
              details:
                type: object
                properties:
                  limit:
                    type: integer
                    example: 1000
                  window:
                    type: string
                    example: 1 hour
                  resets_at:
                    type: string
                    format: date-time
    InternalServerError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
                example: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API key (`ico_live_…`), sent as `Authorization: Bearer <key>`. Not a
        JWT.

````

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