Express
Validate documents with AI in Express
The file is processed in memory and sent with the JavaScript SDK, without ever being written to disk.
Installation
npm i @constaia/sdk multer
The safe pattern
The browser or app never sees your secret key. The file goes to your server, your server calls Constaia and returns the result. If you do not have a server, use the widget with a publishable key.
import express from "express";
import multer from "multer";
import { Constaia } from "@constaia/sdk";
const app = express();
const upload = multer({ storage: multer.memoryStorage(), limits: { fileSize: 20 * 1024 * 1024 } });
const constaia = new Constaia();
app.post("/api/verify", upload.single("file"), async (req, res) => {
if (!req.file) return res.status(400).json({ error: "missing_file" });
const analysis = await constaia.analyze(req.file.buffer, {
filename: req.file.originalname,
expect: "es_dni",
checks: { notExpired: true },
});
res.json({ status: analysis.verdict?.status, reasons: analysis.verdict?.reasons });
});
app.listen(3000);One call. An answer you can act on.
- 01
Send the document and what you expect
A photo, screenshot or PDF. Tell us which document you expect and the rules it must meet: not expired, issued in the last 60 days, in this person's name.
- 02
We read, classify and check
Text reading, AI classification and fixed checks: PDF417 barcodes, machine-readable zones, ABA routing numbers, dates and totals.
- 03
Get the verdict and the file is deleted
Valid, invalid or review, with the reasons in your language. By default, the file is deleted when the analysis ends unless it needs review.
And for the record…
Create your free account and validate your first document in five minutes. No credit card required.