# Upscale image

> Beta. Queues an enlargement of an image and returns the task. `effort` picks the upscaler and sets a flat price; `size` never changes it. The result can be at most 4096x4096 pixels, so a larger request fails with `OUTPUT_TOO_LARGE` and is not charged.

`POST /image/upscale`

**Auth:** API key or OAuth token

## Request body

- `effort` (required, string) — Upscaler to run, and the price. 'low' is fast and sharp; 'high' rebuilds fine detail such as small text and faces. One of: `"high"`, `"low"`.
- `size` (required, object | string) — How much to enlarge each side. The upscaled image can be at most 4096x4096 pixels. One of: `"2x"`, `"4x"`.
  - `factor` (required, number) — One of: `2`, `4`.
  - `type` (required, "scale")
- `url` (required, string)
- `access` (object) — Controls whether the create-task response should include a short-lived Public Access Token. That token can be passed to browser or client-side code for polling task status and task images without exposing your API key.
  - `pat` (required, object)
    - `enabled` (boolean) — Default `true`.
- `destination` (string) — ≥ 1 characters, ≤ 64 characters. Example `"bunny-prod"`.
- `metadata` (object)
- `output` (object)
  - `format` (string) — One of: `"jpg"`, `"png"`, `"webp"`.
- `webhook` (object)
  - `custom` (object[]) — ≥ 1 items, ≤ 5 items.
    - `url` (required, string)
  - `dashboard` (boolean) — Set to false to disable dashboard-managed webhooks for this task. Request-level custom webhooks are still sent.

## Response

### 201 — Image upscale task created

- `data` (required, object)
  - `estimatedCost` (required, string) — Estimated cost in USD reserved for this task. Failed images are refunded, so the final cost may be lower. Example `"0.03"`.
  - `taskId` (required, string) — Task ID Example `"tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.
  - `access` (object) — Returned when `access.pat.enabled` is true.
    - `publicAccessToken` (required, string) — Short-lived Public Access Token for polling task status and image results. This token is safe to return to frontend code and can be used instead of your API key for polling public task state. Example `"pat_eyJhbGciOi..."`.

```json
{
  "data": {
    "estimatedCost": "0.03",
    "taskId": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
    "access": {
      "publicAccessToken": "pat_eyJhbGciOi..."
    }
  }
}
```

### 400 — The request was rejected before anything was queued. `message` says what to change. A field that failed the schema is also listed in `issues`.

- `code` (required, string) — `VALIDATION_ERROR` for a body that failed validation, `INVALID_JSON` for one that is not JSON. One of: `"VALIDATION_ERROR"`, `"INVALID_JSON"`.
- `message` (required, string) — Every problem, in one sentence each.
- `issues` (object[]) — One entry per field that failed the schema.
  - `path` (required, (string | integer)[]) — Where the problem is, e.g. `["inputs", 0, "source"]`. Empty for the body as a whole.
  - `message` (required, string)

```json
{
  "code": "VALIDATION_ERROR",
  "message": "count must be at most 20 (was 50).",
  "issues": [
    {
      "path": [
        "count"
      ],
      "message": "count must be at most 20 (was 50)"
    }
  ]
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/image/upscale \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "effort": "high",
    "size": "2x",
    "url": "string",
    "destination": "bunny-prod"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/image/upscale", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "effort": "high",
    "size": "2x",
    "url": "string",
    "destination": "bunny-prod"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
