Hand it off through the API
Upload the photos, hand off the work, and get the result as JSON when it’s done.
Work handed off through the API is kept as a project, as it is on screen, and comes off the same balance.
-
Create a key
Sign in and create one under “API keys” in the left menu. Each person has one key per workspace.
Every request carries the key in an
Authorization: Bearerheader. The code below reads the key and the address from these two lines.export FLOW_API_KEY="<api_key>" export FLOW_URL="https://flow.unblanq.com" -
Upload photos
Call once for each photo, with
slotset tovehicle_images. Keep thedescriptorfrom each answer.It takes PNG, JPEG, WebP, HEIC and HEIF, up to 50MB a photo and 120 photos in one hand-off. An uploaded photo is kept until the
expires_atin itsdescriptor.curl -X POST \ "$FLOW_URL/v1/agencies/agency%3Aauto_damage_inspector/actions/analyze_vehicle_damage/uploads" \ -H "Authorization: Bearer $FLOW_API_KEY" \ -F "slot=vehicle_images" \ -F "file=@<file>" -
Hand it off
Put the
descriptorof each photo invehicle_imagesand send.idempotency_keyis your own reference for this request.Use
result.run_idfrom the answer to check the status, andresult.admission.target_idto find the result.Send the same
idempotency_keywith the sameinputsagain within 24 hours, and nothing new is handed off: you get the first answer back (deduplicated: true). If theinputsdiffer, it is refused with 409.curl -X POST \ "$FLOW_URL/v1/agencies/agency%3Aauto_damage_inspector/actions/analyze_vehicle_damage/runs" \ -H "Authorization: Bearer $FLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "vehicle_images": [<descriptor>, <descriptor>], "title": "Claim received Oct 22", "output_locale": "en-US" }, "idempotency_key": "request-001" }' -
Check the status
Call it every few seconds until the work ends. It has ended when
statusis one ofsucceeded,failed,cancelled.If it
failed,public_errorssays why.curl "$FLOW_URL/v1/runs/<run_id>" \ -H "Authorization: Bearer $FLOW_API_KEY" -
Get the result
The result is kept as a project. First find, in the list, the
record_idof the item whoserecord_keyis yourtarget_id. If it isn’t on the first page, put the answer’snext_cursorincursorfor the next page.Read with that
record_id, and the result comes back as JSON at once (result.record.content). Never put thetarget_idwhere therecord_idgoes.# 1. List: the record_id of the item whose record_key is your target_id curl -X POST \ "$FLOW_URL/v1/agencies/agency%3Aauto_damage_inspector/actions/list_auto_damage_projects/runs" \ -H "Authorization: Bearer $FLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{"inputs": {"relation": "owned", "limit": 50}}' # 2. Read: the result (JSON) is in result.record.content curl -X POST \ "$FLOW_URL/v1/agencies/agency%3Aauto_damage_inspector/actions/read_auto_damage_project/runs" \ -H "Authorization: Bearer $FLOW_API_KEY" \ -H "Content-Type: application/json" \ -d '{"inputs": {"record_id": "<record_id>"}}'
What you sendanalyze_vehicle_damage
| Name | Type | Required | Description |
|---|---|---|---|
output_locale |
stringminLength: 2 |
No | The language the result explanations are written in. If you don’t send it, they’re written in Korean (ko-KR). |
project_id |
stringminLength: 1 |
Yes | The project’s reference. |
request_id |
stringminLength: 1 |
Yes | This request’s reference. |
title |
string |
No | The name of the result project. Leave it empty and Flow names it. |
vehicle_images |
arrayminItems: 1 · maxItems: 120 · items: object |
Yes | Photos of the accident vehicle. Put in the descriptor from each upload. |
You don’t need to send project_id or request_id: Flow fills them in from idempotency_key.