Callbacks
Instead of polling for status, pass a callback_url (HTTPS) in the /edit body.
When the edit finishes, Imagen POSTs the result to that URL, so you don’t have to
poll. This works for both the profile-based flow
and Smart Editing. Add callback_url to the
same edit request you already send.
Polling is fine for scripts and testing, but a callback is the production-friendly option. You find out the moment editing finishes instead of waiting on a poll interval.
What Imagen sends
When editing finishes, Imagen sends a plain HTTP POST to your callback_url with
the project’s project_uuid, its status, and the action that completed.
Possible statuses are Completed and Failed.
{
"project_uuid": "65f3a1c2d4e5f6a7b8c9d0e1",
"status": "Completed",
"action": "edit"
}On Completed, continue to download (or, for the profile-based flow with
export: true, the export runs automatically). On Failed, contact your Imagen service manager.
Securing your endpoint
Imagen sends a plain HTTP POST with no authentication header and no HMAC signature. Anyone who learns your callback URL could POST to it. Secure your endpoint by embedding an unguessable token in the URL path, and reject any request that doesn’t include the correct token.
Generate a long random token and put it in the path of the callback_url you
send to Imagen:
https://yourdomain.com/webhook/your-secret-token-hereWhen a request arrives, check that the path contains your token before trusting it. Reject anything that doesn’t match. The token only appears in the path you registered, so it stays out of logs that record bodies. An attacker can’t forge it without knowing it.