---
title: "Draft a mapping from sample files"
description: "Mappings API"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.certinvo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Draft a mapping from sample files

{/* Generated by apps/docs/scripts/generate.ts from contracts/api/openapi.yaml. Do not edit. */}
<div class="cvo-op">
<div class="cvo-op-main">

<div class="cvo-op-header">
<div class="cvo-op-path-row">
<span class="cvo-method" data-method="post">POST</span>
<code class="cvo-op-path-code">/v1/mappings/drafts</code>
</div>
</div>

Send 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

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

</div>
<div class="cvo-op-aside">

</div>
</div>

Source: https://docs.certinvo.com/reference/api/mappings/draft-a-mapping-from-sample-files/index.mdx
