Agent Wranglers

Reliability Recommended

Run long jobs asynchronously

When work can take longer than 10 seconds, accept it with 202 and a status resource the client can poll.

How to do it

Return 202 with a Location header pointing to a job, such as /jobs/job_31c. The job shows its state, such as queued, running, succeeded or failed. When done, it links to the result or holds a problem details object. Send Retry-After on the job to pace polling.

Example

POST /exports HTTP/1.1

HTTP/1.1 202 Accepted
Location: /jobs/job_31c
Retry-After: 5

How to check

Start an export in a test. The answer is 202 with Location, and polling ends in a completed state with a result link.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers api design playbook: https://agentwranglers.se/playbook/api-design/reliability/long-running-jobs.