For AI agents: this page is also available as Markdown at https://docs.refabric.com/api-reference/platform/jobs/cancel-a-job.md, and the index of every page is https://docs.refabric.com/llms.txt.
Platform API › Jobs
Cancel a job
202 with the job's lifecycle now — the request to stop was accepted; the job read says how it ended.
https://api.refabric.com/v1/jobs/{job_id}/cancelimport os
import requests
url = "https://api.refabric.com/v1/jobs/{job_id}/cancel"
headers = {"Authorization": f"Key {os.environ['REFABRIC_API_KEY']}"}
response = requests.put(url, headers=headers)
print(response.json()){
"job_id": "9b2f4c1d0e8a",
"lifecycle": "running"
}Authentication. A key with jobs:cancel: cancelling changes a running job.
Common use cases
- Stop a job you no longer need.
Conflicts. A job that already ended answers 202 and nothing changes.
See also
GET /v1/jobs/{job_id}
Authorization
Authorization: Key $REFABRIC_API_KEYScope: jobs:cancel
Parameters
Path parameters
- stringrequired
Header parameters
- stringoptional
The contract version you wrote against (a date). Absent: the current version.
format: date
- stringoptional
Your own id for this request; we answer it back under X-Client-Request-ID.
max length 128
Response
202 — Accepted: the work goes on after this answer; the body says where to follow it.
- stringrequired
The job you asked to stop.
Example:
9b2f4c1d0e8a - stringrequired
Where the job is now:
queuedorrunning— the job is asked to stop;terminal— the job had already ended and is left as it is. ReadGET /v1/jobs/{job_id}for how it ended (outcome).Values
queued— Accepted and waiting to start.running— Being made.terminal— Ended.outcomesays how.
Example:
running
- 401 — No valid API key was sent.
- 403 — Your key or your plan does not allow this.
- 404 — Nothing has this address.
- 429 — Too many requests: wait for the number of seconds in the Retry-After header.
- 500 — Something went wrong on our side; retry, and quote the request id if it keeps happening.