# Troubleshooting: fix a refused request or a failed job

Source: https://bobabanana.com/docs/api/troubleshooting/

> Fix BobaBanana API problems by symptom: 401 on every call, 404 for a new job, 402, 429, 400 or 422 errors, refused URLs, failed jobs and missing webhooks.

**Find your symptom below: each section gives the cause, then the fix as numbered steps.** Every BobaBanana API error carries a stable `error.code` and usually the field at fault in `error.param`; the full list is on [Error codes](https://bobabanana.com/docs/api/errors/).

**At a glance**

- **First look at:** `error.code`, `error.param` and `error.message`
- **Check your key:** `GET /v1/balance` (free)
- **Check availability:** `GET /v1/status` (free)
- **Check a job:** `GET /v1/jobs/{job_id}`
- **Support:** quote the `X-Request-ID` response header

## 401 on every call

**Cause:** no key reached the API (`missing_api_key`), or the key is wrong or revoked (`invalid_api_key`).

1. Print the header your code sends: it must be exactly `Authorization: Bearer bb_...`, or `X-API-Key: bb_...`.
2. Check that the environment variable is set in the process that runs the code (`echo $BOBABANANA_API_KEY`).
3. Check that the whole key was copied; keys are shown only once.
4. Test the key alone: `curl https://bobabanana.com/api/v1/balance -H "Authorization: Bearer $BOBABANANA_API_KEY"`.
5. If the key was revoked, make a new one in **Settings → API keys**.

## 403 with error code 1010

**Cause:** a plain-text `403` reading `error code: 1010` comes from the site's edge protection, not from the API, which answers every HTTP client.

1. Send a `User-Agent` that names your app, for example `my-app/1.0`, and retry once.
2. Check that the URL starts with `https://bobabanana.com/api/v1/` or `https://bobabanana.com/docs/`.
3. If it persists, contact support with the time of the request.

## 403 workspace_suspended or link_expired

1. `workspace_suspended`: the workspace that owns the key is suspended; contact support. No call works until it is active again.
2. `link_expired`: a result link is old or invalid. Fetch the job again with `GET /v1/jobs/{job_id}`; it returns fresh links.

## 404 for a job I just made

**Cause:** jobs are private to the key that made them, and deleted jobs stay gone.

1. Use the same key that created the job; another key, even of the same workspace, gets `404 job_not_found`.
2. Check the id: job ids start with `x_`, upload ids with `file_`.
3. If the job was deleted with `DELETE /v1/jobs/{job_id}`, it cannot be shown again.
4. `404 not_found` (not `job_not_found`) means the path is wrong: check it against the [API reference](https://bobabanana.com/docs/api/reference/).

## 402 insufficient_credits

**Cause:** the workspace's available credits are less than the job's estimate. Nothing was held.

1. Read `error.required` and `error.available`.
2. Check `GET /v1/balance`: `credits_held` shows what unfinished jobs hold; it comes back when they finish or are canceled.
3. Add credits in the studio under **Credits**, or make a smaller job (shorter, lower resolution, fewer steps).
4. Next time, price the request first with `dry_run: true`: its `enough_credits` says whether it would be accepted.

## 429 too many requests

**Cause:** a limit was reached; `error.code` says which.

1. `too_many_active_jobs`: the key has 10 unfinished jobs (default). Wait for one, or cancel one.
2. `daily_limit_reached`: the key used its 200 jobs (default) in the last 24 hours. Wait, or ask an owner to raise the limit.
3. `too_many_downloads` or `network_busy`: URL inputs are busy; retry after `Retry-After`, or upload the files first.
4. `too_many_files`: the workspace has 1000 live uploads; delete some with `DELETE /v1/files/{file_id}`.
5. `too_many_attempts`: too many wrong keys from your address; stop, fix the key, and wait for `Retry-After`.
6. Always wait for the `Retry-After` header before retrying. See [Limits](https://bobabanana.com/docs/api/limits/).

## 400 or 422 invalid_request: which field?

**Cause:** a field is wrong. `422` comes from reading the body (type, range, length); `400` from the rules between fields.

1. Read `error.param`: it names the field, for example `duration_seconds` or `reference_images[1]`.
2. Read `error.message`: it says the rule, for example "At 720p a video is 10 seconds at most".
3. Check the field in the endpoint's [reference page](https://bobabanana.com/docs/api/reference/), which lists types, limits and defaults.
4. Fix that field and send again. Do not retry the same body.

## My URL input was refused

**Cause:** URL inputs must be public `https://` links that BobaBanana can download without signing in.

1. `invalid_url`: use `https://`, a host that exists, and a public address (not a local or private one).
2. `fetch_failed`: the URL answered with an error; open it in a private browser window to check it. Signed links from other services often expire.
3. `fetch_timeout`: downloads must finish within 30 seconds; use a faster host or upload the file.
4. `file_too_large`: images up to 25 MB, audio up to 60 MB.
5. When in doubt, upload the file with `POST /v1/files` and send its `file_id`.

## Voice sample rejected

1. `voice_consent_required`: send `voice_consent: true` with an uploaded sample, and only when the voice is yours or you have the speaker's explicit permission.
2. `invalid_voice_sample`: the sample is too short or too long. Use 5 to 30 seconds of one person speaking clearly, with no music.
3. `invalid_audio`: the file could not be read. Use WAV, MP3, M4A, OGG or FLAC.
4. For better clones, send the exact words spoken as `transcript`.

## The job failed

**Cause:** a step could not be made. The job shows `"status": "failed"` and `error.code` `render_failed`.

1. Read `error.message` and `error.steps`: they name the step and why.
2. Change what the message points at: a clearer reference picture, a simpler motion, a shorter script.
3. Create a new job; a failed job is final. Its undelivered steps cost nothing.
4. If many jobs fail, check `GET /v1/status` for what is available now.

## No webhook arrived

1. Check the job: `GET /v1/jobs/{job_id}` shows `webhook.status`, `attempts` and `last_status` (your server's HTTP status).
2. Your endpoint must be public `https://` and answer any `2xx` within 10 seconds.
3. Each event gets up to 6 attempts, waiting 0 s, 10 s, 1 min, 5 min, 30 min, 2 h before each; after the last failure the status is `failed`.
4. A job created without `webhook_url` has no webhook (`409 no_webhook` on replay).
5. A revoked key's webhooks are not sent.
6. Send it again with `POST /v1/jobs/{job_id}/webhook/replay` once the endpoint is fixed. See [Webhooks](https://bobabanana.com/docs/api/webhooks/).

## The result link stopped working

**Cause:** result links are signed and work for at least 24 hours.

1. Fetch the job again with `GET /v1/jobs/{job_id}` for fresh links.
2. If the job was deleted, its results are gone.
3. Store results you want to keep on your side.

## Frequently asked questions

### Where do I start when something fails?
Read `error.code` and `error.param` in the response body. The code finds the row on [Error codes](https://bobabanana.com/docs/api/errors/), and the field tells you what to change. For a job that failed later, read `error.message` in `GET /v1/jobs/{job_id}`.

### What should I send to support?
The `X-Request-ID` header of the failing response, the time, the endpoint, and the job id if there is one. Never send your API key.

### Why does the same request work in curl but not in my code?
Compare the headers and the body your code sends with the curl command. Common causes are a missing `Content-Type: application/json`, a body sent as form data instead of JSON, or a key variable that is empty in that process.
