Passport Photo API

Turn any photo into a compliant passport or visa photo. Face detection, automatic framing to each government's head-size and eye-line rules, and a correctly sized file at 300 DPI.

Quick start

No sign-up, no API key. Send a front-facing photo and a document type, get back a correctly framed photo.

curl -X POST https://2x2passportphoto.com/api/v1/photos \
  -H "Content-Type: application/json" \
  -d '{
    "image": "<base64-encoded photo>",
    "document": "us-passport"
  }'

Base URL https://2x2passportphoto.com · OpenAPI spec /api/v1/openapi.json

What is free, what costs money

Free: face detection, cropping, resizing and the finished photo with a watermark across it. Everything the API returns is free.

$9.99 one-time: the same photo without the watermark, print-ready. The response includes a checkout.url you can hand to the user; they pay there and download it. There is no subscription and no per-seat fee.

You are never charged for calling the API. The payment is between the end user and us, at the point they want the clean file.

Rate limits

  • POST /api/v1/photos — 10 requests per minute per IP.
  • Read endpoints — 60 requests per minute per IP.

Exceeding a limit returns 429 with a Retry-After header. Need more? Get in touch.

Endpoints

POST/api/v1/photos

Creates a compliant photo. The source should be front-facing with the whole head visible and even lighting.

{
  "image": "<base64, or a data:image/jpeg;base64,... URL>",
  "document": "us-passport",
  "email": "optional@example.com"
}

Response

{
  "id": "api_mh8x2k_9fjs02la",
  "document": {
    "id": "us-passport",
    "name": "US Passport",
    "output": { "width": 600, "height": 600, "dpi": 300,
                "inches": "2×2", "mm": "51×51" }
  },
  "photo": {
    "watermarked": true,
    "width": 600, "height": 600, "dpi": 300,
    "data": "data:image/jpeg;base64,..."
  },
  "checkout": {
    "url": "https://2x2passportphoto.com/result/api_mh8x2k_9fjs02la",
    "price": { "amount": 9.99, "currency": "USD" },
    "description": "One-time payment for the watermark-free file."
  }
}

Max image size 10MB. Images larger than ~1500px on the long edge are downscaled before detection, so sending a 12MP phone photo only costs you upload time.

GET/api/v1/photos/{id}

Whether that photo has been purchased yet. Returns paid, a previewUrl (watermarked, always available) and a downloadUrl once it is paid for.

GET/api/v1/documents

All 41 supported document types with the exact pixel dimensions each one returns.

GET/api/v1/documents/{id}

One document in full: output size, the framing ratios we target, and the issuing authority's rules on background, glasses, expression and clothing — plus the reasons photos of that type get rejected.

Errors

Every error returns the same shape. Branch on code; hint says what to do about it.

{
  "error": {
    "code": "no_face_detected",
    "message": "No face detected. Use a front-facing photo where the whole head is visible.",
    "hint": "Use a straight-on photo with the whole head visible and even lighting."
  }
}
CodeHTTPMeaning
invalid_request400A required field is missing or malformed
unsupported_document400Unknown document id — check /api/v1/documents
image_too_large413Image exceeds 10MB
invalid_image422The bytes could not be decoded as an image
no_face_detected422No face found in the photo
rate_limited429Too many requests — see Retry-After
not_found404Unknown photo or document id
service_unavailable503Face detection temporarily down

Supported documents (41)

Pass any id below as the document field. Aliases resolve to the same spec.

idNameOutputSize
australia-passportAustralia Passport413×53135×45 mm
australia-visaAustralia Visa413×53135×45 mm
bangladesh-passportBangladesh Passport413×53135×45 mm
brazil-visaBrazil Visa590×82650×70 mm
canada-passportCanada Passport590×82650×70 mm
canada-visaCanada Visa590×82650×70 mm
china-passportChina Passport390×56733×48 mm
china-visaChina Visa390×56733×48 mm
generic-35x45Standard 35×45mm413×53135×45 mm
hongkong-passportHong Kong Passport472×59140×50 mm
hongkong-visaHong Kong Visa472×59140×50 mm
india-passportIndia Passport600×60051×51 mm
india-visaIndia Visa413×53135×45 mm
indonesia-visaIndonesia Visa413×53135×45 mm
japan-passportJapan Passport413×53135×45 mm
japan-visaJapan Visa413×53135×45 mm
malaysia-passportMalaysia Passport413×59135×50 mm
malaysia-visaMalaysia Visa413×59135×50 mm
mexico-visaMexico Visa413×53135×45 mm
nz-passportNew Zealand Passport413×53135×45 mm
nz-visaNew Zealand Visa413×53135×45 mm
pakistan-nadraPakistan NADRA413×53135×45 mm
philippines-passportPhilippines Passport413×53135×45 mm
russia-visaRussia Visa413×53135×45 mm
saudi-visaSaudi Arabia Visa413×53135×45 mm
schengen-visaSchengen Visa413×53135×45 mm
singapore-passportSingapore Passport413×53135×45 mm
singapore-visaSingapore Visa413×53135×45 mm
south-korea-visaSouth Korea Visa413×53135×45 mm
taiwan-passportTaiwan Passport413×53135×45 mm
taiwan-visaTaiwan Visa413×53135×45 mm
thailand-visaThailand Visa413×53135×45 mm
turkey-visaTurkey Visa591×70950×60 mm
uae-passportUAE Passport472×70940×60 mm
uae-visaUAE Visa413×53135×45 mm
uk-passportUK Passport413×53135×45 mm
uk-visaUK Visa413×53135×45 mm
us-dv-lotteryUS DV Lottery600×60051×51 mm
us-passportUS Passport600×60051×51 mm
us-visaUS Visa600×60051×51 mm
vietnam-visaVietnam Visa472×70940×60 mm

Photos and privacy

A photo you send is processed and stored against the order id returned to you, so the user can come back and buy the clean file. It is not used for training and is not shared. Tell your users their photo is being sent to us to be processed.

Questions

Higher limits, a different document type, or something not working? Get in touch.