Send a whole export file, such as a month of invoices, through one of the company’s frozen mapping cards. Certinvo maps and validates each invoice in it, and you download the results. One invoice and many use the same call.
Before you start
- The company has a frozen card with an
inputblock.GET /v1/mappingslists the company’s cards. You may name the card by its version, for examplehandwerk-csv-draft-1.0.0, or let the API find the one that reads the file. - The workspace’s processing plan includes conversion. Otherwise the call is refused with 403
workspace_plan_unavailable(no plan in force) oroperation_not_included. - The decoded file fits the plan’s byte limit. That limit is at most 10 MB. The API allows a 14 MB encoded request, so base64 overhead does not eat into the 10 MB.
- The file holds no more than 128 MB once read. A wide export can pass that even when the file itself is well under 10 MB, because reading it repeats every column name for each row. Split such a file.
Send the file
DATA=$(base64 < export.csv | tr -d '\n')
curl -s -X POST "https://api.certinvo.com/v1/conversions" \
-H "Authorization: Bearer cvo_live_sk_..." \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d "{\"input\":{\"type\":\"mapped-file\",\"mappingVersion\":\"handwerk-csv-draft-1.0.0\",\"data\":\"$DATA\"}}"The answer is 202 with the operation and its items:
{"id":"…","kind":"conversion","context":"issued","status":"processing","itemCount":1,"pending":1,"policyVersion":3,"mappingVersion":"handwerk-csv-draft-1.0.0","retention":{"kind":"durable","expiresAt":null},"items":[{"index":0,"status":"pending"}]}itemCountcounts invoices, not rows. Here it is 1, because the file has two rows that form one invoice.contextisissued: a conversion always produces issued invoices.mappingVersionnames the card that read the file.
To also get other files, such as the ZUGFeRD PDF or a Peppol BIS 3.0 file, add outputs beside input,
exactly as for canonical invoices. See
Create an invoice and its PDF.
Once the invoices are stored, the answer is 202 with the id, even when handing them to the queue failed. The service picks them up again within about fifteen minutes. Do not send the file again.
Let the API pick the card
Leave mappingVersion out, and the API finds the card itself:
curl -s -X POST "https://api.certinvo.com/v1/conversions" \
-H "Authorization: Bearer cvo_live_sk_..." \
-H "Content-Type: application/json" \
-d "{\"input\":{\"type\":\"mapped-file\",\"data\":\"$DATA\"}}"The API reads what format the bytes are, such as csv, xlsx or edifact, and tries each frozen card
whose input.format is that format on the file. It never reads the file name for this. A card reads the
file when its reader reads it and the file has every column or place the card reads from. An empty value
does not count against it. A PDF goes to the cards whose format is document, which read a PDF your system
printed. Several versions of one card count as one card, and the newest confirmed version is used. A retired card
is never tried. The
answer’s mappingVersion says which version read the file.
Nothing is accepted in these cases:
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_operation |
The file is not a customer export. A finished e-invoice belongs on POST /v1/validations, and canonical JSON in an input of type canonical-invoices. A PDF sent with no PDF card is refused this way too, and the message names both doors. The message says which. |
| 409 | several_mappings_fit |
Cards with more than one name read this file, and they would make different invoices. detail holds the format, the versions that read it and the file’s layout. Choosing between two integrations is a decision about somebody’s invoices, so send the file again naming one, or answer once for the layout with POST /v1/mappings/layout-choices. |
| 422 | no_mapping_fits |
No frozen card of this company knows enough of this file’s layout: it comes from another system, and it is not a filled copy of our CSV or Excel template (Start from a template). detail.format is the format the bytes were recognised as, when they were. Create a card for it, freeze it, and send the file again. |
| 400 | unreadable_file |
Nothing places the bytes as a customer export. The one card of the format they come closest to says why it cannot read them, in detail. |
When no card reads the file cleanly, the card that knows most of its layout reads it, when it knows at least 0.6
of it and 0.15 more than the next card: the file is read as if sent naming it: refused with unreadable_file or unmappable_payload, with
error.mappingVersion naming it, or converted with its notes. A card that has seen
every field of the file comes before one that reads it with a field it never saw. Two cards that read the file and
decide the same are one card: the newest reads it, the other is retired, and nobody is asked.
The console’s upload works this way: a customer export dropped there is sent without mappingVersion.
When two cards read the file, the person picks one on the file’s page, and the file is sent again naming it.
If the file is refused
A file is accepted whole or not at all. Nothing is stored when a file is refused. A file with fields the card has
never seen, or without fields it reads, is accepted, and the answer’s notes names them: new_fields,
missing_fields, and optional_fields_absent for the ones the card lets a file lack. These are Certinvo checks, not
legal requirements. Save the card’s next version from the file to decide each field once.
| Status | Code | Meaning |
|---|---|---|
| 404 | unknown_mapping_config |
The company has no card with that version. |
| 409 | mapping_retired |
The version names a retired card. detail names it and, in into and version, the card that replaced it and its newest version. Send the file again naming that version, or naming none. |
| 400 | config_reads_no_file |
The card has no input block, so it cannot read a file. |
| 400 | unreadable_file |
The file does not match the card’s input block. detail says what the reader found. |
| 400 | unmappable_payload |
Some records could not be mapped. detail names up to twenty, each with its position in the file and its fields. Each field names the source the card read and the mapper’s detail, such as the column it looked for. review lists the values waiting for a person. One record is enough to refuse the file: Certinvo never files a partly mapped invoice. |
| 409 | value_format_changed |
The values of one or more columns are now written another way than the card declares, such as dates or amounts. detail.fields names each column, the way it was and the ways that read it now. Nothing was read the new way. |
| 400 | operation_too_large |
More items or decoded bytes than the workspace plan permits. Split the file. |
| 400 | not_an_invoice |
A record maps to a business document that claims no payment, such as a pro forma (type code 325). It is made as a PDF only, with POST /v1/business-documents. Nothing was accepted. |
| 413 | operation_too_large |
The base64 and JSON request is larger than 14 MB. Split the operation. |
| 400 | invalid_operation |
The request or its base64 is malformed, it names a field the contract does not allow, or mappingVersion is sent but empty. The message names the field. |
| 413 | file_too_large_to_read |
The file holds more than 128 MB once read. Split it. |
| 409 | several_mappings_fit |
Only without mappingVersion: more than one card reads the file. See above. |
| 422 | no_mapping_fits |
Only without mappingVersion: no card reads the file. See above. |
| 409 | idempotency_key_reused |
The same key was used before with a different body. |
| 403 | workspace_plan_unavailable, operation_not_included |
No plan is in force, or it does not include conversion. |
| 429 | document_quota_exceeded |
The plan’s document allowance has no room for every invoice in the file. |
| 502 | engine_unavailable |
Our reader could not run. This says nothing about the file; send it again. |
| 503 | store_unavailable |
The operation could not be stored. Send it again. |
After a layout change, the console can help you rebuild the card. See Handle a file that no longer fits.
Follow the conversion
Poll the operation:
curl -s -H "Authorization: Bearer cvo_live_sk_..." "https://api.certinvo.com/v1/conversions/<id>"The answer lists every item with its status. A finished item has its verdict and generated files, or
an error. pending counts the items still waiting.
- A durable result also carries its retained
invoiceId. A temporary result never enters the archive. - An error’s code is
unreadable_document,invalid_invoice,engine_unavailable,virus_foundorinvoice_number_used. None is a verdict.virus_foundmeans the virus scan found a virus in your file.invoice_number_usedmeans another outgoing invoice of your company already carries that invoice number, so the invoice was not filed. Give it the next free number and send it again. - An
invalid_invoiceerror also hasdetail, naming each field at fault by its JSON Pointer.
Or follow it live as server-sent events:
curl -N -H "Authorization: Bearer cvo_live_sk_..." "https://api.certinvo.com/v1/conversions/<id>/events"The stream first repeats the items that are already done. It then sends a settled event for each item as
it finishes, and ends with done.
Retry safely
To retry an operation whose answer you did not receive, send the same Idempotency-Key with the same
body. You get the original operation back instead of a second one.
Download validated files
Download one released rendering:
curl -OJ -H "Authorization: Bearer cvo_live_sk_..." \
"https://api.certinvo.com/v1/conversions/<id>/items/0/download?format=ubl"Or download a ZIP containing every released file:
curl -o conversion.zip -H "Authorization: Bearer cvo_live_sk_..." \
"https://api.certinvo.com/v1/conversions/<id>/download"A rejected or withheld file is never placed in either download. Its validator report stays at
GET /v1/conversions/<id>/items/0/report.
Once an item is filed, the invoice also keeps where each of its values came from, and names the file it
was made from. Download them from the invoice with format=trace and format=source-file. See
Download an invoice in another format. An
operation that keeps its results only for a while keeps neither.
Convert canonical invoices instead
The same route also accepts invoices in Certinvo’s own JSON, without a card:
{"input":{"type":"canonical-invoices","items":[{ …canonical invoice… },{ …another… }]}}Canonical items are rendered as issued invoices. Finished e-invoice files belong on
POST /v1/validations instead, where the request states received or issued and no conversion
happens.
See also
- Handle a file that no longer fits: fix a card after the export changes.
- Mapping card format: every key a card may hold.