Skip to content

API reference

Preview a code book file

Other routes API

POST/v1/data-files/codes/previews

Reads a code book file (CSV, Excel or JSON) and says what importing it would do, row by row. Nothing is saved. A row is keyed by its list and code. Each row is new, same, changed (with now, the answer the book holds today) or invalid, naming its column and why: a list that is not official, an empty code or one longer than 100 characters, an answer not on the list, or a code the file answers twice. A file with no list column takes list from the request: the official list its codes are on. Without it, such a file is refused. A code the file leaves out is kept. basedOn is the book’s version; send it with the import.

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 list column, as GET /v1/mappings/codes/lists names it.

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

    • statusstringRequired
      One 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 reason says it; field is the row's column.

      Show 2 child fields
      • codestringRequired
      • valuesobjectRequired
    • liststringRequired
    • codestringRequired
    • officialstringRequired
    • nowstring

      A changed row's answer in the book today.

Status codes

Status Meaning
200 What the file would do.
400 The body was refused, or the file is no code book file (invalid_data_file, invalid_json). Nothing was read.
401 No usable credential was sent (invalid_credentials).
502 The engine could not run, so nothing was read (engine_unavailable).
POST/v1/data-files/codes/previews
Example
curl -X POST https://api.certinvo.com/v1/data-files/codes/previews \
  -H "Authorization: Bearer $CERTINVO_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @body.json
import { readFile } from 'node:fs/promises'

const response = await fetch(`https://api.certinvo.com/v1/data-files/codes/previews`, {
  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/previews",
    headers={"Authorization": f"Bearer {os.environ['CERTINVO_API_KEY']}", "Content-Type": "application/json"},
    data=open("body.json", "rb"),
)
print(response.status_code, response.text)
200
application/json
{
  "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"
    }
  ]
}
Success response
POST
/v1/data-files/codes/previews
Preview a code book file
All
›AuthenticationRequiredBearerAuth

Provide your API key in the Authorization: Bearer <key> header. Keys are stored locally in your browser.

›Headers2
›Bodyapplication/json
›Code Snippet
curl -X POST "https://api.certinvo.com/v1/data-files/codes/previews" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "string",
  "data": "string",
  "list": "string"
}...'
Response

No request sent yet

Configure parameters and click Send to view the response.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close