Skip to main content

Import existing invoices

Not all your invoices exist in Scribee: supplier invoices received outside the exchange networks, invoices issued by another application, historical records to bring over. POST /api/v1/workspaces/{workspace_id}/invoices/upload brings them into your workspace in a single call: you send the file, Scribee detects the format, reads the data, and creates a draft ready to enter the regulatory lifecycle. The write scope is required (Authentication).

This endpoint accepts two families of file, handled differently. A structured file - UBL or CII XML, or a PDF that embeds that XML (Factur-X) - is read during the call and the invoice is returned with a 201. A PDF with no recognised invoice XML and an image (jpg, jpeg, png, heic) go to AI-assisted extraction: the call answers 202 with no invoice, and the invoice is created in the background. That second case depends on the workspace's offer: offers that only allow structured deposits reject it with a 422.

What Scribee does for you​

  • Content-based format detection: the file is classified from its bytes and embedded XML - UBL 2.1, CII (EN16931), or Factur-X (PDF with embedded CII XML) - never from its extension or declared MIME type, which serve only as a fallback. Inside a PDF, the attachment carrying the XML is recognised by its name whatever text-string encoding was used to write it (UTF-16, UTF-8, PDFDocEncoding): whoever produces your Factur-X needs to meet no requirement beyond the standard itself. An ancillary XML file such as index.xml does not make the PDF structured: under a nonstandard name, the XML must have an Invoice, CreditNote, or CrossIndustryInvoice root. The search continues through the other attachments before classifying the PDF as plain. Standard invoice filenames retain priority and their content still undergoes structured validation, even when invalid.
  • Structured parsing: header, seller and buyer, lines, taxes, and payment means are read from the XML, with no mapping required on your side.
  • Allowances that state their direction twice: EN 16931 carries the direction of an allowance/charge group in the indicator alone (BT-91, cbc:ChargeIndicator in UBL, ram:ChargeIndicator in CII) and keeps the amount (BT-92, BT-136) non-negative. Some issuers state the direction twice, sending an allowance whose amount is negative. Scribee reads that amount as a magnitude and imports the invoice, rather than rejecting it over a double negation. A charge with a negative amount contradicts itself and is still rejected: it would lower what you invoice while its indicator says to raise it. The amount Scribee stores, and the one it puts back on the wire when it regenerates the file, is therefore always non-negative - a zero amount is still a valid amount and passes through the import unchanged.
  • The emitter's readable representation: when the structured file carries a PDF (BT-125-1 application/pdf) as a BG-24 attachment whose description (BT-123) reads LISIBLE, in any casing, that PDF becomes the invoice's visible layer instead of the one Scribee would render, and provided_pdf then reads true. AFNOR XP Z12-012 reserves that marker for the complete readable representation of the invoice. As a tolerance towards emitters that do not set it, a PDF whose file name is exactly lisible.pdf, in any casing, is recognised the same way; a name that merely contains it, such as facture_lisible.pdf, is not enough. When an attachment marked LISIBLE and an attachment named lisible.pdf are both present, the one marked LISIBLE wins. The PDF selected is not saved among the invoice's supporting documents. Outside those two cases, an attachment carrying any other description (RIB, BON_LIVRAISON, ...) stays a supporting document and never replaces the rendering. A readable representation Scribee cannot process - encrypted, corrupt, 50 MiB (52,428,800 bytes) or more - is ignored without failing the import: the invoice is created and falls back to the Scribee rendering.
  • Flow direction: Scribee compares your company's identifiers (SIREN, VAT number) to the parties in the file - your company as buyer gives a purchase invoice, as seller a sales invoice. With no match, the direction stays the one carried by the call's direction field, purchases by default. On a PDF or an image read by assisted extraction, a seller whose legal identifier as read names another company (a complete SIREN, SIRET or foreign register number that is not yours) is not your company, even when the VAT number read next to it is yours; an incomplete or unreadable identifier does not set it aside: extraction often copies the customer's VAT number next to the issuer's identifier, and the invoice does not become a sale for it.
  • Third-party matching: the seller and buyer are matched to your existing suppliers and customers (see below).
  • Legal registration kept, SIREN emitted: a UBL, CII or Factur-X file keeps the legal registration its issuer declares in it. A SIRET declared under 0009 stays stored, and read back in the response, under siret. The files Scribee then generates for the invoice - ubl, cii, and facturx or pdf when they do not return a deposited Factur-X - emit it instead as the SIREN of its first 9 digits, under 0002 (The parties' legal registration in the generated files).
  • Original file retained: the imported file is attached to the invoice as long as it is under 50 MiB (52,428,800 bytes) and is indeed a PDF or an XML. The MIME type your HTTP client declares on the file part does not have to be exact: an unrecognized type - application/octet-stream in particular - is replaced by the one derived from the already-analyzed content, and the file is retained anyway. If it is still refused (50 MiB or more, or content that is neither PDF nor XML), the call answers 201 and the invoice is created without its original file. upload_source reads api on every invoice this endpoint creates: the provenance is written in the same transaction as the invoice, and a refusal of that write cancels the import rather than letting it through. The API serves that file back in one case: for an invoice deposited as a Factur-X whose PDF carrier is retained, downloading it in the facturx and pdf formats returns the deposited bytes themselves (Formats and downloads). Everywhere else, downloads only return the formats Scribee produces (pdf, ubl, cii, facturx).
  • Attachments embedded in the Factur-X PDF: complementary files embedded in the PDF are saved as invoice supporting documents, subject to the accepted file formats. The XML used to read the invoice is excluded. These documents have kind: other and attachable_to_invoice: false. The original PDF stays unchanged. Extraction allows at most 100 embedded files and less than 50 MiB (52,428,800 bytes) of decoded data in total, including the XML. A refused file or a reached limit produces an import warning. A manual upload still requires a file under 10 MiB (10,485,760 bytes).

The path of an imported file​

Import a structured file​

This call creates a draft invoice in your workspace; it transmits nothing to the PPF (Portail Public de Facturation), the Peppol network, or any recipient. The draft stays as is until you trigger a lifecycle transition. It remains deletable through DELETE /api/v1/invoices/{id} while it is a draft: the original number of an invoice imported by file, even a final one, does not block deletion, which only the other conditions described in Reverting to draft can refuse. A correction goes through updating the draft (PATCH /api/v1/invoices/{id}, API reference).

Send the file as multipart/form-data, field file:

curl -X POST https://app.scribee.tech/api/v1/workspaces/YOUR_WORKSPACE_ID/invoices/upload \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "file=@facture-fournisseur.xml" \
-F "company_id=317" \
-F "direction=purchases"

file must be a file part of the multipart body (-F "file=@..." with curl). Any other form is rejected with 422 before anything is read or created - see 422: file sent as something other than a file.

Three optional fields go alongside file:

  • company_id: the workspace company that receives the invoice. Without it, the first active company of the workspace is used, never an archived one - in a multi-company workspace, this is the only way to choose which one. An unknown identifier returns 404.
  • direction: sales or purchases, purchases by default. On this file-upload endpoint the value is not validated: it is overwritten when the parties in the structured file identify your company, and the import then succeeds normally even if you sent nonsense. When the parties do not identify it, the value you sent is kept as is and the import fails further down, with no message pointing at direction. Send only sales or purchases. (JSON creation via POST /api/v1/workspaces/{workspace_id}/invoices does validate this field and answers 422.)
  • lifecycle_state: triggers a lifecycle transition on the invoice in the same call, instead of a separate PATCH /api/v1/invoices/{id}/transition. Accepted values: draft (default, no transition), deposited (deposit, on a sales invoice) or available (made available, on a purchase invoice) - any other value is rejected with 422. On a file that goes to AI extraction, only draft passes without rejection: deposited, available, and any out-of-list value are rejected (see below).

A structured file (UBL, CII, Factur-X) is processed during the call and the created invoice is returned (status 201). Response trimmed to the fields useful here:

{
"data": {
"id": 12456,
"invoice_number": "FAC-2026-0183",
"issue_date": "2026-07-10",
"type_code": "invoice",
"currency_code": "EUR",
"direction": "purchases",
"tax_inclusive_amount": 1770.0,
"lifecycle_state": "draft",
"lifecycle_status_code": "000",
"lifecycle_available_transitions": ["make_available"],
"source_format": "ubl",
"upload_source": "api"
},
"meta": {
"trashed": false,
"duplicate_of_id": null,
"warnings": []
}
}

source_format is ubl, cii, facturx or api: for a received document it carries the carrier, not the syntax it embeds. api is the odd one out: it marks an invoice created through the API with no structured file deposited, so there is no carrier to describe. A Factur-X PDF is returned as facturx. A CII XML stays cii even when it carries a Factur-X guideline, because it is an XML and not a PDF/A-3.

:::warning Behaviour change Until now a Factur-X PDF was returned as cii and the value facturx never appeared. If your integration tests source_format == "cii" to recognise a Factur-X deposit, it must now accept facturx. :::

lifecycle_available_transitions lists the transitions you can trigger: make_available on a purchase invoice (status 203, made available), deposit on a sales invoice (status 200, deposited). The details of the states and codes are in The invoice lifecycle.

The meta block of the 201 response​

Next to data, the 201 response always carries a meta object with three keys:

  • trashed: true when the file, deposited as a purchase, repeats a purchase invoice already present and the copy was moved to the trash (A purchase invoice already imported answers 201, then goes to the trash). data then describes an invoice that GET /api/v1/invoices/{id} no longer finds (404), and no invoice.created event is emitted for it.
  • duplicate_of_id: the identifier of the invoice already present of which the file is a copy - received with the same file, or from the same supplier with the same number and the same amount including VAT -, whether the copy was moved to the trash or kept; null when the file copies none.
  • warnings: the warnings the import left on the invoice, in the order they were recorded, each with a code and a plain-language message; an empty array when there is none. trashed_duplicate comes with a copy moved to the trash; duplicate_supplier_invoice signals, on a kept invoice, an invoice already received with the same file, or another invoice from the same supplier that already carries this number; unmatched_party signals a counterparty none of your third parties matched (Third-party matching).

The same file deposited a second time, abridged response:

{
"data": {
"id": 12457,
"invoice_number": "FAC-2026-0183",
"direction": "purchases"
},
"meta": {
"trashed": true,
"duplicate_of_id": 12456,
"warnings": [
{
"code": "trashed_duplicate",
"message": "Ce fichier a déjà été reçu comme document n°12456 : il a été mis à la poubelle. Ouvrez la poubelle pour le restaurer si c'est une erreur."
}
]
}
}

These warnings can only be read in this response: no other API read exposes them. The 202 response to an unstructured file carries no meta.

lifecycle_state: the real cause of a rejection is in details.file, not in message​

Passing lifecycle_state triggers the requested transition in the same call as the import, under the same rules as the dedicated transition endpoint (PATCH /api/v1/invoices/{id}/transition, The invoice lifecycle). It is all or nothing: if the transition is refused, nothing is created, including the invoice itself.

Three rejection causes all return the same 422 envelope as the other file-processing failures: message stays the generic Échec du traitement du fichier de facture, and details.file[0] is what carries the real cause. A partner that logs only message sees nothing actionable. The third, specific to deposited: this transition can only be triggered manually on a sales invoice, and direction defaults to purchases on this endpoint (see above) - if the file does not flip the direction to sales, the transition is refused with details.file[0]: La transition deposit ne peut pas être déclenchée manuellement., a message that does not mention direction. A deposit refused by the Schematron check is the exception to this shape when it names fields: details is then keyed by field path rather than by file (see below).

Requesting deposited or available on a file that goes to AI extraction (a PDF with no recognised invoice XML, an image) is rejected - draft is still accepted (see above):

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["lifecycle_state ne peut être demandé que pour une facture électronique structurée (Factur-X, UBL, CII). Ce fichier nécessite une extraction assistée : rien n'a été créé. Déposez-le sans lifecycle_state, puis utilisez l'endpoint de transition."]
}
}

