DocsAPI Reference

API Reference

Endpoints, request and response shapes, authentication, and error codes.

The Veralens REST API is a small, predictable surface. Every endpoint lives under one base URL, speaks JSON, and returns the same envelope shape whether it succeeds or fails.

text
https://api.veralens.ai/v1

Authentication

Programmatic requests authenticate with an API key as a Bearer token. Create keys under Keys in the dashboard; each secret starts with vl_ and is shown once.

http
Authorization: Bearer vl_your_secret_key

Key management endpoints (create, list, rotate, revoke) are part of the dashboard and use your logged-in session — you cannot manage keys with an API key. Everything below under Jobs accepts an API key.

Response envelope

Success responses wrap the payload in data:

json
{ "status": "success", "data": { "id": "V1StGXR8_Z5jdHi6B", "status": "pending" } }

Errors carry a stable error_code plus a matching HTTP status:

json
{ "status": "error", "error_code": "insufficient_balance" }

Branch on the HTTP status and error_code — the codes are stable; treat human-readable text as advisory only.

POST /jobs/create

Create an extraction job. Returns immediately with a job id; the work runs asynchronously.

Body

FieldTypeRequiredDescription
sourcesarrayyesOne or more inputs. Each is { "type": "text" | "image", "data": string }. Text data is raw text; image data is a data URL (data:image/png;base64,...). Raster images only — SVG and other vector formats are rejected.
schemaobjectconditionalA JSON Schema describing the output object. When present, target must be json (or omitted).
targetstringconditionalOutput format: json, markdown, or plaintext. Required when no schema is given. Defaults to json when a schema is present.
global_promptstringnoNatural-language instructions applied to the whole extraction.
enginestringnovera-1.0-high (default) or vera-1.0-low. See Pricing.
webhook_urlstringnoHTTPS URL to receive the result. API-key auth only. See Jobs & Queue.

You must send at least one of schema or target. Provide a schema for strict typed JSON; provide only a target (with an optional global_prompt) for freeform Markdown/plaintext or schemaless JSON.

Response201 Created. Returns the full job object (same shape as GET /jobs/:jobId/get below), already in pending. model, target, and the precharge hold (usage.cost) are set immediately; output and settled token usage fill in once the job runs.

json
{
  "status": "success",
  "data": {
    "id": "V1StGXR8_Z5jdHi6B",
    "status": "pending",
    "createdAt": "2025-03-01T10:15:00.000Z",
    "source": "key",
    "target": "json",
    "sources": { "images": 1, "texts": 0, "documents": 0 },
    "model": "vera-1.0-high",
    "usage": { "cost": 0.0021, "inputTokens": null, "outputTokens": null },
    "output": null,
    "durationMs": null
  }
}

Example

bash
curl -X POST https://api.veralens.ai/v1/jobs/create \
  -H "Authorization: Bearer vl_your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{
    "sources": [{ "type": "image", "data": "data:image/png;base64,iVBORw0KGgo..." }],
    "engine": "vera-1.0-high",
    "schema": {
      "type": "object",
      "properties": {
        "merchant": { "type": "string", "description": "Store or merchant name." },
        "total":    { "type": "number", "description": "Grand total paid." }
      },
      "required": ["merchant", "total"]
    }
  }'

GET /jobs/:jobId/get

Fetch a single job by id. Poll this until status is no longer pending.

Response

json
{
  "status": "success",
  "data": {
    "id": "V1StGXR8_Z5jdHi6B",
    "status": "completed",
    "createdAt": "2025-03-01T10:15:00.000Z",
    "source": "key",
    "target": "json",
    "sources": { "images": 1, "texts": 0, "documents": 0 },
    "model": "vera-1.0-high",
    "usage": { "cost": 0.0031, "inputTokens": 812, "outputTokens": 44 },
    "output": "{\"merchant\":\"Acme\",\"total\":19.9}",
    "durationMs": 2100
  }
}

Job fields

FieldTypeDescription
idstringJob id.
statusstringpending, completed, or failed.
createdAtstringISO timestamp the job was created.
sourcestringOrigin: key (API) or playground (dashboard).
targetstringjson, markdown, or plaintext.
sourcesobjectCount of inputs by type: images, texts, documents.
modelstringEngine used, or null before it runs.
usageobjectBilled cost (USD), inputTokens, outputTokens. null values until settled.
outputstringThe extraction result as a string. For json targets, JSON.parse it. null until completed.
durationMsnumberWall-clock runtime; null while pending.

GET /jobs/list

List your jobs, most recent first.

Query parameters

ParamTypeDefaultDescription
qstringFree-text search over jobs.
statusstringallall, finished, pending, or failed.
sourcestringFilter by origin: key or playground.
limitnumber100Page size, 1–500.
offsetnumber0Rows to skip.

Response

json
{
  "status": "success",
  "data": {
    "jobs": [ { "id": "V1StGXR8_Z5jdHi6B", "status": "completed", "target": "json", "model": "vera-1.0-high", "usage": { "cost": 0.0031, "inputTokens": 812, "outputTokens": 44 } } ],
    "total": 1
  }
}

Error codes

error_codeHTTPMeaning
unauthorized401Missing or invalid API key.
invalid_input400The request body failed validation.
insufficient_balance400Not enough balance to cover the job's hold. Add funds.
job_not_found404No job with that id for your account.
job_image_mime_unsupported400An image source used an unsupported format (e.g. SVG). Use PNG, JPEG, or WebP.
rate_limit_exceeded429Too many requests — back off and retry.
inference_timeout504The model timed out. Retry with a smaller payload.
inference_rate_limited429Inference is throttled — retry shortly.
parsing_failed500The model response could not be parsed. Retry.
internal_server_error500Unexpected error. Retry.

Rate limits

Every endpoint is rate limited per route. When you exceed a limit you get 429 with rate_limit_exceeded; retry with exponential backoff.