Exports
Download Constaia results as JSON, CSV, Excel, XML, vCard or PDF, per analysis or combined per batch, via 24-hour signed links or on demand.
Besides the JSON response, Constaia generates ready-to-use files with the extracted data and the verdict. Exports are included in the price of the analysis: they don't use credits.
Formats
| Format | Extension | Content |
|---|---|---|
json | .json | The full analysis object (for a batch, a list of analyses). |
csv | .csv | One row per document with the extracted fields and the verdict. |
xlsx | .xlsx | Same as csv, in an Excel sheet. |
xml | .xml | The same data as XML. |
vcard | .vcf | One contact card (vCard 4.0) per document: name, birth date, address and a note with the type, the document number and the verdict. Meant for identity documents. |
pdf | .pdf | A readable report of the analysis. |
In csv and xlsx, each row starts with some common columns (id, file, type, verdict, reasons, signals, date),
continues with the extracted fields and ends with a metadata.<key> column for each metadata key. Nested fields
(e.g. an invoice's lines) go as JSON in their cell. Column headers are in Spanish. The CSV uses ; as separator,
decimal commas and UTF-8 with BOM, so Spanish-locale Excel opens it correctly straight away.
The field columns depend on the document type. The quickest way to see them is to generate an export in test mode, which is free.
Two ways to get them
1. When analysing: options.export
Ask for the formats in the same request. When the analysis finishes, exports holds one signed URL per format:
curl https://api.constaia.com/v1/analyze \
-H "Authorization: Bearer $CONSTAIA_API_KEY" \
-F file=@invoice.pdf \
-F 'options={"expect":"invoice","export":["xlsx","json"]}'"exports": {
"xlsx": "https://api.constaia.com/v1/files/exp_01J9Z…?expires=1790244002&sig=…",
"json": "https://api.constaia.com/v1/files/exp_01J9Z…?expires=1790244002&sig=…"
}- The URLs don't need an API key: the signature is the authorisation. Treat them as secrets and don't publish them.
- They expire after 24 hours. After that they return
404. GET /v1/analyses/{id}returns the links that are still valid inexports.- If the analysis is async, the URLs arrive in the
analysis.completedwebhook.
2. On demand: GET /v1/analyses/{id}/export
Generates the file on the fly, with your API key, for any finished analysis whose results are still stored:
curl -OJ "https://api.constaia.com/v1/analyses/an_01J9Z8Q3K4M5N6P7Q8R9S0T1V2/export?format=xlsx" \
-H "Authorization: Bearer $CONSTAIA_API_KEY"formatacceptsjson(default),csv,xlsx,xml,vcardorpdf.- The response is the file with
Content-Disposition: attachment; filename="an_….xlsx"(that is whycurl -OJsaves it under its name). - If the analysis hasn't finished:
409 analysis_not_completed. Wait forcompleted. - If it was deleted or created with
keep_results: false:404 resource_missing.
Downloading from your code
constaia.analyses.export() returns the raw Response:
import { writeFile } from "node:fs/promises";
import { Constaia, InvalidRequestError } from "@constaia/sdk";
const constaia = new Constaia();
const id = process.argv[2]!;
try {
const res = await constaia.analyses.export(id, "xlsx");
await writeFile(`${id}.xlsx`, Buffer.from(await res.arrayBuffer()));
console.log(`Saved ${id}.xlsx`);
} catch (err) {
if (err instanceof InvalidRequestError && err.code === "analysis_not_completed") {
console.error("The analysis hasn't finished yet.");
} else {
throw err;
}
}To download a signed URL from exports you need neither the SDK nor the key: a plain GET is enough.
curl -o invoice.xlsx "https://api.constaia.com/v1/files/exp_01J9Z…?expires=1790244002&sig=…"Combined batch export
In a batch, options.export applies to the batch: when every document has finished,
Constaia generates a single file per format with one row per document (extracted fields and verdict). The URLs
arrive in the batch object's exports and in the batch.completed webhook:
curl https://api.constaia.com/v1/batches \
-H "Authorization: Bearer $CONSTAIA_API_KEY" \
-F "files[]=@invoice-1.pdf" \
-F "files[]=@invoice-2.pdf" \
-F 'options={"expect":"invoice","export":["xlsx"]}'{
"id": "bat_01J9Z…",
"object": "batch",
"status": "completed",
"total": 2,
"exports": { "xlsx": "https://api.constaia.com/v1/files/exp_01J9Z…?expires=…&sig=…" }
}It is the easiest way to turn a pile of invoices into a spreadsheet. Full guide: invoices to Excel.
Privacy
Exported files are stored encrypted, like documents, and are deleted when you delete the analysis
(DELETE /v1/analyses/{id}). Signed links expire after 24 hours. More in
storage and privacy.
Next steps
Data residency & compliance
Where Constaia processes and stores documents, the sovereign and standard processing profiles, the upcoming US region, and how GDPR, CCPA and DPPA apply to your integration.
Credits & billing
How credits are calculated per page, what is not charged, the free plan of 150 credits a month, packs in EUR and USD, expiry, balance, alerts and 402 errors.