A value outside draft, deposited, or available:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Valeur lifecycle_state invalide à la création : 'approved'. Valeurs autorisées : draft, deposited, available"]
}
}

When the company is declared as part of the 1 September 2026 issuing wave, depositing a sales invoice imported with lifecycle_state: "deposited" requires, as through the transition endpoint, a mandate of the company that authorises the emission of its invoices on the day of the deposit (422 at deposit: no mandate authorises emission). A self-billed sales invoice you receive from your customer is not concerned. Without that mandate, the call is refused and nothing is created:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Aucun mandat en vigueur aujourd'hui n'autorise l'émission des factures de cette société. Il faut un accord formel désignant la Plateforme Agréée, ou une délégation couvrant l'émission des factures, signé et en vigueur à la date du dépôt : faites signer ou renouveler ce mandat, puis déposez de nouveau la facture. Rien n'a été déposé."]
}
}

An unstructured file answers 202, not 201​

A PDF with no recognised invoice XML and an image are accepted when the workspace's offer allows unstructured deposits (otherwise, 422: see below). The file then goes to AI-assisted extraction, in the background. The response is not the invoice, and its body has nothing in common with the 201 one:

{
"data": {
"status": "processing",
"upload_file_id": 4821
}
}

No invoice exists yet at that point. It is created later, once the extraction succeeds, and that is when the invoice.created event goes out to your webhook endpoints. No API endpoint lets you follow upload_file_id: wait for the webhook, or re-read the workspace's invoice list. The extraction can also fail, in which case no invoice is created and no event is emitted.

