Docs

Job callbacks

Give a long-running job an inbox URL and wait for it to call back instead of polling.

Many APIs that do slow work (video rendering, batch inference, transcription, CI pipelines, document processing) accept a callback URL and post to it when they finish. An inbox lets an agent use those callbacks instead of polling.

The pattern#

  1. Create an inbox with a lifetime longer than the job could take.
  2. Start the job with callback_url (or whatever the API calls it) set to <url>/jobs/<job-id>.
  3. Call wait_for_request with path_prefix: "/jobs/<job-id>", and call it again whenever it times out.
wait_for_request
{ "inbox_key": "porch_sk_…", "path_prefix": "/jobs/render-42", "timeout_seconds": 300 }

Each call waits up to 5 minutes, and because positions are saved, a callback that lands between calls is returned by the next one.

Several jobs at once#

Give each job its own path. Waiting on /jobs/render-42 never consumes the callback for /jobs/render-43; each filter keeps its own position. To take whichever finishes first, wait with path_prefix: "/jobs/" instead.

Long jobs#

Answering the job#

Some APIs expect a particular response to the callback, for example 202 Accepted or a JSON acknowledgement. Set it before starting the job:

set_response
{ "inbox_key": "porch_sk_…", "path_prefix": "/jobs/", "status": 202, "body": "{\"received\":true}", "content_type": "application/json" }