POST /v1/jobs/{job_id}/cancel: cancel a job
POST /v1/jobs/{job_id}/cancel is the endpoint to cancel a queued or running job. Stops the job's unfinished steps and releases their credits. Steps already delivered stay charged. Canceling a finished job changes nothing and returns it.
At a glance
- Endpoint
POST /v1/jobs/{job_id}/cancel- Base URL
https://bobabanana.com/api/v1- Auth
Authorization: Bearer bb_...- Success
200- Safe to retry
- no body to repeat; repeating it is harmless
- Guide
- Jobs
Request#
Path parameters#
| Name | Type | Required | Default | Limits | Description |
|---|---|---|---|---|---|
job_id |
string | yes | The job's id, e.g. x_8d21c0f4a9b3. |
Headers#
| Header | Required | Description |
|---|---|---|
Authorization |
yes | Bearer bb_...: your API key (or send X-API-Key: bb_...) |
Example request#
curl -X POST https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3/cancel \
-H "Authorization: Bearer $BOBABANANA_API_KEY"
import os
import requests
r = requests.post(
"https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3/cancel",
headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}"},
timeout=60,
)
r.raise_for_status()
print(r.json())
const res = await fetch("https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3/cancel", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`,
},
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
console.log(await res.json());
Response#
200 (Job): Successful Response
{
"id": "x_8d21c0f4a9b3",
"object": "job",
"type": "image",
"status": "canceled",
"created": 1764950400,
"finished": 1764950472,
"input": {
"reference_images": [
{
"file_id": "file_3f9c2a1b7d4e",
"label": "a mustard yellow three-seat sofa"
}
],
"assets": [],
"prompt": "the sofa in a sunlit loft, morning light, wide shot",
"aspect_ratio": "16:9"
},
"output": {},
"error": {
"code": "canceled",
"message": "The job was canceled."
},
"cost": {
"credits_estimate": 4,
"credits_charged": 0,
"credits_released": 4,
"status": "released"
}
}
Errors#
Errors use the error object. The codes this endpoint can return (what to do about each is in Error codes):
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_request |
The Content-Length header is not a number. |
| 401 | invalid_api_key |
The key is wrong, revoked or belongs to no workspace. |
| 401 | missing_api_key |
No API key was sent. |
| 403 | workspace_suspended |
The workspace that owns the key is suspended. |
| 404 | job_not_found |
No job with this id for this API key (another key's jobs are invisible). |
| 413 | too_large |
The request body is over the limit for this endpoint (JSON bodies 100 MB, uploads 64 MB). |
| 429 | too_many_attempts |
Too many requests with wrong keys came from your address. Retry-After is set. |
| 500 | internal_error |
Something went wrong on our side. |
| 503 | maintenance |
BobaBanana is being updated; changes are paused for a few minutes. Reads still work. Retry-After is set. |
Related#
- Guide: Jobs
- All endpoints
- Objects
- Error codes