A French VAT number read on the document with the five digits of an establishment NIC glued after it - the SIRET printed next to it, read as one value - is stored without that suffix in the party's vat_identifier, when the number's key proves the remaining nine digits are the SIREN. Any other value is stored as read.

Finally, the extraction can succeed without producing a visible invoice. When automatic document sorting is enabled for the workspace, a file the extraction recognises as something other than an invoice to pay is filed outside your invoices: a delivery note, a quote, a purchase order, a bank statement, a shipping or customs document - including an invoice that carries the statement for customs purposes only, no commercial value or billing invoice will be sent separately -, and an invoice whose read number appears nowhere in the document's text. That document appears neither in GET /api/v1/workspaces/{workspace_id}/invoices nor through GET /api/v1/invoices/{id}, and no invoice.created event is emitted. If it is restored from the Scribee interface, it becomes a visible invoice and invoice.created goes out at that moment; set aside for a number not found, it comes back with a provisional DRAFT- number to replace by PATCH before the deposit.

An invoice created by the extraction whose issue date is absent or unreadable carries today's date in its place and a blocking import error: deposit and make_available disappear from lifecycle_available_transitions until a PATCH /api/v1/invoices/{id} carrying the issue date (see Import errors are not HTTP errors).

So handle the two statuses separately: a 201 carries the invoice, a 202 only an acknowledgement.

:::warning Behaviour change A conformant Factur-X PDF whose XML attachment name is written in UTF-16 was not recognised as structured: it went to assisted extraction and answered 202, or was rejected with a 422 on an offer reserved for structured deposits. Those files are now read during the call and the invoice is returned with a 201. If your integration expects a 202 for such uploads, it must accept a 201 carrying the invoice. :::

Third-party matching​

The seller of a purchase invoice is compared to your suppliers, the buyer of a sales invoice to your customers, in this order - the first conclusive criterion wins:

  1. Legal identifier and its scheme (SIREN, SIRET) - the most precise criterion.
  2. SIREN cross-matching: a SIRET from the file is matched to the corresponding SIREN and vice versa, including via a French VAT number.
  3. Intra-community VAT number. A file party with no VAT number but carrying a foreign legal identifier is looked up by that identifier among your third parties' VAT numbers.
  4. Exact name (case-insensitive), compared to the third party's name and trading name.

A supplier that the company's SAP Business One synchronisation reports as frozen is never a candidate, whatever the criterion, even though it stays listed among your suppliers.

Every criterion stands down when two or more third parties match: it does not match rather than match incorrectly, and the next criterion is tried. Keep your identifiers unique in your directory.

