Skip to content

Fix Passport Photo API ​

Product overview: Fix Passport Photo API.

Fix an existing passport or ID photo so it meets official requirements. The API evaluates the whole image, corrects only the problems it finds, and leaves already suitable regions unchanged.

This endpoint is for portrait normalization, not beautification. Its highest priority is keeping the person recognizable as the same real individual.

United States and United Kingdom passport rules require an unedited photograph. Do not use this API to correct those documents. Detect the problem and ask for a new capture. Other issuers set their own rules.

The problem it solves ​

Real users rarely submit a perfectly controlled studio photo. A single image may combine a turned head, a tilted posture, visible teeth, glasses, hard shadows, compression artifacts, or a shoulder that was cut off during an earlier background-removal step. Fixing these issues manually is slow, and chaining separate edits can introduce inconsistent results.

POST /v2/aiEdit applies the necessary corrections together while protecting details that should not change: identity, natural skin texture, age, hair, clothing, background, crop, and overall photographic character.

Use it before specification-based processing

This endpoint improves the portrait itself. It does not select a country-specific document size or guarantee acceptance by an issuing authority. For sizing, background processing, validation, and issue codes, pass the normalized result to the Passport Photo API.

What the API corrects ​

Input problemCorrectionWhat remains protected
Head turned or tilted; uneven postureMakes the face naturally front-facing, keeps the head upright, and levels the shoulders when neededRecognizable facial structure, natural anatomy, framing, and scale
Broad smile, open mouth, or visible teethProduces a calm, natural, closed-mouth expressionCharacteristic lip shape, eye shape, and the person's likeness
Eyeglasses, sunglasses, or unsuitable novelty headwearRemoves the obstruction and conservatively reconstructs only hidden facial regionsHairline, ears, head shape, ordinary jewelry, and religious or cultural head coverings that do not obscure the face
Harsh shadows, color casts, overexposure, or underexposureBalances facial light and color while preserving real skin tonePores, age, complexion, and natural texture—without whitening or makeup
Blur, noise, compression, or weak local contrastRestores only the clarity needed for a usable ID-style portraitReal detail—without invented features, aggressive sharpening, or plastic skin
A shoulder or garment ends at an unnatural internal edgeReconstructs only the missing continuation of the existing clothing and silhouetteBody proportions, clothing, lighting, background, and the existing crop

If a region already meets these requirements, the API is instructed to leave it unchanged.

Before and after ​

These synthetic examples illustrate the kinds of corrections the endpoint is designed to make. They are not real customers or identity documents, and individual results vary with the input image.

Before · turned head and visible teethSynthetic portrait before editing, with the subject's head turned and teeth visible in a broad smile
After · front-facing and neutralSynthetic portrait after editing, with the same subject facing forward with a neutral closed-mouth expression
Pose and expression. The face is brought toward the camera and the expression is neutralized while the subject's age, hair, skin texture, clothing, and background remain consistent.
Before · glasses and hard side lightSynthetic portrait before editing, with prescription glasses and strong uneven lighting across the face
After · clear face and even lightSynthetic portrait after editing, with the same subject's glasses removed and facial lighting balanced
Face visibility and lighting. The glasses are removed, only the covered facial areas are reconstructed, and the strong light imbalance is corrected without changing the background or adding glamour retouching.
Before · eyes hidden by dark glassesSynthetic portrait before editing, with the subject's eyes and eyebrows obscured by dark glasses
After · obstruction removedSynthetic portrait after editing, with the same subject's dark glasses removed and the obscured eye area reconstructed
Dark-glasses removal. The frames and lenses are removed and only the hidden eye and eyebrow region is reconstructed. The pose, expression, face shape, hair, clothing, and background remain consistent.
Before · blur, noise, and compressionSynthetic portrait before editing, with moderate focus softness, visible image noise, and compression artifacts
After · conservative quality recoverySynthetic portrait after editing, with the same subject rendered more clearly while retaining natural age and skin texture
Recoverable image quality. Noise, compression artifacts, softness, and weak local contrast are reduced without aggressive sharpening, invented facial detail, or artificial skin smoothing.
Before · shoulder cut off inside frameSynthetic portrait before editing, with one sweater shoulder ending at an unnatural straight edge inside the image
After · silhouette reconstructedSynthetic portrait after editing, with the same subject's missing shoulder and sweater area naturally reconstructed
Incomplete silhouette. Only the missing shoulder and sweater continuation are repaired. A shoulder that already ends naturally—or continues through the image boundary—is not changed.

