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

# Add document

> Attach a document to a case or to a creditor. Upload the file first with `POST /v1/{tenantId}/files` and pass the object it returns as `file` — the upload calls the identifier `id`, and it goes in here as `fileId`.

`type` decides what the document means in the collection process: the types other than `OTHER` are what give a debt a legal foundation and decide when it expires.

`minAccessRole` decides who can see it — `debtor` shows it in the debtor self-service portal, `client` to the creditor, `caseworker` only inside the platform.

**Required scope:** `write:documents`



## OpenAPI

````yaml POST /v1/{tenantId}/documents
openapi: 3.1.0
info:
  title: Debbie API Docs
  description: >
    The Debbie API is a RESTful interface, allowing you to programmatically

    update, add and access your data in the platform. It provides predictable
    URLs

    for accessing resources, and uses built-in HTTP features to receive commands
    and

    return responses. This makes it easy to communicate with third party
    systems.


    ## Idempotency


    The Debbie API supports idempotency for non-idempotent requests through the
    optional `Idempotency-Key` header. 

    This ensures that retrying the same request multiple times will produce the
    same result, preventing duplicate operations.


    ### Using Idempotency Keys


    - Include an `Idempotency-Key` header with a unique string (we recommend
    UUIDs)  

    - Maximum key length is 64 characters

    - Keys are valid for 48 hours

    - Responses served from the idempotency cache include an
    `Idempotency-Cached` header


    ### Example

    ```http

    Idempotency-Key: 123e4567-e89b-12d3-a456-426614174000

    ```


    ### Error Cases

    - Invalid key format: 400 Bad Request

    - Reusing a key for a different request: 400 Bad Request


    ### Best Practices

    - Use a new key for each unique business transaction

    - Use the same key when retrying a failed request 

    - Store keys with request details for debugging
  contact:
    email: api-support@debbie.dk
  version: v0.1.0
servers:
  - url: https://api.debbiecollect.com
security:
  - bearerAuth: []
tags:
  - name: Authorization
    description: Endpoints for interacting with authorization
  - name: Cases
    description: Endpoints for interacting with cases
  - name: Customers
    description: Endpoints for interacting with customers
  - name: Creditors
    description: Endpoints for interacting with creditors
  - name: Ultimate creditors
    description: >-
      Endpoints for interacting with ultimate creditors. An ultimate creditor is
      the original creditor behind the creditor on a case — for example when a
      debt collection agency forwards cases on behalf of its own client. On
      cases with an ultimate creditor, the creditor template mentions (name,
      address and company identifier) use the details of the ultimate creditor.
  - name: Updates
    description: Endpoints for interacting with updates
  - name: Users
    description: Endpoints for interacting with updates
  - name: Files
    description: Endpoints for interacting with files
  - name: Case vouchers
    description: Endpoints for interacting with case vouchers
  - name: Voucher types
    description: The voucher types of the tenant, used to categorize case vouchers
  - name: Interactions
    description: >-
      Interactions are messages and notes on a case, for example an incoming
      message from a debtor.
  - name: Billing
    description: Endpoints for interacting with billing
  - name: Transaction accounts
    description: >-
      Endpoints for interacting with transaction accounts — the bank and payment
      service provider accounts that payments are registered on
  - name: Links
    description: Endpoints for generating links
  - name: Webhooks
    description: >-
      Debbie provides a range of webhooks. To try them out please visit Debbie
      Caseworker and navigate to Settings --> Developers --> Webhooks.
  - name: End reasons
    description: Endpoints for interacting with end reasons
  - name: Case groups
    description: Endpoints for interacting with case groups
  - name: Documents
    description: Endpoints for attaching documentation to a case or to a creditor
  - name: Direct payments
    description: Endpoints for registering payments made directly to the creditor
externalDocs:
  description: Find out more about Debbie here
  url: https://debbiecollect.com