When none of these criteria concludes and AI matching is enabled for the company (a Scribee interface setting, on by default), Scribee submits the file party to an AI model, which picks among your suppliers or customers. The name of a purchase invoice's seller written at least half in Chinese, Japanese or Korean characters is first transliterated, then compared again by exact name, when AI matching is enabled. The model's pick is kept only if it designates one of your third parties with sufficient confidence, stays close to the name read on the invoice and does not contradict the SIREN the file carries; otherwise the party stays unmatched. This matching covers the invoice's counterparty and runs in the background, after the response, unless the call requests lifecycle_state deposited or available: it then happens during the call, before the transition.

The result is readable on the invoice: seller.party_id and buyer.party_id carry the identifier of the matched supplier or customer, and are null when no matching happened. An AI match made in the background does not appear in the 201 response: read the invoice again with GET /api/v1/invoices/{id}. An unmatched third party blocks nothing. It leaves an unmatched_party warning in meta.warnings of the 201 response, whose message names the seller or the buyer, except when AI matching continues in the background after the response: the response then carries none. The matching then happens from the Scribee interface, or after an accounting synchronisation (see below).

The seller of a purchase invoice can also be matched later, in the background, when purchase order management is enabled for the company. While the invoice is in draft or available, if the purchase orders the invoice cites - through its purchase_order_reference, through the order_line_reference of its lines, or through its number carried on a goods receipt - all belong to a single supplier, that supplier becomes its seller and seller.party_id takes its identifier. A seller matched by one of the four criteria above, or chosen by a user, is never replaced. A PATCH /api/v1/invoices/{id} that changes purchase_order_reference, a line's order_line_reference or invoice_number restarts this search.

A counterparty left unmatched is also searched for again, in the background, at the end of every completed synchronisation of the accounting software the company connected from the Scribee interface (ACD, Cegid Loop, Fulll, Pennylane or Sage GEC), when that synchronisation created or changed a supplier or customer that shares a legal identifier, a SIREN, a VAT number, a name or a trading name with the invoice's party. Only the four criteria above apply, across all your suppliers or customers and with the same stand-downs; no AI model is consulted. When one of them concludes, seller.party_id of a purchase invoice, or buyer.party_id of a sales invoice, takes the identifier of the third party found. A counterparty already matched is never replaced, and an invoice in the trash is not picked up. A sales invoice, other than a self-billed invoice received from your customer, and a purchase invoice your company self-bills in its supplier's name are picked up only while they are in draft. A single synchronisation picks up at most 2,000 invoices, those with the highest id. No webhook event announces this matching: read the invoice again with GET /api/v1/invoices/{id}.

Matching the seller of a purchase invoice, by one of the four criteria or by AI, at import as after an accounting synchronisation, can also change its category_id. A purchase invoice with no category takes the matched supplier's: the category of that supplier's rule whose invoice number prefix, the longest that matches, opens invoice_number regardless of case (rules defined in the Scribee interface), otherwise the supplier record's category_id. An archived category is not taken, and an invoice that already carries a category keeps it.

The deliver-to location identifier (BT-71)​

The deliver-to location identifier is only kept when its identification scheme (BT-71-1) travels with the value in the file - cac:DeliveryLocation/cbc:ID/@schemeID in UBL, ram:ShipToTradeParty/ram:GlobalID/@schemeID in CII. An identifier without a scheme is ignored, and both delivery.location_id and delivery.location_scheme_id are then null: rule BR-FR-CO-10_BT-71-1 makes the scheme mandatory as soon as the identifier is stated, so an unqualified identifier could never be re-issued. The deliver-to party name (BT-70) is unaffected and is still kept in delivery.location_name.

Order, despatch advice and delivery at line level​

Each line of an imported UBL or CII file keeps its purchase order number (EXT-FR-FE-135), its despatch advice (EXT-FR-FE-140, EXT-FR-FE-141 and EXT-FR-FE-201) and its delivery (EXT-FR-FE-BG-10), read from the locations described in Issue a sales invoice. Read them back with GET /api/v1/invoices/{id}?include=lines, in purchase_order_reference, despatch_advice and delivery on the line.

Two restrictions apply to the line's delivery:

  • the location identifier is only kept with its scheme, like the header's. In CII, where a line may state several, only the first ram:GlobalID carrying a schemeID is kept;
  • the address is only kept when it carries its country - ram:PostalTradeAddress/ram:CountryID in CII, cac:Address/cac:Country/cbc:IdentificationCode in UBL. Without a country, delivery.address is null. The location name is still kept in delivery.location_name.

References to earlier invoices​

A structured file's references to earlier invoices are kept with their type. At invoice level (BG-3), each invoice_references entry returns the number, date, and type of the referenced invoice (EXT-FR-FE-02), and document_id is null there. At line level (EXT-FR-FE-BG-06), for example the line of a final invoice that takes back a down payment, the number, date, type, and line of the referenced invoice come back in the line's invoice_reference object. The type is returned under its Scribee key, retainer_invoice for a retainer invoice (386); the list of keys is in Issue a sales invoice.

External identifiers (external_source, external_id)​

These two fields are silently ignored by the import endpoint: the call still answers 201 with no error, but the invoice does not carry them. Send them through the draft update (PATCH /api/v1/invoices/{id}, API reference) or at JSON creation (POST /api/v1/workspaces/{workspace_id}/invoices) to link the imported invoice to the matching record in your system - an ERP, for instance.

The two fields go together: sending one without the other fails with 422, on both creation and update.

{
"error": "unprocessable_entity",
"code": "external_reference_incomplete",
"message": "external_source et external_id doivent être fournis tous les deux, ou omis tous les deux",
"violations": []
}

