/v1/data-files/codes/importsSaves every new row and every changed row except those in keep, in one step. A changed row in keep keeps the answer the book holds today. Invalid rows are not imported; the answer names them again. Refused with 409 list_changed when the book has a newer version than basedOn. Preview the file again. Only invoices made after the import read the new answers. Any credential may call this, as for one answer.
Request body
application/json, required
- namestring
- datastring (byte)Required
The file as base64, at most 10 MB decoded.
- liststring
The official list the codes are on, for a file with no
listcolumn. - basedOnintegerRequired
The version the preview answered.
- keeparray of integer
The rows (by
row) of changed codes whose answer today is kept. Absent, every changed code takes the file's answer.
Response
A 200 answer carries these fields.
- basedOnintegerRequired
The code book's version the preview was made against; 0 for a book never written.
- countsobjectRequired
Show 4 child fields
- newintegerRequired
- changedintegerRequired
- sameintegerRequired
- invalidintegerRequired
- rowsarray of objectRequired
Show 9 child fields
- rowintegerRequired
The row's line in the file
- statusstringRequiredOne of
new,changed,same,invalid. - columnstring
An invalid row's column.
- messagestring
Why an invalid row cannot be imported.
- reasonobject
Why an invalid row cannot be imported, as a code, the way an error's
reasonsays it;fieldis the row's column.Show 2 child fields
- codestringRequired
- valuesobjectRequired
- liststringRequired
- codestringRequired
- officialstringRequired
- nowstring
A changed row's answer in the book today.
- savedintegerRequired
How many codes were added or changed.
- versionintegerRequired
The code book's version now.
Status codes
| Status | Meaning |
|---|---|
200 |
What was saved. |
400 |
The body was refused, or the file is no code book file (invalid_data_file, invalid_json). Nothing was saved. |
401 |
No usable credential was sent (invalid_credentials). |
409 |
The code book changed since the preview (list_changed). Nothing was saved. |
501 |
This deployment keeps no database, so nothing can be saved (no_database). |
502 |
The engine could not run, so nothing was read (engine_unavailable). |
/v1/data-files/codes/importscurl -X POST https://api.certinvo.com/v1/data-files/codes/imports \
-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/data-files/codes/imports`, {
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/data-files/codes/imports",
headers={"Authorization": f"Bearer {os.environ['CERTINVO_API_KEY']}", "Content-Type": "application/json"},
data=open("body.json", "rb"),
)
print(response.status_code, response.text){
"basedOn": 0,
"counts": {
"new": 0,
"changed": 0,
"same": 0,
"invalid": 0
},
"rows": [
{
"row": 0,
"status": "new",
"column": "string",
"message": "string",
"reason": {
"code": "string",
"values": {}
},
"list": "string",
"code": "string",
"official": "string",
"now": "string"
}
],
"saved": 0,
"version": 0
}