A compliant passport photo from one API call.

Send a portrait and name the document. The Photo Engine checks it against that country's official rules, crops it to the exact millimetre, replaces the background and returns the finished photo with every measurement it took.

Base URL https://visapicture.com/api/v1

Request
curl https://visapicture.com/api/v1/photos \
  -H "X-Client-Id: $VISAPICTURE_CLIENT_ID" \
  -H "Authorization: Bearer $VISAPICTURE_KEY" \
  -H "Idempotency-Key: order-1042" \
  -F "document=us-passport" \
  -F "file=@portrait.jpg"
Response, shortened
{
  "status": "passed",
  "measurements": {
    "head_height_mm": 31.1,
    "eye_from_bottom_mm": 31.0
  },
  "issues": [],
  "result": { "url": "https://…/photo.jpg" }
}

Quickstart

Three steps take you from keys to a finished photo. Use a test key while you build: it is free and behaves exactly like a live key, except that results carry a watermark.

  1. Keep your credentials on your server

    You get a client ID and a subscription key. Store both as environment variables on your backend. Never ship the key in a mobile app or in browser code.

  2. Send the photo

    Post the image as multipart/form-data with the document id. The call waits for the engine and answers with the verdict, usually within 2 to 6 seconds.

    curl https://visapicture.com/api/v1/photos \
      -H "X-Client-Id: $VISAPICTURE_CLIENT_ID" \
      -H "Authorization: Bearer $VISAPICTURE_KEY" \
      -H "Idempotency-Key: order-1042" \
      -F "document=us-passport" \
      -F "file=@portrait.jpg"
  3. Act on the status

    If status is passed, download the image from result.url within the hour and store it yourself. If it is failed, show the issues messages to your user so they can retake the photo.

Authentication

Every request carries two headers. The client ID says who you are and is safe to log. The subscription key is the secret.

Request headers
X-Client-Id: vp_cid_3f9a1c0d2b7e4f6a9c5d1e0b
Authorization: Bearer vp_test_sk_Zk3…
CredentialLooks likeUse
Client IDvp_cid_…Identifies your account. Sent in X-Client-Id.
Test keyvp_test_sk_…Free. Results are watermarked. Has its own monthly quota.
Live keyvp_live_sk_…Clean results. Counts toward your plan.

A key is shown once, when it is created. We keep only a fingerprint of it, so a lost key cannot be recovered. Ask for a new one and have the old one revoked. You can hold several keys at once, which lets you rotate without downtime.

The API is for server-to-server calls. It sends no CORS headers, so browsers cannot call it directly, which protects your key.

Process a photo

POST /photos

FieldWhereDescription
fileForm, requiredThe portrait. JPEG, PNG or HEIC, up to 4 MB. 2400 px on the long side is more than enough.
documentForm, requiredA document id such as us-passport. See Documents.
Idempotency-KeyHeader, optionalA unique string of up to 128 letters, digits or symbols without spaces, for example your order number. A retry with the same key returns the first result and is not counted twice. Test and live keys keep separate lists, and a request that ended in an error can be retried with the same key.

The response is 201 Created with a photo object. A replayed idempotent request answers 200 with the header Idempotent-Replayed: true.

Response when the photo passes
{
  "object": "photo",
  "id": "5b0c9d1e-7a41-4f0e-9c1b-2f6f0e7a3d55",
  "mode": "live",
  "document": "us-passport",
  "status": "passed",
  "issues": [
    {
      "code": "strong_smile",
      "severity": "warn",
      "message": "Use a neutral expression; a big smile may be rejected."
    }
  ],
  "measurements": {
    "head_height_mm": 31.1,
    "eye_from_bottom_mm": 31.0,
    "eye_from_top_mm": 19.8,
    "top_margin_mm": 4.4,
    "chin_to_bottom_mm": 15.3,
    "center_offset_mm": -0.1,
    "upscale": 0.82
  },
  "ranges": {
    "head_height": { "value": 31.1, "range": { "min": 25.4, "max": 34.9 }, "pass": true },
    "eye_line": { "value": 31.0, "range": { "min": 28.6, "max": 34.9 }, "pass": true },
    "top_margin": { "value": 4.4, "range": { "min": 2.0, "max": 8.1 }, "pass": true }
  },
  "output": { "width_px": 600, "height_px": 600, "dpi": 300 },
  "source": { "width_px": 1920, "height_px": 2400 },
  "result": {
    "url": "https://…/photo.jpg?token=…",
    "url_expires_at": "2026-11-27T15:04:05.000Z",
    "content_type": "image/jpeg"
  },
  "error_code": null,
  "processing_ms": 2840,
  "created_at": "2026-11-27T14:04:05.000Z",
  "expires_at": "2026-11-28T14:04:05.000Z"
}