external_id is unique per (company, external_source) and capped at 255 characters, same as external_source. external_source cannot take a value reserved for one of Scribee's own integrations: its accounting integrations (the SAP Business One import, among others) and the reception of invoices coming from Chorus Pro, which reserves the value chorus, as well as the SAB piece number entered in the Scribee application, which reserves the value sab. Sending one fails with 422, on both creation and update:

{
"error": "unprocessable_entity",
"code": "external_source_reserved",
"message": "'sap_business_one' est une valeur external_source réservée à l'une des intégrations de Scribee et ne peut pas être définie via l'API",
"violations": []
}

Once an invoice carries a reserved external_source - because it was imported by one of these integrations or a SAB piece number was entered on it - neither external_source nor external_id can be modified through the API anymore, even to other values:

{
"error": "unprocessable_entity",
"code": "external_reference_locked",
"message": "Cette référence externe est gérée par une intégration de Scribee ou par l'application Scribee : external_source et external_id ne peuvent pas être modifiés via l'API",
"violations": []
}

These three rejections do not have the shape of the file-processing errors above: the body carries no details key, only error, code, message and an empty violations array. code names each cause: external_reference_incomplete, external_source_reserved and external_reference_locked.

A pair already carried by another invoice of the company is refused by the generic validation envelope, with code validation_failed and the details.external_id key. Only a concurrent request that records the same pair at the same moment receives code duplicate_external_reference, with the message Une facture avec la référence externe '<external_source>' / '<external_id>' existe déjà pour cette entreprise.: the invoice number is not at fault, change the reference.

What happens next​

  • The invoice.created event is delivered to your webhook endpoints (Webhooks), except for a copy moved to the trash (see A purchase invoice already imported answers 201, then goes to the trash).
  • The invoice's download formats (pdf, ubl, cii, facturx) are generated, unless a blocking import error occurs: see Formats and downloads.
  • An EN16931 validation (Schematron rules) is started in the background on the XML. Neither its report nor its findings appear in the invoice payload; they only surface at deposit (see below).
  • Nothing goes out: transmission to the recipient and the regulatory lifecycle only begin at the transition you trigger.

Errors and edge cases​

Most file-processing failures return a 422 status in the same shape: error is unprocessable_entity, message is Échec du traitement du fichier de facture, and details.file carries the precise cause. violations restates each message of details.file as a source: "request" element whose field is file (API conventions). An unknown company_id falls outside that shape and returns 404. An invalid direction that inference did not correct produces two shapes, depending on what the file allows to be decided:

  • If the structured parties identify a company but not yours, the membership check fails first and you receive the file-processing envelope above, with the cause in details.file.
  • If that check cannot decide - no usable party identifier, for instance - the invalid value reaches persistence and you receive the generic validation envelope (message is La validation a échoué, details is keyed by field, here details.direction).

When the file carries structured parties that do identify your company, inference wins and the invalid value is replaced without an error - see above. The errors common to all endpoints (401, 403, 404) follow the format described in API conventions.

422: unreadable file or unknown format​

An XML file that is neither UBL nor CII and an invalid XML file are rejected:

{
"error": "unprocessable_entity",
"code": "invalid_xml_content",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Contenu XML invalide"]
},
"violations": [
{
"source": "request",
"field": "file",
"rule": null,
"type": null,
"severity": "error",
"message": "Contenu XML invalide",
"message_fr": null,
"message_en": null,
"xpath": null
}
]
}

Each cause has its code, and details.file its message: file_required (Un fichier est requis), file_read_error (Impossible de lire le fichier), unknown_file_format (Format de fichier non reconnu (XML, PDF ou image attendu)), malformed_pdf (Le fichier PDF est malformé : <détail>), xml_content_required (Le contenu XML est requis, for an empty XML file), invalid_xml_content (Contenu XML invalide) and unknown_xml_format (Format de facture inconnu : <identifiant>). Branch your handling on code, not on the text of details.file[0]. malformed_pdf is reserved for a PDF that no reader can open: a PDF that is technically malformed but still readable - a declared stream length that does not match the real bytes, a cross-reference table that cannot be found, an object of an unexpected type - is accepted and, carrying no recognised invoice XML, goes to AI extraction (202, see above) like any other PDF with no recognised invoice XML. file_read_error is no verdict on the file: replay the same call. For the other causes, fix the file or re-export it from the original software before replaying the call.

422: file sent as something other than a file​

Only a file part of the multipart body is accepted as file. A text value (a path, for example), a number, an object or a list is rejected, whether it arrives in a JSON or form body, in the query string, or as a text part of the multipart. Nothing is read or created:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["doit être une partie fichier téléversée, et non une valeur texte, un objet ou une liste"]
},
"violations": [
{
"source": "request",
"field": "file",
"rule": null,
"type": null,
"severity": "error",
"message": "doit être une partie fichier téléversée, et non une valeur texte, un objet ou une liste",
"message_fr": null,
"message_en": null,
"xpath": null
}
]
}

code is validation_failed and details.file carries that single message. A missing or empty file receives the response described above (Un fichier est requis). Attach the file as a file part, then replay the call.

422: file sent as something other than a file​

