VerifyAI Node.js Integration
Call the VerifyAI REST API from your Node.js backend with the fetch and FormData built into Node 18+. There is no Node package to install: the examples below are plain HTTPS, and the webhook receiver is run against real signed deliveries in our test suite.
Quick Start
1. Install
# No VerifyAI package to install: Node 18+ ships fetch, FormData and Blob.
# Keep your API key on the server.
export VERIFY_AI_KEY=vai_your_api_key2. Use
import fs from "node:fs";
const form = new FormData();
form.set("image", new Blob([fs.readFileSync("photo.jpg")], { type: "image/jpeg" }), "photo.jpg");
form.set("policy", "scooter_parking");
form.set("metadata", JSON.stringify({ trip_id: "trip_123" }));
const res = await fetch("https://verify.switchlabs.dev/api/v1/verify", {
method: "POST",
headers: { "X-API-Key": process.env.VERIFY_AI_KEY },
body: form,
});
const result = await res.json();
if (!res.ok) throw new Error("VerifyAI " + res.status + ": " + result.error);
if (result.is_compliant) {
console.log("Verified:", result.id);
} else {
console.log("Issue:", result.feedback, result.violation_reasons);
}Features
Plain HTTPS
One POST to /api/v1/verify with an X-API-Key header. Works with fetch, undici, axios or got, with nothing VerifyAI-specific to install or upgrade.
Multipart or JSON
Send the photo as a multipart file, or as base64 in a JSON body when it reached your server that way from a mobile client.
Stable JSON Response
Branch on is_compliant, violation_reasons, feedback and confidence. The docs include a TypeScript interface for the response you can copy into your project.
Idempotent Retries
Send an Idempotency-Key header and a retried request returns the original result instead of running, and billing, the check twice.
Tested Webhook Receiver
Verify X-VerifyAI-Signature over the raw body with node:crypto. The Express and Next.js receivers below run against real signed deliveries in our test suite.
Clear Rate Limits
A 429 carries Retry-After in seconds, and every response carries an X-Request-Id you can quote to support.
Code Examples
Requirements
- Node.js 18 or higher (built-in fetch, FormData and Blob)
- A VerifyAI API key (vai_…), kept on your server
- Express and multer only if you use the upload example
- Your webhook signing secret (whsec_…) for the receiver
Frequently Asked Questions
Start Building with Node.js
Get an API key and send your first verification with a single fetch call.
Other ways to integrate
Mobile SDKs, server-side HTTP examples, the REST API, webhooks, and no-code automation platforms.