> ## Documentation Index
> Fetch the complete documentation index at: https://api-doc.fidly.be/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> One envelope for every error, with a machine-readable code, grouped by resource.

Every error uses the same envelope, in English:

```json theme={null}
{
  "error": {
    "code": "invalid_filter",
    "message": "Invalid type 'x'. Allowed: [...]"
  }
}
```

`code` is stable and snake\_case — branch on it, not on the message. `message` is
human-readable and safe to log. No stack trace is ever returned.

## General

<ResponseField name="validation_error" type="422">
  Body or parameter failing schema validation; message is `field: reason`.
</ResponseField>

<ResponseField name="invalid_filter" type="400">
  Unknown value in a list filter (also unknown `language` on reference lists,
  unknown `format` on file download).
</ResponseField>

<ResponseField name="invalid_parameter" type="422">
  Query parameter that does not apply to the targeted resource (e.g.
  `?ignore_duplicate` on a contact).
</ResponseField>

<ResponseField name="field_not_editable" type="422">
  Read-only field in a `PATCH` — `bic`/`reference` of a non-manual bank account,
  `code`/`category`/`sequence_scope` of a journal, `type`/`journal_id` of a
  document — or a field that does not exist for the relation's type.
</ResponseField>

<ResponseField name="not_found" type="404">
  Unknown route or unknown UUID (including a UUID of another company).
</ResponseField>

<ResponseField name="internal_error" type="500">
  Unexpected server error, logged on our side. Retry later; if it persists, contact
  support with the `X-Request-ID` from the response header — it lets us pull that
  request's trace straight away and speeds up handling (see
  [Conventions](/en/conventions#tracing-a-request)).
</ResponseField>

## Authentication

<ResponseField name="invalid_request" type="400">
  Missing credential field on `/auth/token`.
</ResponseField>

<ResponseField name="invalid_credentials" type="401">
  Unknown `client_id` or wrong `client_secret`.
</ResponseField>

<ResponseField name="invalid_grant" type="401">
  Unknown, already-used or revoked `refresh_token`.
</ResponseField>

<ResponseField name="client_inactive" type="401">
  The client has been deactivated.
</ResponseField>

<ResponseField name="invalid_token" type="401">
  Missing, malformed or expired `access_token`.
</ResponseField>

<ResponseField name="insufficient_permissions" type="403">
  The `access_token` lacks the required permission.
</ResponseField>

<ResponseField name="too_many_requests" type="429">
  Too many failed authentications on this `client_id`.
</ResponseField>

## Documents

<ResponseField name="invalid_relation" type="422">
  `relation_id` unknown, belonging to another company, or with no address.
</ResponseField>

<ResponseField name="invalid_journal" type="422">
  Journal unknown, inactive, of another company, or of the wrong category for the
  document type.
</ResponseField>

<ResponseField name="no_default_journal" type="422">
  No `journal_id` given and the company has no default journal for the category.
</ResponseField>

<ResponseField name="invalid_delivery_location" type="422">
  Delivery location unknown or belonging to another relation than the document's.
</ResponseField>

<ResponseField name="invalid_amount" type="422">
  Document total negative.
</ResponseField>

<ResponseField name="invalid_paid_amount" type="422">
  Declared `paid_amount` above the document total.
</ResponseField>

<ResponseField name="invalid_allowance_charge" type="422">
  Document-level discount/charge on lines totalling 0, or a VAT rate whose lines
  total a negative amount.
</ResponseField>

<ResponseField name="invalid_issue_date" type="422">
  Date outside the bracket of the neighbouring numbered documents, or outside the
  numbering window.
</ResponseField>

<ResponseField name="invalid_document_lines" type="422">
  Stored lines that cannot be reused for a recompute — send the full `lines` array
  instead.
</ResponseField>

<ResponseField name="self_billing_disabled" type="422">
  Creating a purchase document while self-billing is not enabled for the company.
</ResponseField>

<ResponseField name="not_sendable" type="422">
  Sending a document type Peppol does not transport (e.g. a proforma). As a `409`:
  sending a **received** document.
</ResponseField>

<ResponseField name="send_failed" type="422">
  The send workflow could not be started. With `?send_peppol=true` the document
  **was** created — the message gives its id; recover with
  `POST /documents/{id}/send`, never a second creation.
</ResponseField>

<ResponseField name="already_sent" type="409">
  Peppol send on a document already sent — only a failed send (`peppol_status`
  `failed` or `rejected`) can be retried.
</ResponseField>

<ResponseField name="duplicate_attachment" type="409">
  Attachment filename already present on the document.
</ResponseField>

<ResponseField name="document_not_editable" type="409">
  `PATCH` on a document already sent to the customer, already transmitted to
  accounting, or received.
</ResponseField>

<ResponseField name="document_not_deletable" type="409">
  `DELETE` on a document that is not the last of its sequence, already sent,
  transmitted, or received.
</ResponseField>

<ResponseField name="document_in_use" type="409">
  `DELETE` on a document linked to a reconciliation, an invoiced timesheet line or
  a payment intent.
</ResponseField>

Import and attachments also return plain HTTP statuses: `413` (file too big) and
`415` (extension not allowed).

## Relations

<ResponseField name="duplicate_relation" type="409">
  Company whose `vat`, `identifier` or `electronic_address` already exists —
  bypass with `?ignore_duplicate=true`; the message gives the existing id.
</ResponseField>

<ResponseField name="invalid_address" type="422">
  Address without `country_code`, or `street_number` without `street`.
</ResponseField>

<ResponseField name="relation_in_use" type="409">
  `DELETE` on a relation still referenced (document, subscription, project,
  timesheet line, accounting match...). The message says what blocks.
</ResponseField>

## Delivery locations

<ResponseField name="invalid_address" type="422">
  Address without `country_code`, or `street_number` without `street` — the same
  rules as a relation's address.
</ResponseField>

<ResponseField name="invalid_identifier" type="422">
  `identifier` / `identifier_scheme` pair half-filled.
</ResponseField>

<ResponseField name="invalid_delivery_location" type="422">
  On a document: location unknown or belonging to another relation than the
  document's.
</ResponseField>

<ResponseField name="delivery_location_in_use" type="409">
  `DELETE` on a delivery location a document is delivered to.
</ResponseField>

## Bank accounts

<ResponseField name="duplicate_bank_account" type="409">
  Account with the same `reference` (IBAN) already exists.
</ResponseField>

<ResponseField name="default_account_required" type="422">
  Demoting the default bank account without promoting another.
</ResponseField>

## Journals

<ResponseField name="duplicate_journal_code" type="409">
  Journal `code` already used in the company.
</ResponseField>

<ResponseField name="default_journal_required" type="422">
  Default journal created or left inactive, or demoting the last default of a
  category.
</ResponseField>

<ResponseField name="invalid_bank_account" type="422">
  `bank_account_id` matching no account of the company.
</ResponseField>

## Brandings

<ResponseField name="default_branding_required" type="422">
  Demoting the default branding — promote another instead.
</ResponseField>