Only a file part of the multipart body is accepted as file. A text value (a path, for example), a number, an object or a list is rejected, whether it arrives in a JSON or form body, in the query string, or as a text part of the multipart. Nothing is read or created:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["doit être une partie fichier téléversée, et non une valeur texte, un objet ou une liste"]
},
"violations": [
{
"source": "request",
"field": "file",
"rule": null,
"type": null,
"severity": "error",
"message": "doit être une partie fichier téléversée, et non une valeur texte, un objet ou une liste",
"message_fr": null,
"message_en": null,
"xpath": null
}
]
}

code is validation_failed and details.file carries that single message. A missing or empty file receives the response described above (Un fichier est requis). Attach the file as a file part, then replay the call.

422: the offer only accepts electronic invoices​

A PDF with no recognised invoice XML and an image (jpg, jpeg, png, heic) normally go to AI extraction (202, see above). Some offers reserve the endpoint for structured invoices: the file is then rejected, and no invoice is created.

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Ce document n'a pas été transmis à votre cabinet : votre offre accepte uniquement les factures électroniques (Factur-X, UBL ou CII), pas les PDF simples ni les photos. Transmettez-le à votre cabinet par votre canal habituel. Fichier(s) refusé(s) : facture-scan.pdf"]
}
}

Deposit the file in Factur-X, UBL, or CII format.

422: your company is not a party to the invoice​

When the file carries identifiers and the target company appears in it as neither seller nor buyer:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["L'entreprise sélectionnée (843295671) n'apparaît ni comme vendeur (152836408) ni comme acheteur (503241636) dans ce fichier."]
}
}

Check the company_id you send - without it, the first active company of the workspace is used - and that this company's SIREN or VAT number matches one of the parties in the file. The company's legal_identifier counts as a SIREN only when its legal_registering_country is FR or blank. A file party's legal registration, when it is nine or fourteen bare digits, counts as a SIREN only under the siren (0002) or siret (0009) scheme, or for a party whose country belongs to the French VAT territory (FR, GP, MQ, RE); a French VAT number counts as the SIREN it carries. The check is skipped when your company carries neither a legal identifier nor a VAT number, and when any party named by the file carries none: a party given by name alone may well be your company, and refusing on that silence would reject a sound purchase - a foreign supplier whose buyer block carries no SIRET, for one. The refusal above therefore only applies when every party named by the file carries an identifier and none of them matches your company.

422: invoice number already imported​

The number of a sales invoice is unique per company. Replaying the import of the same sales file returns code duplicate_invoice_number:

{
"error": "unprocessable_entity",
"code": "duplicate_invoice_number",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Une facture avec le numéro 'FAC-2026-0183' existe déjà pour cette entreprise."]
},
"violations": [
{
"source": "request",
"field": "file",
"rule": null,
"type": null,
"severity": "error",
"message": "Une facture avec le numéro 'FAC-2026-0183' existe déjà pour cette entreprise.",
"message_fr": null,
"message_en": null,
"xpath": null
}
]
}

This refusal protects you from duplicates as long as the file carries a number. A file with no invoice number receives a randomly drawn placeholder number: replaying that import does create a second draft.

A purchase invoice already imported answers 201, then goes to the trash​

A structured file deposited as a purchase that repeats a purchase invoice already present in the company is not refused. Two rules recognise the copy, in this order:

  1. The same file: the file is identical, byte for byte, to the one a purchase invoice of the same company was received with, whatever the reading gave - another number, a placeholder number, another supplier -, credit notes and proformas included.
  2. Same supplier, same number, same amount including VAT in the same currency. The warning's message then names this rule: Ce fichier est une copie du document n°12456 déjà reçu (même fournisseur, même numéro, même montant) : il a été mis à la poubelle. Ouvrez la poubelle pour le restaurer si c'est une erreur.

