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

# Invoices (sales / purchase entries)

### Definition

In the Accounting API, a **sales entry** is a customer invoice and a **purchase entry** is a supplier invoice recorded in the accounting system.
If the accounting software supports invoices, Chift creates a native invoice object. Otherwise, Chift posts the equivalent journal entries. The accounting result is the same.

> [!NOTE]
>
> "Invoice" also exists in the [Invoicing API](/unified-apis/invoicing/concepts/invoice) (a standalone billing document) and the [PMS API](/unified-apis/pms/concepts/invoice) (a guest bill). The Accounting API version abstracts the underlying journal entries.

### Purpose

* Book customer and supplier invoices with business fields, without building the journal entry lines yourself.
* Generate the receivable or payable line automatically from the partner.
* Get the same behavior across accounting software, whether or not they support invoices natively.

### Structure

Each invoice has:

* An **identifier** (`id`) and an **invoice number** (`invoice_number`). If you do not send a number on creation, the accounting software generates it. Use it for [idempotency](/unified-apis/guides/idempotency)
* A **type** (`invoice_type`):
  * `customer_invoice`, `customer_refund`: sales invoice and credit note
  * `supplier_invoice`, `supplier_refund`: purchase invoice and credit note
* A **status** (`status`): `draft`, `posted`, `paid` or `cancelled`. On creation, only `draft` or `posted`. The default is `posted`
* An **approval status** (`approval_status`): `pending`, `approved`, `rejected` or `unknown` (the status could not be determined)
* **Dates**: the accounting date (`invoice_date`), the due date (`due_date`, and `due_dates` for all due dates) and the delivery date (`delivery_date`). On creation only: the period covered (`start_date`, `end_date`) for accruals and deferrals
* A **partner** (`partner_id`) and a **journal** (`journal_id`)
* A **currency** (`currency`) and, on creation, an **exchange rate** (`currency_exchange_rate`). The rate is required when the currency differs from the folder currency
* **Amounts**: `untaxed_amount`, `tax_amount` and `total` (`total` = `untaxed_amount` + `tax_amount`). See [Amounts validation](/unified-apis/accounting/concepts/invoice/amounts-validation)
* **References**: `reference` (for a purchase invoice, often the supplier's invoice number), `payment_communication` (payment reference, used for reconciliation) and `customer_memo`
* A **payment term** (`payment_term_id`) and a **payment method** (`payment_method_id`)
* An optional **withholding tax** (`withholding_tax`), mainly used in Spain
* An **attachment status** (`attachments_info`): `yes`, `yes_to_request`, `no` or `unknown`. On creation, send a PDF with `pdf` and `pdf_name`
* On read only: the **last update** (`last_updated_on`), the **payments** (`payments`) and the **partner details** (`partner`)
* **Lines** (`lines`). Each line has:
  * A **ledger account** (`account_number`): a general account (income or expense). See [Accounts in invoices](/unified-apis/accounting/concepts/invoice/accounts)
  * A **VAT code** (`tax_code`) and a **tax rate** (`tax_rate`)
  * **Amounts**: `unit_price`, `quantity`, `untaxed_amount`, `tax_amount` and `total`
  * A **description** (`description`)
  * An optional **analytic account** (`analytic_account`)

### Relationships

* Each invoice is linked to a [partner](/unified-apis/accounting/concepts/partner) (`partner_id`): a client for sales, a supplier for purchases. Chift books the receivable or payable line on the account of that partner. Some software cannot create partners by API. For these, send the partner with `partner_info`.
* Each invoice is recorded in a [journal](/unified-apis/accounting/concepts/journal) (`journal_id`). Use `journal_ids` to filter invoices. When you create an invoice without `journal_id`, Chift selects the journal automatically only if there is exactly one. Otherwise, it returns an error.
* Each line references a [ledger account](/unified-apis/accounting/concepts/ledger-account) (`account_number`) and a [VAT code](/unified-apis/accounting/concepts/vat-codes) (`tax_code`).
* An invoice generates [journal entries](/unified-apis/accounting/concepts/journal-entry) in the accounting software.
* Open invoices appear in [outstanding items](/unified-apis/accounting/concepts/outstanding). Use [Match entries](/api-reference/endpoints/accounting/match-entries) to match an invoice with financial entries or journal entries of the same partner.
* Lines can carry [analytic accounts](/unified-apis/accounting/concepts/analytical-accounting/analytic-account): `analytic_account` for the default plan, `analytic_distribution` for multiple plans.
* When `attachments_info` is `yes_to_request`, get the documents from the [attachments](/unified-apis/accounting/concepts/attachments) endpoint with `type=invoice`.
* When you list invoices, use `updated_after` and `last_updated_on` for [incremental synchronization](/unified-apis/guides/incremental-synchronization). Use `payment_status` (`all`, `paid`, `unpaid`) and `approval_status` to filter. Lines, payments and partner details are returned only with `include_invoice_lines`, `include_payments` and `include_partner_info` when the software needs extra requests.

### API endpoints

* [Get invoices by type](/api-reference/endpoints/accounting/get-invoices-by-type-salepurchase-entries): list the invoices of one type, with the analytic accounts of the default analytic plan.
* [Get invoices by type (multiple analytic plans)](/api-reference/endpoints/accounting/get-invoices-by-type-salepurchase-entries--multiple-analytic-plans): list the invoices of one type, with the analytic accounts of all analytic plans.
* [Get one invoice](/api-reference/endpoints/accounting/get-one-invoice-salepurchase-entry): get one invoice by its ID.
* [Get one invoice (multiple analytic plans)](/api-reference/endpoints/accounting/get-one-invoice-salepurchase-entry--multiple-analytic-plans): get one invoice by its ID, with the analytic accounts of all analytic plans.
* [Get payment terms](/api-reference/endpoints/accounting/get-payment-terms): list the payment terms.
* [Get payment methods](/api-reference/endpoints/accounting/get-payment-methods): list the payment methods.
* [Create sale/purchase entry](/api-reference/endpoints/accounting/create-salepurchase-entry): create an invoice.
* [Create sale/purchase entry (multiple plans)](/api-reference/endpoints/accounting/create-salepurchase-entry-multiple-plans): create an invoice with analytic accounts in several analytic plans.
* [Create an invoice payment](/api-reference/endpoints/accounting/create-an-invoice-payment): record a payment on an invoice.

Not every accounting software supports every invoice endpoint. Payment terms, payment methods and invoice payments have limited support. Check the [coverage matrix](/connectors/accounting/coverage).


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