---
title: "Open a file as a draft"
description: "Invoicing 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.

# Open a file as a draft

{/* 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/drafts/from-file</code>
</div>
</div>

Reads one invoice file and saves it as a new draft, which the console's create form continues. Nothing is filed. An XRechnung, UBL, CII or ZUGFeRD file is read by the same reader that reads a received invoice, and the draft holds the canonical invoice it makes. `settings.openedFrom.verdict` is the validator's verdict on the file as it arrived. A PDF with no invoice inside is read through this company's one PDF mapping, on our servers. `settings.openedFrom.read` is then `pdf`, and every field needs a check. Our own canonical JSON is saved as it is. A customer's own export (CSV, XLSX, JSON, XML, SAP IDoc, EDIFACT) is read through a saved mapping: the one `mappingVersion` names, or the one of this company's mappings that reads the file. `settings.openedFrom.read` is then `mapped`, with the mapping's version. An export of more than one invoice is refused (`unreadable_file`) naming how many; make them as serial invoices or send the file through the mapping.

## Request body

`application/json`, required

## Response

A `201` answer carries these fields.

## Status codes

| Status | Meaning |
|---|---|
| `201` | The saved draft. `settings.openedFrom` says how it was read. |
| `400` | The body was refused (`invalid_draft`, `invalid_json`, `invalid_operation` for data that is not base64), or the file is not one invoice this door opens (`unreadable_file`, `unreadable_document`). A file a mapping cannot fill is refused as a mapped file is (`unmappable_payload`, `config_reads_no_file`). Nothing was saved. |
| `401` |  |
| `404` | `mappingVersion` names no saved mapping of this company (`unknown_mapping_config`). Nothing was saved. |
| `409` | More than one of this company's mappings reads the file, and they would make different invoices (`several_mappings_fit`). `detail.versions` names them and `detail.layout` the file's layout; send the file again naming `mappingVersion`, or answer once for the layout with `POST /v1/mappings/layout-choices`. Nothing was saved. |
| `413` | The file is larger than one document may be (`document_too_large`, `file_too_large_to_read`). Nothing was read. |
| `422` | No saved mapping of this company reads this export (`no_mapping_fits`). `detail.format` is what the file was recognised as, for the Convert page that makes one. Nothing was saved. |
| `501` |  |
| `502` | The engine could not run, so nothing was saved (`engine_unavailable`). |

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

</div>
</div>

Source: https://docs.certinvo.com/reference/api/invoicing/open-a-file-as-a-draft/index.mdx