For the best results, send the original camera photo: face the camera, even light, nothing covering the face. The engine straightens a tilted head by up to 25 degrees and brightens a dim photo on its own. It cannot repair blur, a black-and-white photo or a turned head.

Reading the result

A request that reaches the engine always returns a photo object. The status field carries the verdict.

StatusMeaningWhat to do
passedThe photo meets every rule we check. result.url holds the finished image.Download and store it. Show any warn issues to your user.
failedThe photo breaks at least one rule. There is no result.Show the fail messages and ask for a new photo. Not counted toward your quota.

Each entry in issues has a stable code for your logic, a severity and a plain-language message written for the person in the photo.

SeverityMeaning
failBreaks an official rule, for example a tilted head, closed eyes, a second face, blur or a black-and-white photo.
warnThe photo passed, but something may still cause a rejection, for example a big smile or a low-resolution source.
Response when the photo fails, shortened
{
  "object": "photo",
  "id": "c1a7e6b2-3d94-4a8e-b0f5-91d2c4e8a771",
  "mode": "live",
  "document": "uk-passport",
  "status": "failed",
  "issues": [
    {
      "code": "head_tilted",
      "severity": "fail",
      "message": "Your head is tilted. Keep both eyes level."
    }
  ],
  "result": null
}

measurements are taken on the finished photo, in millimetres at print size. ranges pairs each official rule with its allowed range and whether the photo is inside it, so you can show your users the proof.

Retrieve a photo

GET /photos/{id}

Returns the same photo object with a fresh download link. Use it when the first link has expired. Its status can also be processing while a request is still running, or error if that request failed. Photos made with a test key are only visible to test keys, and live photos to live keys.

Retrieve a photo
curl https://visapicture.com/api/v1/photos/5b0c9d1e-7a41-4f0e-9c1b-2f6f0e7a3d55 \
  -H "X-Client-Id: $VISAPICTURE_CLIENT_ID" \
  -H "Authorization: Bearer $VISAPICTURE_KEY"

Documents

GET /documents GET /documents/{id}

Lists every document the engine can produce, with the official size, head-height range and background it enforces. These are the ids you can use today.

Document idDocumentSizeHead height
us-passportUS Passport2 x 2 in (51 x 51 mm)25.4 to 34.9 mm
us-visaUS Visa2 x 2 in (51 x 51 mm)25.4 to 34.9 mm
uk-passportUK Passport35 x 45 mm (1.38 x 1.77 in)29 to 34 mm
schengen-visaSchengen Visa35 x 45 mm (1.38 x 1.77 in)32 to 36 mm
india-passportIndian Passport35 x 45 mm (1.38 x 1.77 in)36 to 38.25 mm
india-visaIndian Visa (e-Visa)2 x 2 in (51 x 51 mm)25.4 to 34.9 mm
List documents
curl https://visapicture.com/api/v1/documents \
  -H "X-Client-Id: $VISAPICTURE_CLIENT_ID" \
  -H "Authorization: Bearer $VISAPICTURE_KEY"

Usage

GET /usage

Shows how many photos have passed this calendar month, in UTC, and what remains of your quota in each mode. Only photos that pass are counted. Failed photos and errors are free. Photos that are still being processed hold a place in the quota until they finish.