Identity-preserving boundaries ​

The endpoint is designed to preserve facial proportions, face shape, eyes, eyebrows, nose, lips, jawline, cheeks, ears, skin tone and texture, hairstyle, hairline, age, and distinctive characteristics.

It does not intentionally:

  • slim, reshape, rejuvenate, beautify, or cosmetically retouch the person;
  • change ethnicity or gender presentation;
  • whiten skin, add makeup, or create glamour lighting;
  • replace the background or clothing;
  • add objects or alter regions that are already suitable;
  • invent fine facial detail when the source does not contain enough information.

API endpoint ​

The Fix Passport Photo API uses the request path below. Send the request to the region where your account and data processing are configured:

  • https://api-us.idphotoapp.com — US region
  • https://api-eu.idphotoapp.com — EU region
  • Other regional deployments are available on request
http
POST /v2/aiEdit

Request ​

Send exactly one input: imageBase64 or photoUuid.

FieldTypeRequiredDescription
apiKeystringYesYour API key. Send requests from your server; do not expose credentials in browser code.
apiSecretstringYesYour API secret.
imageBase64stringOne of the twoBase64-encoded JPEG or PNG, with or without a data URI prefix, up to 20 MB. Use a single-person portrait.
photoUuidstringOne of the twoThe photoUuid of an ID photo that your account made with the Passport Photo API. That photo is used as the input, so you do not need to resend the image.
specCodestringNoA specification code, for example uk-passport. When set, previewOutput also shows the specification's measurement guides. It does not resize or crop output. See Find a photo specification.
outputFormatstringNoJPEG or PNG. When omitted, the input image format is used.
outputTypestringNoIMAGE_BASE64 (default) returns the image as Base64. URL stores the image and returns a link that is valid for 2 days.
jsonc
{
  "apiKey": "your-api-key",
  "apiSecret": "your-api-secret",
  "imageBase64": "data:image/jpeg;base64,...",
  "outputFormat": "JPEG",
  "outputType": "IMAGE_BASE64"
}

To edit an ID photo you already made, pass its photoUuid instead of the image:

jsonc
{
  "apiKey": "your-api-key",
  "apiSecret": "your-api-secret",
  "photoUuid": "your-photo-uuid",
  "specCode": "uk-passport",
  "outputType": "URL"
}

Response ​

FieldTypeDescription
outputstringThe edited image. Base64 without a data URI prefix for IMAGE_BASE64, or a link valid for 2 days for URL.
previewOutputstringThe same edited image with a Preview watermark, in the same form as output. Show it to your user before they pay or confirm. When specCode is set it also shows the specification's measurement guides.
widthintegerOutput width in pixels.
heightintegerOutput height in pixels.
photoUuidstringReturned only when outputType is URL. Identifies the stored result.
jsonc
{
  "output": "/9j/4AAQSkZJRgABAQ...",
  "previewOutput": "/9j/4AAQSkZJRgABAQ...",
  "width": 600,
  "height": 800
}

To display a Base64 result as a JPEG in an application, prepend data:image/jpeg;base64, to the value. For storage or further API processing, decode it as binary image data instead. Download URL results within 2 days.

Errors ​

Errors return a JSON body with a detail field that describes the problem.

StatusMeaning
400The image cannot be used: no face, more than one face, not a JPEG or PNG, or too large.
402Your account cannot make this call right now. Contact support@idphoto.ai.
403The credentials are invalid, or the account cannot use this endpoint.
404The photoUuid or specCode was not found.
422The request is invalid (for example, both or neither of imageBase64 and photoUuid were sent), or the photo could not be edited.
502, 503, 504Temporary service problem or timeout. Try again later.

Integration guidance ​

  • Use a clear, single-person portrait and keep the complete image payload on your server. If you already made the ID photo with this account, send its photoUuid instead of the image.
  • Set a client timeout of about 200 seconds. Edits can take a while to finish.
  • Do not log credentials or full Base64 values.
  • Show previewOutput to end users before they pay, and deliver output only after they confirm.
  • Treat authentication failures, 402, invalid image data, and processing failures separately from a successful edit.
  • Review the edited portrait before passing it to the Passport Photo API. A successful edit does not by itself select or validate a document specification.