# `POST /v1/jobs/{job_id}/upscale`: upscale a job

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

> POST /v1/jobs/{job_id}/upscale: upscale a finished image or video job. Parameters, body fields, example request and response, and errors.

**`POST /v1/jobs/{job_id}/upscale` is the endpoint to upscale a finished image or video job.** Makes a new job with a larger, sharper copy of a finished job's image or video. The source job is untouched; the new job's `source_job_id` names it. Videos keep their sound. Answers 202 with a queued job.

**At a glance**

- **Endpoint:** `POST /v1/jobs/{job_id}/upscale`
- **Base URL:** `https://bobabanana.com/api/v1`
- **Auth:** `Authorization: Bearer bb_...`
- **Success:** `202` (or `200` with `dry_run: true`)
- **Safe to retry:** yes, with an `Idempotency-Key` header
- **Guide:** [Upscale](https://bobabanana.com/docs/api/upscale/)

## 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_...`) |
| `Content-Type` | yes | `application/json` |
| `idempotency-key` | no | Any unique string up to 255 characters (a UUID is ideal). A retry with the same key and the same body within 24 hours returns the first job instead of making a second one; the same key with a different body is 422 idempotency_key_reused. |

### Body (JSON)

Every field is optional; the body may be left out.

| Field | Type | Required | Default | Limits | Description |
|---|---|---|---|---|---|


## Example request

Twice the size:

```bash
curl https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3/upscale \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "factor": 2
  }'
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3/upscale",
    headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "factor": 2,
    },
    timeout=60,
)
r.raise_for_status()
print(r.json())
```

```javascript
const res = await fetch("https://bobabanana.com/api/v1/jobs/x_8d21c0f4a9b3/upscale", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    "factor": 2
  }),
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
console.log(await res.json());
```

### More request bodies


**A 480p video to 1080p, with a cost cap** (`video_1080p`):

```json
{
  "factor": 2.25,
  "max_credits": 60
}
```

## Response

**200** ([DryRunEstimate](https://bobabanana.com/docs/api/reference/objects/#dry-run-estimate)): dry_run: true: the price of this request. Nothing is queued, held or stored.

```json
{
  "object": "estimate",
  "dry_run": true,
  "type": "video_upscale",
  "credits_estimate": 36,
  "credits_available": 950,
  "enough_credits": true,
  "billing_mode": "credits"
}
```

**202** ([Job](https://bobabanana.com/docs/api/reference/objects/#job)): Successful Response

```json
{
  "id": "x_0c9e4a7d2b85",
  "object": "job",
  "type": "video_upscale",
  "status": "queued",
  "created": 1764950400,
  "input": {
    "source_job_id": "x_5b70e2d9c4a1",
    "factor": 2.25
  },
  "output": {},
  "eta_seconds": 240,
  "poll_after_seconds": 30,
  "cost": {
    "credits_estimate": 36,
    "credits_charged": 0,
    "credits_released": 0,
    "status": "held"
  },
  "source_job_id": "x_5b70e2d9c4a1",
  "output_size": {
    "width": 1920,
    "height": 1080
  }
}
```

## 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 | [`bad_request`](https://bobabanana.com/docs/api/errors/#bad_request) | The `Content-Length` header is not a number. |
| 400 | [`cost_above_max`](https://bobabanana.com/docs/api/errors/#cost_above_max) | The job would cost more than `max_credits`. `credits_estimate` gives the price. |
| 400 | [`fetch_timeout`](https://bobabanana.com/docs/api/errors/#fetch_timeout) | Downloading a URL input took too long. |
| 400 | [`invalid_metadata`](https://bobabanana.com/docs/api/errors/#invalid_metadata) | `metadata` has more than 16 keys, a key over 40 characters or a value over 500. |
| 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. |
| 400 | [`invalid_url`](https://bobabanana.com/docs/api/errors/#invalid_url) | The URL is not `https://`, its host cannot be found, or it points to a private address. |
| 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. |
| 402 | [`insufficient_credits`](https://bobabanana.com/docs/api/errors/#insufficient_credits) | The workspace's available credits are less than the job's estimate. `required` and `available` give both numbers. |
| 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). |
| 409 | [`idempotency_in_progress`](https://bobabanana.com/docs/api/errors/#idempotency_in_progress) | A request with this `Idempotency-Key` is still being processed. `Retry-After`: 5 s. |
| 413 | [`too_large`](https://bobabanana.com/docs/api/errors/#too_large) | The request body is over the limit for this endpoint (JSON bodies 100 MB, uploads 64 MB). |
| 422 | [`idempotency_key_reused`](https://bobabanana.com/docs/api/errors/#idempotency_key_reused) | This `Idempotency-Key` was already used with a different request. |
| 422 | [`invalid_json`](https://bobabanana.com/docs/api/errors/#invalid_json) | The body is not valid JSON. |
| 429 | [`daily_limit_reached`](https://bobabanana.com/docs/api/errors/#daily_limit_reached) | This key has used its jobs for the last 24 hours. `Retry-After`: 3600 s. |
| 429 | [`queue_full`](https://bobabanana.com/docs/api/errors/#queue_full) | The workspace has too many steps waiting. |
| 429 | [`too_many_active_jobs`](https://bobabanana.com/docs/api/errors/#too_many_active_jobs) | This key already has its maximum of unfinished jobs. `Retry-After`: 30 s. |
| 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. |
| 503 | [`engine_unavailable`](https://bobabanana.com/docs/api/errors/#engine_unavailable) | This kind of generation is not available right now. `Retry-After`: 300 s. |
| 503 | [`maintenance`](https://bobabanana.com/docs/api/errors/#maintenance) | BobaBanana is being updated; changes are paused for a few minutes. Reads still work. `Retry-After` is set. |

## Related

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