An invoice received over the e-invoicing network (Peppol or an Approved Platform's flow) is never treated as the copy of a file: it is the original invoice. The API deposit of the same file is the copy, moved to the trash or flagged naming the invoice received over the network, with the message Ce fichier est la facture reçue par le réseau de facturation électronique comme document n°12456 : cette copie a été mise à la poubelle. Ouvrez la poubelle pour la restaurer si c'est une erreur. This holds even when your deposit arrived first: shortly after the network reception, a periodic check moves to the trash, as at deposit, the earlier deposit of the same file that is still draft or available and that nobody has modified, through the interface or the API. A deposit already worked on is kept by this check and carries the duplicate_supplier_invoice warning; a user can still move it to the trash (A kept copy can be moved to the trash from the interface). An invoice moved to the trash after the fact answers 404 on read, although its 201 carried meta.trashed at false.

In both cases, the call answers 201 with the invoice created, like any import. This new copy is immediately moved to the trash as a duplicate, and the response says so: meta.trashed is true and meta.duplicate_of_id names the invoice already present (The meta block of the 201 response). Afterwards, GET /api/v1/invoices/{id} on that identifier answers 404, the invoice does not appear in the list, and no invoice.created event is emitted. The invoice already present stays in place.

The number is compared ignoring case, spaces, punctuation and leading zeros: 0092-688798 and 92 688 798 are one number. The supplier is recognised by the third-party record linked to both invoices, failing that by the seller's VAT number and SIREN, that SIREN being read only on the conditions described above for the file's parties (siren or siret scheme, or a country of the French VAT territory) - failing that, the legal registration is compared whole, so two foreign suppliers whose registrations share their first nine digits remain distinct; the amount including VAT allows a 0.01 difference. The invoice already present must be a live purchase invoice: not in the trash, nor refused, rejected or cancelled - for both rules. Under the second rule, a credit note and an invoice with a placeholder number are never treated as duplicates, and a proforma invoice is compared with proformas only.

The copy is kept, and stays readable, when the call carries a lifecycle_state that moves the invoice through a transition, or depending on your workspace's configuration: meta.trashed is then false, meta.duplicate_of_id still names the invoice already present, and meta.warnings carries a duplicate_supplier_invoice warning. For a different file, the same supplier and number for another amount are not enough: both invoices are kept, meta.duplicate_of_id is null, and the same duplicate_supplier_invoice warning appears in meta.warnings.

A kept copy can be moved to the trash from the interface​

A kept copy - including an invoice you deposited through the API and already worked on - can later be moved to the trash by a user, from the Scribee interface, as a duplicate of the invoice already present. Only a received purchase invoice that arrived over no e-invoicing network is concerned, in one of the states available (203), taken_in_charge (204), approved (205), approved_partially (206), disputed (207) or suspended (208), with no recorded payment nor confirmed purchase match, and as long as the invoice it copies stays live. From that moment, GET /api/v1/invoices/{id} and the endpoints attached to the invoice answer 404, it disappears from the list, and its status no longer changes while it is in the trash. Restored from the interface, it comes back with the same identifier and the same lifecycle_state, with no new invoice.created event: it was already announced at its creation. Permanently deleted from the trash, it answers 404 for good.

422: line price or quantity out of precision​

A received line value is never rounded: it is stored as the file writes it, or the whole file is refused and no invoice is created. A UBL, CII or Factur-X file is refused as soon as one of its lines carries an invoiced quantity (BT-129) or a price base quantity (BT-149) with more than 4 decimals, a net price (BT-146) or a price discount (BT-147) with more than 6 decimals, or one of these values past 19 digits - a minus sign counts as one, the decimal point does not. Precision is judged on the value: trailing zeros in the decimal part do not count, so 1.1234560 is 1.123456 and passes.

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["La facture est refusée : une valeur reçue devrait être arrondie pour être enregistrée, et une valeur reçue n'est jamais arrondie (PAready 3.1, section 4.3.1.2). ligne 2, BT-146 \"1.1234567\" comporte plus de 6 décimales (BR-FR-DEC-03)"]
}
}

The message names each refused value, separated by ; , in the form ligne <identifier>, <term> "<value>" <reason> (<rule>): the identifier is the line's identifier in the file (BT-126), the rule is BR-FR-DEC-02 for a quantity and BR-FR-DEC-03 for a price. The message details at most 20 refused values, then counts the rest (et 3 autres valeurs refusées); a quoted value is truncated to 40 characters, a line identifier to 35. Fix the file in the originating software, then replay the import.

422: repeated line identifier on a sales invoice​

A UBL, CII or Factur-X file that creates a sales invoice is refused whole when two of its lines carry the same identifier (BT-126), and no invoice is created:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["La ligne '1' de la facture porte le même identifiant (BT-126) qu'une autre ligne. Chaque ligne doit avoir son propre identifiant ; corrigez la facture puis soumettez-la à nouveau."]
}
}

The identifier quoted is the line's identifier in the file. A sub-line names its group line by this identifier (EXT-FR-FE-162), which must therefore name a single line. A received purchases invoice is not subject to this check: the same file imported as a purchase is accepted. Fix the file in the originating software, then replay the import.

422 at deposit: number already used under the seller's SIREN​

An imported sales invoice keeps the number the file carries. At deposit, that number is reserved under the seller's SIREN for the year of the issue date (AIFE rule G1.45), like that of an invoice issued by Scribee (Issue a sales invoice). A number this SIREN already holds for that year on Scribee - through the sales invoice of another company carrying the same SIREN, whatever its workspace, or through a self-billed invoice issued in this seller's name - is refused. With lifecycle_state: "deposited", nothing is created:

{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Le numéro de facture FAC-2026-0183 ne peut pas être utilisé pour ce vendeur en 2026 : un numéro de facture doit être unique par vendeur et par année (règle AIFE G1.45)."]
}
}

An invoice imported as a draft then deposited with PATCH /api/v1/invoices/{id}/transition receives the same message in the transition endpoint's envelope, and stays a draft. The message says nothing about the invoice that holds the number.

422: your offer does not include sales invoicing​

A file where your company is the seller creates a sales invoice; some offers do not include it. details.file then contains: Votre offre n'inclut pas la facturation de vente. Contactez votre cabinet comptable pour mettre à niveau votre offre.

Import errors are not HTTP errors​

The import succeeds (status 201) even when a required field is missing: a missing invoice number, issue date, type, or currency receives a placeholder value and an import error is recorded on the invoice. The API does not expose those errors - only warnings, which block nothing, appear in meta.warnings of the 201 response; the observable signal is lifecycle_available_transitions, from which deposit and make_available disappear while a blocking error is present. Update the draft with the correct data (PATCH /api/v1/invoices/{id}): the update clears the import errors and the transition becomes available again. It also restarts generation of the four download formats in the background, without deleting the previous ones: until the regeneration replaces them, a download requested right after a PATCH returns the files from before the update. If the invoice carried a provided PDF, the update sets provided_pdf back to false, so regeneration starts from the Scribee rendering. The imported file itself is not touched by the update.

A country code outside ISO 3166-1 alpha-2 is not stored​

EN 16931 types the country code (BT-40, BT-55, BT-69) as ISO 3166-1 alpha-2: two letters, FR and not FRA. A value that is not one - an alpha-3, a country name, free text - is not stored: the field comes back null and the call succeeds, instead of the 422 you used to receive.