paths:
  /v1/{tenantId}/documents:
    post:
      tags:
        - Documents
      summary: Add document
      description: >-
        Attach a document to a case or to a creditor. Upload the file first with
        `POST /v1/{tenantId}/files` and pass the object it returns as `file` —
        the upload calls the identifier `id`, and it goes in here as `fileId`.


        `type` decides what the document means in the collection process: the
        types other than `OTHER` are what give a debt a legal foundation and
        decide when it expires.


        `minAccessRole` decides who can see it — `debtor` shows it in the debtor
        self-service portal, `client` to the creditor, `caseworker` only inside
        the platform.


        **Required scope:** `write:documents`
      operationId: create-document
      parameters:
        - in: path
          name: tenantId
          schema:
            type: string
            format: uuid
          required: true
          description: Id of the tenant
      requestBody:
        description: New document
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewDocument'
            example:
              entityId: 3f1c2d4e-5a6b-7c8d-9e0f-1a2b3c4d5e6f
              entityType: case
              type: OTHER
              minAccessRole: debtor
              file:
                fileId: 8d9f0c1e-2b3a-4c5d-6e7f-8a9b0c1d2e3f
                fileName: invoice-D12412347.pdf
                contentType: application/pdf
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '422':
          $ref: '#/components/responses/UnprocessableContent'
components:
  schemas:
    NewDocument:
      type: object
      properties:
        entityId:
          type: string
          format: uuid
          description: Id of the case or the creditor the document belongs to.
        entityType:
          $ref: '#/components/schemas/DocumentEntityType'
        type:
          $ref: '#/components/schemas/DocumentType'
        file:
          $ref: '#/components/schemas/File'
          description: >-
            The uploaded file, as returned by the file endpoint. Only fileId is
            read: the name and content type are taken from the stored file, so
            they always agree with it.
        minAccessRole:
          type: string
          enum:
            - debtor
            - client
            - caseworker
          description: >-
            The least privileged role that may see the document. `debtor` shows
            it to the debtor in the self-service portal, `client` to the
            creditor, `caseworker` only to the collector. Defaults to the
            collector-only level.
        date:
          type: string
          description: >-
            The date of the document itself, which can differ from the date it
            was uploaded. Defaults to now.
        isSigned:
          type: boolean
          description: Whether the document is already signed.
        signedAt:
          type: string
          description: When the document was signed. Only used together with `isSigned`.
        meta:
          type: object
          description: Extra information about the document.
          properties:
            note:
              type: string
              description: A free-text note shown with the document.
            amount:
              type: integer
              description: Amount in the minor unit, used by document types that carry one.
      required:
        - entityId
        - entityType
        - type
    Document:
      type: object
      properties:
        documentId:
          type: string
          format: uuid
        id:
          type: integer
          description: Sequential id of the document
        tenantId:
          type: string
          format: uuid
        entityId:
          type: string
          format: uuid
        entityType:
          $ref: '#/components/schemas/DocumentEntityType'
        type:
          $ref: '#/components/schemas/DocumentType'
        file:
          $ref: '#/components/schemas/File'
        signedFile:
          $ref: '#/components/schemas/File'
          description: The signed version of the file, once the document has been signed.
        minAccessRole:
          type: string
        date:
          type: string
        signedAt:
          type:
            - string
            - 'null'
        createdAt:
          type: string
    DocumentEntityType:
      type: string
      enum:
        - case
        - creditor
      description: >-
        What the document is attached to. `case` hangs it on a collection case,
        `creditor` on the creditor itself.
    DocumentType:
      type: string
      enum:
        - OTHER
        - FOUNDATION
        - SKYLDERKLAERING
        - COURTOPGJORTOGFREMLAGT
        - DOM
        - PAATEGNING
        - FORLIG
        - COURT
        - GAELDSBREV
      description: >-
        What the document is. The types other than `OTHER` carry legal meaning
        in the collection process — they decide whether the debt has a
        foundation and when it expires — and are set by the collector, not by
        you.
    File:
      type: object
      properties:
        fileName:
          type: string
        contentType:
          type: string
        fileId:
          type: string
          format: uuid
      required:
        - fileName
        - contentType
        - fileId
  responses:
    UnauthorizedError:
      description: Access token missing or invalid
    UnprocessableContent:
      description: Unable to process the contained instructions.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Authentication can be done by using a bearer token in the Authorization
        header. This is done using the following format `Authorization: Bearer
        {token}`.

````