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

# Invoice

> Recommended flow for creating invoices, and how files, payments, and sent_at behave.

## Creating invoices

<Steps>
  <Step title="Create contacts">
    Create contacts on [postV1Contacts](/api-reference/contacts/create-or-update-administration-contacts).
  </Step>

  <Step title="Create debtors">
    Create debtors on [postV1Debtors](/api-reference/debtors/create-or-update-administration-debtors).
  </Step>

  <Step title="Upload files">
    Upload invoice documents before creating invoices. See [file](/models/file) for details.

    * To unassign a file, provide `destroy: true` on the file parameter.
    * If `destroy: true` is combined with `checksum`, only the file matching that checksum is removed.
  </Step>

  <Step title="Create invoices">
    Create invoices on [postV1Invoices](/api-reference/invoices/upsert-invoices-in-bulk).

    **Payments**

    If payments are provided, all payments for the invoice must be included and ordered chronologically (oldest first). If `open_amount` changes but no payments are provided, Payt creates a payment matching the change in amount.

    **Sent at**

    The `sent_at` field sets the date when the invoice was sent to the debtor. If not provided, Payt sends the invoice to the debtor. This field can only be set if the invoice has not yet been published to the debtor.
  </Step>
</Steps>
