# `POST /v1/sound-effects`: create a sound effect job

Source: https://bobabanana.com/docs/api/reference/create-sound-effect/

> POST /v1/sound-effects: create a sound effect job. Parameters, body fields, example request and response, and errors. BobaBanana API reference with curl,...

**`POST /v1/sound-effects` is the endpoint to create a sound effect job.** Makes a sound effect from a text prompt, 2 to 20 seconds. Answers 202 with a queued job; the result is a WAV file.

**At a glance**

- **Endpoint:** `POST /v1/sound-effects`
- **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:** [Sound effects](https://bobabanana.com/docs/api/sound-effects/)

## Request

### 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)



| Field | Type | Required | Default | Limits | Description |
|---|---|---|---|---|---|
| `webhook_url` | string | no |  | 0 to 500 characters | https:// URL that receives a signed POST when the job finishes |
| `metadata` | object of string | no |  | at most 16 keys | Up to 16 keys (40 characters each) with string values (500 characters each), echoed back on the job and its webhook |
| `name` | string | no |  | 0 to 80 characters | Label shown in the BobaBanana studio |
| `max_credits` | integer | no |  | at least 0 | Refuse the job (400 cost_above_max, nothing held) if it would cost more than this |
| `dry_run` | boolean | no | `false` |  | true: answer 200 with what the job would cost (credits_estimate) and make nothing: nothing is queued, held or stored, and no Idempotency-Key is used |
| `prompt` | string | yes |  | 1 to 300 characters | e.g. 'rain on a tin roof with distant thunder' |
| `duration_seconds` | number | no | `8` | 2 to 20 |  |

## Example request

Rain and thunder:

```bash
curl https://bobabanana.com/api/v1/sound-effects \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "prompt": "rain on a tin roof with distant thunder",
    "duration_seconds": 10
  }'
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://bobabanana.com/api/v1/sound-effects",
    headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "prompt": "rain on a tin roof with distant thunder",
        "duration_seconds": 10,
    },
    timeout=60,
)
r.raise_for_status()
print(r.json())
```

```javascript
const res = await fetch("https://bobabanana.com/api/v1/sound-effects", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    "prompt": "rain on a tin roof with distant thunder",
    "duration_seconds": 10
  }),
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
console.log(await res.json());
```

## 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": "sound_effect",
  "credits_estimate": 2,
  "credits_available": 950,
  "enough_credits": true,
  "billing_mode": "credits"
}
```

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

```json
{
  "id": "x_6d3b8e2a0f19",
  "object": "job",
  "type": "sound_effect",
  "status": "queued",
  "created": 1764950400,
  "input": {
    "prompt": "rain on a tin roof with distant thunder",
    "duration_seconds": 10.0
  },
  "output": {},
  "eta_seconds": 15,
  "poll_after_seconds": 5,
  "cost": {
    "credits_estimate": 2,
    "credits_charged": 0,
    "credits_released": 0,
    "status": "held"
  }
}
```

## 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. |
| 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: [Sound effects](https://bobabanana.com/docs/api/sound-effects/)
- [All endpoints](https://bobabanana.com/docs/api/reference/)
- [Objects](https://bobabanana.com/docs/api/reference/objects/)
- [Error codes](https://bobabanana.com/docs/api/errors/)