Check usage
curl https://visapicture.com/api/v1/usage \
  -H "X-Client-Id: $VISAPICTURE_CLIENT_ID" \
  -H "Authorization: Bearer $VISAPICTURE_KEY"
Response
{
  "object": "usage",
  "client_id": "vp_cid_3f9a1c0d2b7e4f6a9c5d1e0b",
  "period_start": "2026-11-01T00:00:00.000Z",
  "period_end": "2026-12-01T00:00:00.000Z",
  "live": { "photos_passed": 412, "monthly_quota": 1000, "remaining": 588 },
  "test": { "photos_passed": 37, "monthly_quota": 200, "remaining": 163 },
  "rate_limit_per_minute": 30
}

Errors

Errors use standard HTTP status codes and always have the same body. Branch on error.code, and quote request_id when you ask us for help. Every response also carries it in the X-Request-Id header.

Error body
{
  "error": {
    "code": "invalid_credentials",
    "message": "The client ID or subscription key is not valid.",
    "request_id": "req_8f3a1c0d2b7e4f6a9c5d1e0b3a7f2c4d"
  }
}
HTTPCodeMeaning
400invalid_requestA field is missing or malformed. The message says which one.
400unknown_documentThe document id is not one we support.
401missing_credentialsThe X-Client-Id or Authorization header is missing.
401invalid_credentialsThe client ID and key do not match, or the key was revoked.
403client_disabledThe API client has been disabled.
404not_foundNo such photo or document. Photos are deleted after 24 hours.
409request_in_progressA request with the same Idempotency-Key is still running.
413file_too_largeThe upload is larger than 4 MB.
413image_too_largeThe image has more than 64 megapixels.
422unsupported_formatThe file is not a JPEG, PNG or HEIC image.
422unreadable_imageThe file is damaged or is not an image.
429rate_limitedToo many requests in the last minute. Wait for Retry-After seconds.
429quota_exceededThe monthly quota for this mode is used up, or is held by photos still in progress.
500engine_errorThe engine failed or ran out of time. Retry, with the same Idempotency-Key if you sent one. Errors are never counted.
503service_unavailableA temporary outage. Retry with backoff.

Retry 429, 500 and 503 with backoff, and send an Idempotency-Key so a retry can never be counted twice. Do not retry other 4xx errors without changing the request.

Two responses can come from the hosting platform instead of the API, with a body that is not our JSON: 413 when the upload is larger than about 4.5 MB, and 504 in the rare case a request runs out of time. Check the status code before you parse the body.

Limits and retention

LimitValue
Upload size4 MB and 64 megapixels per photo
FormatsJPEG, PNG, HEIC
Request timeUsually 2 to 6 seconds, up to about 15 after idle periods. Set your client timeout to 60 seconds.
Rate limit30 requests per minute by default, across all endpoints. A 429 includes Retry-After.
Monthly quotaSet per client, counted on photos that pass. See Usage.
Download linkValid for 1 hour, or until the photo expires if that is sooner. Request a new one with Retrieve a photo.
RetentionA finished photo is available for 24 hours after processing and is erased from our storage within the following hour. The uploaded original is never stored.

Download the result and keep it in your own storage. Once a photo is erased we hold only the usage record: the time and the outcome, with no image and no measurements.

Test mode

A test key runs the real engine with the real rules, so the status, issues and measurements you see are exactly what a live key would return. The only difference is a visible TEST watermark across the finished image. Test photos are free and have their own monthly quota, so you can build and run your automated tests without spending anything.

Switching to production is a one-line change: replace the test key with your live key.

Getting access

The API is in private beta. Keys are issued by our team: you receive a client ID, a test key to build with and, once you are ready, a live key with a monthly quota that fits your volume. Paid plans will follow the beta.

To ask for access, write to developers@visapicture.com with your company name and the number of photos you expect each month.

The full machine-readable description is available as an OpenAPI 3.1 document, which you can import into Postman or use to generate a client.