This is not a relaxation of the rule, it is a change of judge. The requirement is carried by the EN16931 findings BR-09 and BR-11, both fatal, which surface at deposit exactly as described just above, with the field path in details. The same rule used to be enforced at write time as well, where an unreadable country code failed the whole invoice rather than the single field; on AI-assisted imports the counterparty itself was then not recorded either.

Correct the value with PATCH /api/v1/invoices/{id} before depositing.

Schematron findings surface at deposit​

A finding from the EN16931 validation is not an import error: it does not remove deposit from lifecycle_available_transitions, where an import error does. The transition stays listed and callable, and the check applies at the moment you call it. So do not watch the transitions list for findings, handle the 422. The invoice stays in its original state.

Three distinct causes refuse that deposit, and the code field tells you which: schematron_fatal (a fatal assertion - fix the fields the response names, then deposit again; with the rule SCRIBEE-XML-02, the imported file is not well-formed XML, and the refusal is permanent: correct the file at the source rather than depositing again), schematron_engine_unavailable (no verdict could be produced - the invoice is not at fault, deposit it again later), and schematron_profile_unsupported (no rule set applies to this profile - depositing again changes nothing, send another profile). The three envelopes are detailed in The invoice lifecycle.

On the transition endpoint, schematron_fatal returns a top-level errors object together with code, with no error and no message. Requested as part of the import with lifecycle_state: "deposited", the same refusal keeps this endpoint's file-processing envelope, and details is what carries the offending fields, in place of its usual file key:

{
"error": "unprocessable_entity",
"code": "schematron_fatal",
"message": "Échec du traitement du fichier de facture",
"details": {
"document.lines[].price.unit_price": ["BR-27: [BR-27]-The Item net price (BT-146) shall NOT be negative."]
},
"violations": [
{
"source": "schematron",
"field": "document.lines[].price.unit_price",
"rule": "BR-27",
"type": null,
"severity": "fatal",
"message": "[BR-27]-The Item net price (BT-146) shall NOT be negative.",
"message_fr": null,
"message_en": null,
"xpath": "/*:Invoice[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'][1]/*:InvoiceLine[namespace-uri()='urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'][1]"
}
]
}

The keys of this details follow the same rules as those of errors on the transition endpoint: they are the API field names and not the BT codes, one assertion may be listed under several fields when the rule stands on a set of elements, and one that no single field carries on its own arrives under document._schematron. The detail is in The invoice lifecycle. On this refusal, violations does not restate file: each element is an assertion, source: "schematron", with its rule in rule and the location of the failing node in xpath.

The other two codes keep the usual details.file, whose first element carries the cause. In every case, fix the document or wait, then deposit again.

422 at deposit: Factur-X not PDF/A-3 conformant​

A sales invoice imported as a Factur-X (source_format: "facturx", provided_pdf: false) is transmitted as is, byte for byte. Before depositing it - before status 200, before any transmission -, Scribee therefore checks the PDF/A-3b (ISO 19005-3) conformance of the imported file with veraPDF. The check applies at deposit, whether you request it as part of the import (lifecycle_state: "deposited") or later through PATCH /api/v1/invoices/{id}/transition. Purchase invoices are not concerned, nor are the invoices Scribee generates itself (POST /api/v1/workspaces/{workspace_id}/invoices, with or without pdf_base64).

A non-conformant file is refused, and nothing is created when the deposit was requested as part of the import. details.file[0] names the failed PDF/A rules (three at most) and the file:

{
"error": "unprocessable_entity",
"code": "facturx_not_pdfa",
"message": "Échec du traitement du fichier de facture",
"details": {
"file": ["Factur-X non conforme PDF/A-3 (ISO 19005-3) : 6.8.1: The MIME type of an embedded file shall be specified using the Subtype key - FA-2026-0042.pdf. Corrigez le fichier puis déposez-le à nouveau."]
}
}

code: "facturx_not_pdfa" signals a verdict about the file, and an imported file cannot be replaced: depositing the same invoice again returns the same refusal, so do not replay the call. Fix the file in your generator, then import it again. When the refusal happened on the transition endpoint, the invoice stays a draft with its number; delete it (DELETE /api/v1/invoices/{id}) before importing the corrected file, otherwise the import is refused as an already-imported number. The transition endpoint's envelope is described in The invoice lifecycle.

If veraPDF cannot produce a verdict, the deposit is refused as well, with code: "facturx_validation_unavailable" and in details.file[0]: La conformité PDF/A-3 (ISO 19005-3) du Factur-X n'a pas pu être contrôlée : le service de validation est indisponible. Réessayez le dépôt dans quelques instants. The file was not judged and nothing is recorded: replay the same call later. Branch your handling on code, not on the text of details.file[0].

The verdict is published on the invoice in facturx_conformance. On a sales invoice imported as a Factur-X, this field is null until the deposit has been checked, including after a facturx_validation_unavailable refusal. It becomes compliant when the deposit is accepted, and non_compliant after a facturx_not_pdfa refusal on the transition endpoint. After a refusal of the deposit requested as part of the import, no invoice exists to carry it.

The most frequent cause is an extra attachment embedded without a MIME type: rule 6.8.1 requires every embedded file to declare its MIME type (the /Subtype key of the file specification). Before sending your Factur-X files:

  • give every embedded file, the invoice XML included, a MIME type (/Subtype) and an AFRelationship;
  • validate your files with veraPDF, PDF/A-3b profile (verapdf --flavour 3b facture.pdf).