/v1/mappings/draftsSend sample files of one source and get a draft mapping card back. Without target the card writes the Certinvo canonical invoice. With target it writes a model you registered with POST /v1/mappings/models. Each sample is read the way the console reads it, and several samples are joined into one corpus. Files that are not one source (a different format, or written a different way) are refused. The draft is a proposal. unmapped lists the columns it left open, each with its reasons and the fields it was torn between. The draft is kept with its samples under id: decide the open columns with POST /v1/mappings/drafts/{id}/decisions, test it on every sample with .../test, and a named person finalizes it with .../finalize. The samples are kept as your files, once each. Nothing is validated. An empty samples list starts a draft from the model instead: the canonical invoice’s empty card, with every field in targets and nothing decided. Decide its fields one by one, a fixed value or a column, and add a sample with .../samples when you have one. It is made without the profiler. A draft for your own model, or with from, needs samples. Finalizing still needs a test that passed on a sample.
Request body
application/json, required
- samplesarray of objectRequired
Sample files of one source, or an empty list for a draft from the model.
Show 2 child fields
- namestringRequired
The file's name. Its bytes decide how it is read, not its extension.
- datastring (byte)Required
The file, base64-encoded. All samples together may be 10 MB of files, whatever the base64 adds.
- targetobject
One of your registered target models. Leave it out for the canonical invoice.
Show 2 child fields
- namestringRequired
- versionstringRequired
- fromstring
A version you froze, when these samples are a changed layout of its files. The new draft starts from it: every field whose column is still there and reads the same is carried over exactly, marked
carried, and the rest is left for review. It writes the model that version writes. - formatsarray of object
With
fromonly. The new way of writing a person confirms for a column avalue_format_changedrefusal named:{column, format}, the column asdetail.fields[].sourcenames it and one of itsnowconverters. Each field offromthat reads the column with a converter of that kind is carried over read the new way; the rest are carried as ever. A column whose values read both ways keeps the converter offrom.Show 2 child fields
- columnstringRequired
- formatstringRequired
- aiReadingstring
The person agreed to have this one PDF read by the AI service our privacy notice names. Only for a single PDF sample; ignored for any other file. While the company's switch (
PUT /v1/company/ai-reading) is on, every single PDF is read without it. The reading adds suggestions to open columns,proposal.by=ai-reading, never a decision;profile.source.aiReadingsays how many were proposed, which fields no label holds, and why nothing was read, if so.One ofthis-file.
Status codes
| Status | Meaning |
|---|---|
200 |
{id, draft, profile, targets, unmapped, corpus, card, decisions, notApplied, from, carried}: the kept draft’s id; the profiler’s draft card; what the samples hold, column by column; every field a column may go to; the columns left open; each file with how many records it held; the card with the decisions applied, the decisions (with from, the ones carried over), any that did not apply, the version it starts from and the fields carried over unchanged. A deployment with no database keeps nothing and answers no id. sameFile, when sent: each sample whose bytes are another’s, {name, sameAs}; it counts once. |
400 |
No sample has a name and its bytes (no_samples), target is not {name, version} (invalid_target_model), this company registered no such model (unknown_target_model), from is not a version (invalid_mapping_config), aiReading is not this-file (invalid_ai_reading), or formats is sent without from, or names a column from does not read with a converter of that kind (invalid_formats). |
401 |
No usable credential was sent (invalid_credentials). |
404 |
from names a version this company never froze (unknown_mapping_config). Nothing was drafted. |
413 |
The samples are larger than 10 MB together (document_too_large), or one holds more than one request may carry once read (file_too_large_to_read). Nothing was drafted. |
422 |
The samples are more than one layout (several_sources, detail.groups lists each group’s files; draft each group on its own), the samples are not one source (not_one_source, detail names the file), a sample is already an e-invoice (already_an_invoice), a sample cannot be read (unreadable_file), or the profiler cannot profile it (unprofilable_sample). Nothing was drafted. |
503 |
The profiler did not answer (profiler_unavailable). Nothing is wrong with the samples. |
/v1/mappings/draftscurl -X POST https://api.certinvo.com/v1/mappings/drafts \
-H "Authorization: Bearer $CERTINVO_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @body.jsonimport { readFile } from 'node:fs/promises'
const response = await fetch(`https://api.certinvo.com/v1/mappings/drafts`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CERTINVO_API_KEY}`,
'Content-Type': 'application/json',
},
body: await readFile('body.json'),
})
console.log(response.status, await response.json())import os
import requests
response = requests.post(
"https://api.certinvo.com/v1/mappings/drafts",
headers={"Authorization": f"Bearer {os.environ['CERTINVO_API_KEY']}", "Content-Type": "application/json"},
data=open("body.json", "rb"),
)
print(response.status_code, response.text)