# `GET /v1/jobs/{job_id}`: get or wait for a job

Source: https://bobabanana.com/docs/api/reference/get-job/

> GET /v1/jobs/{job_id}: get a job, or wait for it to finish. Parameters, example request and response, and errors. BobaBanana API reference with curl, Python...

**`GET /v1/jobs/{job_id}` is the endpoint to get a job, or wait for it to finish.** The job's status, inputs, cost and, once `succeeded`, signed result links in `output`. With `?wait=30` the call returns as soon as the job finishes, or after 30 seconds with the job as it is: the cheapest way to wait.

**At a glance**

- **Endpoint:** `GET /v1/jobs/{job_id}`
- **Base URL:** `https://bobabanana.com/api/v1`
- **Auth:** `Authorization: Bearer bb_...`
- **Success:** `200`
- **Safe to retry:** yes, a read
- **Guide:** [Jobs](https://bobabanana.com/docs/api/jobs/)

## Request

### Path parameters

| Name | Type | Required | Default | Limits | Description |
|---|---|---|---|---|---|
| `job_id` | string | yes |  |  | The job's id, e.g. x_8d21c0f4a9b3. |

### Query parameters

| Name | Type | Required | Default | Limits | Description |
|---|---|---|---|---|---|
| `wait` | integer | no | `0` | 0 to 30 | Seconds to wait for the job to finish before answering (0 to 30). The call returns as soon as the job finishes. |

### Headers

| Header | Required | Description |
|---|---|---|
| `Authorization` | yes | `Bearer bb_...`: your API key (or send `X-API-Key: bb_...`) |

## Example request

```bash
curl https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3?wait=30 \
  -H "Authorization: Bearer $BOBABANANA_API_KEY"
```

```python
import os

import requests

r = requests.get(
    "https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3?wait=30",
    headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}"},
    timeout=60,
)
r.raise_for_status()
print(r.json())
```

```javascript
const res = await fetch("https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3?wait=30", {
  method: "GET",
  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](https://bobabanana.com/docs/api/reference/objects/#job)): Successful Response

```json
{
  "id": "x_8d21c0f4a9b3",
  "object": "job",
  "type": "image",
  "status": "succeeded",
  "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": {
    "image": {
      "url": "https://bobabanana.com/api/v1/files/content/...",
      "content_type": "image/png"
    }
  },
  "cost": {
    "credits_estimate": 4,
    "credits_charged": 4,
    "credits_released": 0,
    "status": "charged"
  }
}
```

## Errors

Errors use the [error object](https://bobabanana.com/docs/api/reference/objects/#error). The codes this endpoint can return (what to do about each is in [Error codes](https://bobabanana.com/docs/api/errors/)):

| Status | Code | Meaning |
|---|---|---|
| 400 | [`invalid_request`](https://bobabanana.com/docs/api/errors/#invalid_request) | A field is missing, has the wrong type or breaks a rule. `param` names the field. Type and range problems found while reading the body are 422 with the same code. |
| 401 | [`invalid_api_key`](https://bobabanana.com/docs/api/errors/#invalid_api_key) | The key is wrong, revoked or belongs to no workspace. |
| 401 | [`missing_api_key`](https://bobabanana.com/docs/api/errors/#missing_api_key) | No API key was sent. |
| 403 | [`workspace_suspended`](https://bobabanana.com/docs/api/errors/#workspace_suspended) | The workspace that owns the key is suspended. |
| 404 | [`job_not_found`](https://bobabanana.com/docs/api/errors/#job_not_found) | No job with this id for this API key (another key's jobs are invisible). |
| 429 | [`too_many_attempts`](https://bobabanana.com/docs/api/errors/#too_many_attempts) | Too many requests with wrong keys came from your address. `Retry-After` is set. |
| 500 | [`internal_error`](https://bobabanana.com/docs/api/errors/#internal_error) | Something went wrong on our side. |

## Related

- Guide: [Jobs](https://bobabanana.com/docs/api/jobs/)
- [All endpoints](https://bobabanana.com/docs/api/reference/)
- [Objects](https://bobabanana.com/docs/api/reference/objects/)
- [Error codes](https://bobabanana.com/docs/api/errors/)
