{"openapi":"3.1.0","info":{"title":"VisaPicture Photo Engine API","version":"1.0.0","description":"Turn a portrait into a compliant passport or visa photo. One call checks the photo against the official rules for a document, crops it to the exact size, replaces the background and returns the finished image with its measurements."},"servers":[{"url":"https://visapicture.com/api/v1"}],"security":[{"clientId":[],"subscriptionKey":[]}],"paths":{"/photos":{"post":{"operationId":"createPhoto","summary":"Process a photo","description":"Upload one portrait and name the document it is for. The call waits for the engine, usually 2 to 6 seconds and up to about 15 on a cold start, and returns the verdict.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"A unique string of up to 128 printable ASCII characters without spaces. Repeating a request with the same key returns the first result instead of processing and counting the photo again. Keys are separate for test and live mode, and a key whose request ended in an error can be reused.","schema":{"type":"string","maxLength":128,"pattern":"^[\\x21-\\x7e]{1,128}$"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file","document"],"properties":{"file":{"type":"string","format":"binary","description":"The portrait. JPEG, PNG or HEIC, up to 4 MB."},"document":{"type":"string","description":"Document id from GET /documents, for example \"us-passport\".","example":"us-passport"}}}}}},"responses":{"200":{"description":"Replay of an earlier request with the same Idempotency-Key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Photo"}}}},"201":{"description":"The photo was processed. Check \"status\" for the verdict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Photo"}}}},"400":{"description":"A field is missing or malformed, or the document is unknown.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid client ID or subscription key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The API client is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The upload is larger than 4 MB or 64 megapixels.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The file is not a readable JPEG, PNG or HEIC image.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or monthly quota exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"The engine failed. Not charged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/photos/{id}":{"get":{"operationId":"getPhoto","summary":"Retrieve a photo","description":"Returns a processed photo with a fresh download link. Photos stop being available 24 hours after processing.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The photo.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Photo"}}}},"401":{"description":"Missing or invalid client ID or subscription key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The API client is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No photo with this id, or it has been deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or monthly quota exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents":{"get":{"operationId":"listDocuments","summary":"List documents","description":"Every document type the engine can produce, with the official size and head-height rules it enforces.","responses":{"200":{"description":"All supported documents.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Document"}}}}}}},"401":{"description":"Missing or invalid client ID or subscription key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The API client is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or monthly quota exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents/{id}":{"get":{"operationId":"getDocument","summary":"Retrieve a document","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"example":"uk-passport"}],"responses":{"200":{"description":"The document.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"401":{"description":"Missing or invalid client ID or subscription key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The API client is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No document with this id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or monthly quota exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/usage":{"get":{"operationId":"getUsage","summary":"Check usage","description":"Photos passed this calendar month (UTC) and the limits for your client, for live and test mode.","responses":{"200":{"description":"Usage for the current month.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Usage"}}}},"401":{"description":"Missing or invalid client ID or subscription key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The API client is disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or monthly quota exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"clientId":{"type":"apiKey","in":"header","name":"X-Client-Id","description":"Your public client ID, \"vp_cid_…\"."},"subscriptionKey":{"type":"http","scheme":"bearer","description":"Your secret subscription key, \"vp_live_sk_…\" or \"vp_test_sk_…\"."}},"schemas":{"Photo":{"type":"object","properties":{"object":{"const":"photo"},"id":{"type":"string","format":"uuid"},"mode":{"enum":["live","test"]},"document":{"type":"string","description":"Document id the photo was made for."},"status":{"enum":["passed","failed","processing","error"],"description":"\"passed\": the result is ready. \"failed\": the photo breaks a rule; see issues. A POST only ever returns these two. GET can also show \"processing\" (still running) or \"error\" (the request failed; see error_code)."},"issues":{"type":"array","items":{"$ref":"#/components/schemas/Issue"}},"measurements":{"type":["object","null"],"description":"Measured on the finished photo, in millimetres at print size. Null when no face could be measured.","properties":{"head_height_mm":{"type":"number","description":"Chin to top of head."},"eye_from_bottom_mm":{"type":"number"},"eye_from_top_mm":{"type":"number"},"top_margin_mm":{"type":"number","description":"Space above the head."},"chin_to_bottom_mm":{"type":"number"},"center_offset_mm":{"type":"number","description":"Horizontal offset of the face from the centre line."},"upscale":{"type":"number","description":"Enlargement of source pixels. Above 1.0 the photo is softer than ideal."}}},"ranges":{"type":["object","null"],"description":"Each official rule with its allowed range, the measured value and whether it passed."},"output":{"type":["object","null"],"properties":{"width_px":{"type":"integer"},"height_px":{"type":"integer"},"dpi":{"type":"integer"}}},"source":{"type":["object","null"],"properties":{"width_px":{"type":"integer"},"height_px":{"type":"integer"}}},"result":{"type":["object","null"],"description":"The finished photo. Null unless status is \"passed\".","properties":{"url":{"type":"string","format":"uri","description":"Signed download link, valid for one hour or until the photo expires, whichever is sooner."},"url_expires_at":{"type":"string","format":"date-time"},"content_type":{"const":"image/jpeg"}}},"error_code":{"type":["string","null"],"description":"Set when status is \"error\"."},"processing_ms":{"type":["integer","null"]},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":"string","format":"date-time","description":"When the photo stops being available. Its image is erased from storage within the following hour."}}},"Issue":{"type":"object","properties":{"code":{"type":"string","example":"head_tilted"},"severity":{"enum":["fail","warn"]},"message":{"type":"string","description":"Plain-language advice you can show to your user."}}},"Document":{"type":"object","properties":{"object":{"const":"document"},"id":{"type":"string","example":"us-passport"},"country_code":{"type":"string"},"country":{"type":"string"},"type":{"enum":["passport","visa","id"]},"name":{"type":"string"},"size_mm":{"type":"object","properties":{"width":{"type":"number"},"height":{"type":"number"}}},"dpi":{"type":"integer"},"head_height_mm":{"type":"object","properties":{"min":{"type":"number"},"max":{"type":"number"}}},"eye_from_bottom_mm":{"type":["object","null"]},"background":{"type":"object","properties":{"label":{"type":"string"},"hex":{"type":"string"}}},"rules":{"type":"array","items":{"type":"string"}},"source_url":{"type":"string","format":"uri"},"verified_at":{"type":"string","format":"date"}}},"Usage":{"type":"object","properties":{"object":{"const":"usage"},"client_id":{"type":"string"},"period_start":{"type":"string","format":"date-time"},"period_end":{"type":"string","format":"date-time"},"live":{"$ref":"#/components/schemas/UsageMode"},"test":{"$ref":"#/components/schemas/UsageMode"},"rate_limit_per_minute":{"type":"integer"}}},"UsageMode":{"type":"object","properties":{"photos_passed":{"type":"integer"},"monthly_quota":{"type":"integer"},"remaining":{"type":"integer"}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"invalid_credentials"},"message":{"type":"string"},"request_id":{"type":"string","description":"Quote this when you contact support."}}}}}}}}