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

# Create customer (or reuse the existing one)

> Create a customer — a creditor you work for.

**`address` is required** — `street`, `zip`, `city` and `country` (ISO code of a European country). It is the
creditor address on the collection letters and the court-fee invoice; a missing or empty line is a `400` that
names it, e.g. `address.zip is required`.

**Partner keys:** `partner_id` is optional (it defaults to your partner account; another partner's id → `403`).
Without `customer_id` the customer gets an organisation of its own, created here. **Organisation keys:** the
customer is created in your organisation; `partner_id` names the referring partner.

**Reusing an existing client.** Send your own ID for the business as `partner_client_reference` and/or its VAT
ID as `uid` on every call. Before creating, the API looks for a customer of *your* partner account — first by
`partner_client_reference`, then by `uid`, and when neither matches, by the same `email` **and** the same
`name` (case and spaces ignored), provided that customer's stored `partner_client_reference` / `uid` do not
differ from the ones you sent:

- match → the existing customer is returned with **HTTP 200** and `reused: true` (same `id` and
  `organization_id`; stored name, email and address are not changed — use PATCH for that). A key the existing
  customer does not have yet is added to it.
- no match → a new customer is created, **HTTP 201**, `reused: false`.
- `partner_client_reference` matches one customer and `uid` another → **HTTP 409**, nothing is created.

Both keys are unique per partner account; another partner sending the same UID gets its own customer. Without
either key, only name and e-mail identify the client: a business whose name or e-mail you send differently
becomes a new customer — send `partner_client_reference` to make the match exact. The client's onboarding
invitation is sent once, with the first claim of that customer.

**Client e-mail that already has a login.** When `email` belongs to an existing incaseof.law user (e.g. one
owner running two companies), no invitation is sent: that user is added to the new customer's organisation
right away, gets a short e-mail that another company is now in their account, and sees it after the next
login. The response then has `existing_user_linked: true`. Each company stays its own customer — keep storing
one customer `id` per company.




## OpenAPI

````yaml post /openapi/customers
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/customers:
    post:
      tags:
        - Customers
      summary: Create customer (or reuse the existing one)
      description: >
        Create a customer — a creditor you work for.


        **`address` is required** — `street`, `zip`, `city` and `country` (ISO
        code of a European country). It is the

        creditor address on the collection letters and the court-fee invoice; a
        missing or empty line is a `400` that

        names it, e.g. `address.zip is required`.


        **Partner keys:** `partner_id` is optional (it defaults to your partner
        account; another partner's id → `403`).

        Without `customer_id` the customer gets an organisation of its own,
        created here. **Organisation keys:** the

        customer is created in your organisation; `partner_id` names the
        referring partner.


        **Reusing an existing client.** Send your own ID for the business as
        `partner_client_reference` and/or its VAT

        ID as `uid` on every call. Before creating, the API looks for a customer
        of *your* partner account — first by

        `partner_client_reference`, then by `uid`, and when neither matches, by
        the same `email` **and** the same

        `name` (case and spaces ignored), provided that customer's stored
        `partner_client_reference` / `uid` do not

        differ from the ones you sent:


        - match → the existing customer is returned with **HTTP 200** and
        `reused: true` (same `id` and
          `organization_id`; stored name, email and address are not changed — use PATCH for that). A key the existing
          customer does not have yet is added to it.
        - no match → a new customer is created, **HTTP 201**, `reused: false`.

        - `partner_client_reference` matches one customer and `uid` another →
        **HTTP 409**, nothing is created.


        Both keys are unique per partner account; another partner sending the
        same UID gets its own customer. Without

        either key, only name and e-mail identify the client: a business whose
        name or e-mail you send differently

        becomes a new customer — send `partner_client_reference` to make the
        match exact. The client's onboarding

        invitation is sent once, with the first claim of that customer.


        **Client e-mail that already has a login.** When `email` belongs to an
        existing incaseof.law user (e.g. one

        owner running two companies), no invitation is sent: that user is added
        to the new customer's organisation

        right away, gets a short e-mail that another company is now in their
        account, and sees it after the next

        login. The response then has `existing_user_linked: true`. Each company
        stays its own customer — keep storing

        one customer `id` per company.
      operationId: createCustomer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomerInput'
            examples:
              basic:
                summary: Create customer
                value:
                  name: Firma ABC GmbH
                  email: office@firma-abc.at
                  phone: +43 1 234 5678
                  address:
                    street: Hauptstraße 1
                    city: Wien
                    zip: '1010'
                    country: AT
              withKeys:
                summary: Create or reuse by your client reference and UID
                value:
                  name: Rauchfangkehrer Huber e.U.
                  email: office@huber-rauchfang.at
                  partner_client_reference: WIN-10457
                  uid: ATU12345678
                  address:
                    street: Gewerbestraße 4
                    city: Graz
                    zip: '8020'
                    country: AT
      responses:
        '200':
          description: Existing customer reused — nothing was created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseCustomerCreate'
        '201':
          description: Customer created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseCustomerCreate'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateCustomerInput:
      type: object
      required:
        - name
        - email
        - address
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        email:
          type: string
          format: email
        partner_id:
          type: string
          format: uuid
          description: >-
            Partner keys — defaults to your partner account. Organisation keys —
            the referring partner.
        phone:
          type: string
          maxLength: 50
        address:
          $ref: '#/components/schemas/CustomerAddressInput'
        metadata:
          type: object
          additionalProperties: true
        uid:
          type: string
          maxLength: 40
          nullable: true
          description: >
            EU VAT ID (UID) of the business, e.g. ATU12345678. Spaces and the
            separators - . / are removed and letters

            uppercased; after that it must be a 2-letter country prefix plus
            2–12 characters (otherwise 400). Unique per

            partner account. null is treated as not given.
          example: ATU12345678
        partner_client_reference:
          type: string
          maxLength: 255
          nullable: true
          description: >-
            Your own ID for this business. Trimmed, matched exactly. Unique per
            partner account; checked before uid.
          example: WIN-10457
        legal_form:
          type: string
          enum:
            - gmbh
            - einzelunternehmen
            - pauschalierter_land_forstwirt
            - flexco
            - eingetragener_kaufmann
            - gbr
            - og_ohg
            - kg
            - gmbh_co_kg
            - ug
            - ag
            - se
            - eg
            - verein
            - praktiker
            - partg
            - kgaa
          description: The provider's legal form. German court filings need it.
        legal_representative:
          $ref: '#/components/schemas/ProviderLegalRepresentativeInput'
        owner:
          $ref: '#/components/schemas/ProviderOwnerInput'
        billing_email:
          type: string
          format: email
          description: Where invoices from incaseof.law to the provider go
        vat_deductible:
          type: boolean
          description: >-
            Whether the provider may deduct input VAT (Vorsteuerabzug). A German
            court filing declares it.
        payout_account:
          $ref: '#/components/schemas/PayoutAccountInput'
    ApiResponseCustomerCreate:
      type: object
      properties:
        success:
          type: boolean
          example: true
        reused:
          type: boolean
          description: >-
            true (HTTP 200) when an existing customer was returned, false (HTTP
            201) when one was created
        existing_user_linked:
          type: boolean
          description: >-
            true when the customer's `email` belongs to an existing incaseof.law
            user who was added to this customer's organisation by this call (no
            invitation is sent in that case); false otherwise
        data:
          $ref: '#/components/schemas/Customer'
    CustomerAddressInput:
      type: object
      required:
        - street
        - zip
        - city
        - country
      additionalProperties: true
      description: >
        Postal address of the business — required. It becomes the creditor
        address on the collection letters and on

        the court-fee invoice. Each line must be a non-empty string; a missing
        or empty line is a `400 VALIDATION_ERROR`

        naming it (e.g. `address.zip is required`).
      properties:
        street:
          type: string
          minLength: 1
          description: Street and house number
          example: Ringstrasse 10
        zip:
          type: string
          minLength: 1
          example: '1010'
        city:
          type: string
          minLength: 1
          example: Wien
        country:
          type: string
          description: >-
            ISO 3166-1 alpha-2 code of a European country, case-insensitive
            (stored upper-case).
          enum:
            - DE
            - AT
            - CH
            - AL
            - AD
            - BY
            - BE
            - BA
            - BG
            - HR
            - CY
            - CZ
            - DK
            - EE
            - FI
            - FR
            - GR
            - HU
            - IS
            - IE
            - IT
            - LV
            - LI
            - LT
            - LU
            - MT
            - MD
            - MC
            - ME
            - NL
            - MK
            - 'NO'
            - PL
            - PT
            - RO
            - RU
            - SM
            - RS
            - SK
            - SI
            - ES
            - SE
            - UA
            - GB
          example: AT
    ProviderLegalRepresentativeInput:
      type: object
      description: >
        Partner keys only. The provider's legal representative (gesetzlicher
        Vertreter), e.g. `{ "function":

        "Geschäftsführer", "name": "Dr. Anna Berger" }` for a GmbH. For a sole
        trader (`einzelunternehmen`,

        `eingetragener_kaufmann`, `praktiker`, `pauschalierter_land_forstwirt`)
        send `owner` instead — a German court

        never takes the owner as the representative.
      required:
        - function
        - name
      properties:
        function:
          type: string
          minLength: 1
          maxLength: 35
        name:
          type: string
          minLength: 1
          maxLength: 35
    ProviderOwnerInput:
      type: object
      description: Partner keys only. The owner of a sole trader.
      required:
        - first_name
        - last_name
      properties:
        first_name:
          type: string
          minLength: 1
          maxLength: 80
        last_name:
          type: string
          minLength: 1
          maxLength: 80
    PayoutAccountInput:
      type: object
      description: >
        Partner keys only, on creation only. The account incaseof.law pays the
        provider's share to. The IBAN is checked

        (ISO 13616 check digits). It cannot be changed through the API
        afterwards — contact incaseof.law.
      required:
        - iban
      properties:
        iban:
          type: string
          example: DE89370400440532013000
        bic:
          type: string
          example: COBADEFFXXX
        bank_name:
          type: string
          maxLength: 255
    Customer:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
          description: The customer's organisation (where its claims live)
        partner_id:
          type: string
          format: uuid
          nullable: true
        name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
          nullable: true
        address:
          type: object
          nullable: true
          additionalProperties: true
        metadata:
          type: object
          nullable: true
          additionalProperties: true
        uid:
          type: string
          nullable: true
          description: EU VAT ID, normalised
        partner_client_reference:
          type: string
          nullable: true
          description: The partner's own ID for this business
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        partner:
          type: object
          nullable: true
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
  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.
    Forbidden:
      description: >-
        The key may not do this — for example a `customer_id` of another
        partner.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                example: Forbidden
              message:
                type: string
                example: This customer does not belong to your partner account.
    Conflict:
      description: >-
        The request conflicts with existing data (see `message`); nothing was
        changed.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              message:
                type: string
    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.