# API reference: Audio

> The Audio endpoints (10 operations), generated from the OpenAPI document (https://faraatarjomeh.com/api/v1/openapi.json). For task-level walkthroughs use the guides; for error handling use /api/v1/docs/errors. The full reference: /api/v1/docs/reference.

## At a glance

- Auth on every call: `Authorization: Bearer $FARA_API_KEY`
- `scope`: `read` for GET/HEAD, `write` for the rest
- **spends Fara**: the call holds or charges Fara; get the price first and send `Idempotency-Key`
- Path parameters in the examples are shell variables (`$JOB_ID`, `$ID` …)
- Errors: `application/problem+json` with a stable `code` (not repeated per endpoint below)

## Index

- **Audio**: [GET /api/v1/audio/voices](#listAudioVoices), [GET /api/v1/audio/pricing](#getAudioPricing), [GET /api/v1/audio/jobs](#listAudioJobs), [POST /api/v1/audio/jobs](#createAudioJob), [GET /api/v1/audio/jobs/{id}](#getAudioJob), [DELETE /api/v1/audio/jobs/{id}](#deleteAudioJob), [PATCH /api/v1/audio/jobs/{id}/segments/{segmentId}](#editAudioScriptSegment), [POST /api/v1/audio/jobs/{id}/approve](#approveAudioScript), [POST /api/v1/audio/jobs/{id}/cancel](#cancelAudioJob), [GET /api/v1/audio/jobs/{id}/download](#downloadAudio)

## Audio

Podcast or audiobook from a finished translation.

<a id="listAudioVoices"></a>
### GET /api/v1/audio/voices

List voices and moods for podcasts and audiobooks

- operationId `listAudioVoices` · scope `read` · free

**Response `200`**

[`VoiceCatalog`](#schema-voice-catalog)

**Responses**

- `200` Voices and moods. (`application/json`)
- Errors: `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/audio/voices" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="getAudioPricing"></a>
### GET /api/v1/audio/pricing

Get podcast and audiobook pricing

- operationId `getAudioPricing` · scope `read` · free

**Response `200`**

[`AudioPricing`](#schema-audio-pricing)

**Responses**

- `200` Pricing. (`application/json`)
- Errors: `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/audio/pricing" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="listAudioJobs"></a>
### GET /api/v1/audio/jobs

List audio jobs

- operationId `listAudioJobs` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `limit` | query | integer | no | Items to return (at most 50). — default: `20`; min 1; max 50 |
| `offset` | query | integer | no | Items to skip. — default: `0`; min 0 |
| `q` | query | string | no | Search by name. Matches the name given to the job or its original file name, ignoring case. Plain text, at most 100 characters; blank means no search. — max length 100 |
| `translationJobId` | query | string | no | Only jobs made from this translation. |
| `feature` | query | string | no | Only this kind. — one of: `podcast`, `audiobook` |

**Response `200`**

[`AudioJobList`](#schema-audio-job-list)

**Responses**

- `200` Jobs. (`application/json`)
- Errors: `400`, `401`, `403`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/audio/jobs" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="createAudioJob"></a>
### POST /api/v1/audio/jobs

Make a podcast or audiobook from a translation

- operationId `createAudioJob` · scope `write` · **spends Fara** · send `Idempotency-Key`

Holds `holdFara` (the price of the longest length plus 20%), charges the actual cost when it finishes, and releases the rest. In rare cases the actual cost is higher than the hold. The job stops at `awaiting_review` with a script you can edit, then approve.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json` (required)

[`AudioCreateRequest`](#schema-audio-create-request)

**Response `201`**

[`AudioJobEnvelope`](#schema-audio-job-envelope)

**Responses**

- `201` Created. (`application/json`)
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/audio/jobs" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"jobId":"string","feature":"podcast"}'
```

<a id="getAudioJob"></a>
### GET /api/v1/audio/jobs/{id}

Get an audio job with its script

- operationId `getAudioJob` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Job id. |

**Response `200`**

[`AudioJobEnvelope`](#schema-audio-job-envelope)

**Responses**

- `200` The job. (`application/json`)
- Errors: `401`, `403`, `404`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/audio/jobs/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="deleteAudioJob"></a>
### DELETE /api/v1/audio/jobs/{id}

Delete a podcast or audiobook job permanently

- operationId `deleteAudioJob` · scope `write` · free · send `Idempotency-Key`

Removes the script and the audio. A podcast or audiobook saved on the translation from this job is removed too from our servers. Ledger rows stay. Only finished jobs (completed, failed, cancelled): a running or queued job answers 409 `JOB_NOT_FINISHED`; cancel it first. Afterwards the job answers 404.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Job id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Responses**

- `204` Deleted.
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X DELETE "https://faraatarjomeh.com/api/v1/audio/jobs/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="editAudioScriptSegment"></a>
### PATCH /api/v1/audio/jobs/{id}/segments/{segmentId}

Edit one script segment

- operationId `editAudioScriptSegment` · scope `write` · free · send `Idempotency-Key`

Only while `awaiting_review`. The whole script must stay within the held length.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Job id. |
| `segmentId` | path | string | yes | Segment id from the job's review data. |
| `If-Match` | header | string | yes | The job's current `reviewVersion`, bare (`3`) or quoted (`"3"`). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json` (required)

[`ScriptSegmentEditRequest`](#schema-script-segment-edit-request)

**Response `200`**

[`ScriptSegmentEditResponse`](#schema-script-segment-edit-response)

**Responses**

- `200` Saved. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `413`, `422`, `428`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X PATCH "https://faraatarjomeh.com/api/v1/audio/jobs/$ID/segments/$SEGMENT_ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H 'If-Match: "$REVIEW_VERSION"' \
  -H "Content-Type: application/json" \
  -d '{"text":"string"}'
```

<a id="approveAudioScript"></a>
### POST /api/v1/audio/jobs/{id}/approve

Approve the script and make the audio

- operationId `approveAudioScript` · scope `write` · free · send `Idempotency-Key`

Uses the Fara already held; nothing new is held.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Job id. |
| `If-Match` | header | string | yes | The job's current `reviewVersion`, bare (`3`) or quoted (`"3"`). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`ApproveResponse`](#schema-approve-response)

**Responses**

- `200` Approved. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `428`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/audio/jobs/$ID/approve" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H 'If-Match: "$REVIEW_VERSION"'
```

<a id="cancelAudioJob"></a>
### POST /api/v1/audio/jobs/{id}/cancel

Cancel an audio job

- operationId `cancelAudioJob` · scope `write` · free · send `Idempotency-Key`

Releases the held Fara.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Job id. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`OkResponse`](#schema-ok-response)

**Responses**

- `200` Cancelled. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/audio/jobs/$ID/cancel" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="downloadAudio"></a>
### GET /api/v1/audio/jobs/{id}/download

Download the MP3

- operationId `downloadAudio` · scope `read` · free

Supports `Range` requests.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `id` | path | string | yes | Job id. |

**Responses**

- `200` The MP3. (`audio/mpeg`)
- `206` Part of the file, for a single `Range: bytes=start-end` request. (`audio/mpeg`)
- `416` The requested range is outside the file. `Content-Range: bytes */total` gives the size.
- Errors: `401`, `403`, `404`, `409`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/audio/jobs/$ID/download" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

## Schemas

Named request and response objects used above. Nested objects are flattened as `parent.child`; arrays as `parent[].child`.

<a id="schema-approve-response"></a>
### ApproveResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `ok` | boolean | yes |  |
| `status` | string | yes | `active`. |
| `reviewVersion` | integer | no |  |
| `untranslatedSpeechSegmentIds` | string[] | no | Video only: spoken segments with no Persian text. They will be silent. |

<a id="schema-audio-create-request"></a>
### AudioCreateRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | yes | Id of a completed translation job. |
| `feature` | string | yes | one of: `podcast`, `audiobook` |
| `voiceId` | string | no | Audiobook narrator: a voice `id` from GET /api/v1/audio/voices, or `male` / `female`. Default `male`. |
| `voiceGender` | string | no | Audiobook only, used when `voiceId` is left out. Default `male`. — one of: `male`, `female` |
| `speaker1VoiceId` | string | no | Podcast only: voice `id` of the first speaker. Default: the male default voice. |
| `speaker2VoiceId` | string | no | Podcast only: voice `id` of the second speaker. Default: the female default voice. |
| `voiceMood` | string | no | Mood of the voices. Default `neutral`. — one of: `neutral`, `friendly`, `formal`, `happy`, `sad`, `calm`, `energetic`, `serious` |

<a id="schema-audio-job-envelope"></a>
### AudioJobEnvelope

| Field | Type | Required | Notes |
|---|---|---|---|
| `job` | object | yes |  |
| `job._id` | string | yes | Audio job id. |
| `job.displayName` | string \| null | no | The name the customer gave the job (null: the original name is shown). — may be null |
| `job.feature` | string | no | one of: `podcast`, `audiobook` |
| `job.translationJobId` | string | no |  |
| `job.status` | string | yes | `pending`, `active`, `awaiting_review` (waiting for your edits and approval), and the end states `completed`, `failed`, `cancelled`. Treat any other value as still running. |
| `job.stage` | string | no |  |
| `job.progress` | number | no |  |
| `job.voiceGender` | string \| null | no | may be null |
| `job.voiceKey` | string \| null | no | Audiobook narrator voice `id`. — may be null |
| `job.speakerVoiceKeys` | object \| null | no | Podcast speaker voice ids. — may be null |
| `job.speakerVoiceKeys.speaker1` | string | no |  |
| `job.speakerVoiceKeys.speaker2` | string | no |  |
| `job.voiceMood` | string \| null | no | may be null |
| `job.reviewVersion` | integer | no | Send as `If-Match` when editing or approving the script. |
| `job.script` | object[] | no | Only on GET /api/v1/audio/jobs/{id}. |
| `job.script[].id` | string | no |  |
| `job.script[].text` | string | no |  |
| `job.estimatedMinutes` | number | no |  |
| `job.estimatedCost` | object \| null | no | Price for the script as it is now; `faraCharged` is in Fara. — may be null |
| `job.cost` | object \| null | no | Price of a media job, in Fara. — may be null |
| `job.cost.faraCharged` | number | no | Fara for this job: the held amount while running, the actual charge once finished. |
| `job.cost.minutesBilled` | number | no | Billed minutes, for media jobs. |
| `job.cost.heldFara` | number | no | Fara held when the job started. |
| `job.cost.refundedFara` | number | no | Part of the hold returned after the actual charge. |
| `job.customerErrorCode` | string \| null | no | Why the job failed, as a stable code. Null while the job is fine. — one of: `NO_TEXT_LAYER`, `FILE_TOO_LARGE`, `TOO_MANY_PAGES`, `MEDIA_TOO_LONG`, `TOOK_TOO_LONG`, `PARTIAL_SECTIONS`, `INSUFFICIENT_CREDITS`, `SPEND_LIMIT_REACHED`, `SERVICE_BUSY`, `YOUTUBE_UNAVAILABLE`, `NO_SPEECH_FOUND`, `VOICE_CONSENT_REQUIRED`, `RETRY_LIMIT_REACHED`, `UNDER_REVIEW`, `OUTLINE_NO_MATERIAL`, `DOCUMENT_NO_MATERIAL`, `OUTLINE_EMPTY`, `RECOVERY_LIMIT`, `UNSUPPORTED_FILE_TYPE`, `DOCUMENT_PROTECTED`, `INVALID_DOCUMENT`, `DOCUMENT_CONVERSION_INCOMPLETE`, `DOCUMENT_CONVERSION_FAILED`, `GENERIC`, `null`; may be null |
| `job.createdAt` | string \| null | no | may be null |
| `job.updatedAt` | string \| null | no | may be null |

<a id="schema-audio-job-list"></a>
### AudioJobList

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobs` | object[] | yes |  |
| `jobs[]._id` | string | yes | Audio job id. |
| `jobs[].displayName` | string \| null | no | The name the customer gave the job (null: the original name is shown). — may be null |
| `jobs[].feature` | string | no | one of: `podcast`, `audiobook` |
| `jobs[].translationJobId` | string | no |  |
| `jobs[].status` | string | yes | `pending`, `active`, `awaiting_review` (waiting for your edits and approval), and the end states `completed`, `failed`, `cancelled`. Treat any other value as still running. |
| `jobs[].stage` | string | no |  |
| `jobs[].progress` | number | no |  |
| `jobs[].voiceGender` | string \| null | no | may be null |
| `jobs[].voiceKey` | string \| null | no | Audiobook narrator voice `id`. — may be null |
| `jobs[].speakerVoiceKeys` | object \| null | no | Podcast speaker voice ids. — may be null |
| `jobs[].speakerVoiceKeys.speaker1` | string | no |  |
| `jobs[].speakerVoiceKeys.speaker2` | string | no |  |
| `jobs[].voiceMood` | string \| null | no | may be null |
| `jobs[].reviewVersion` | integer | no | Send as `If-Match` when editing or approving the script. |
| `jobs[].script` | object[] | no | Only on GET /api/v1/audio/jobs/{id}. |
| `jobs[].script[].id` | string | no |  |
| `jobs[].script[].text` | string | no |  |
| `jobs[].estimatedMinutes` | number | no |  |
| `jobs[].estimatedCost` | object \| null | no | Price for the script as it is now; `faraCharged` is in Fara. — may be null |
| `jobs[].cost` | object \| null | no | Price of a media job, in Fara. — may be null |
| `jobs[].cost.faraCharged` | number | no | Fara for this job: the held amount while running, the actual charge once finished. |
| `jobs[].cost.minutesBilled` | number | no | Billed minutes, for media jobs. |
| `jobs[].cost.heldFara` | number | no | Fara held when the job started. |
| `jobs[].cost.refundedFara` | number | no | Part of the hold returned after the actual charge. |
| `jobs[].customerErrorCode` | string \| null | no | Why the job failed, as a stable code. Null while the job is fine. — one of: `NO_TEXT_LAYER`, `FILE_TOO_LARGE`, `TOO_MANY_PAGES`, `MEDIA_TOO_LONG`, `TOOK_TOO_LONG`, `PARTIAL_SECTIONS`, `INSUFFICIENT_CREDITS`, `SPEND_LIMIT_REACHED`, `SERVICE_BUSY`, `YOUTUBE_UNAVAILABLE`, `NO_SPEECH_FOUND`, `VOICE_CONSENT_REQUIRED`, `RETRY_LIMIT_REACHED`, `UNDER_REVIEW`, `OUTLINE_NO_MATERIAL`, `DOCUMENT_NO_MATERIAL`, `OUTLINE_EMPTY`, `RECOVERY_LIMIT`, `UNSUPPORTED_FILE_TYPE`, `DOCUMENT_PROTECTED`, `INVALID_DOCUMENT`, `DOCUMENT_CONVERSION_INCOMPLETE`, `DOCUMENT_CONVERSION_FAILED`, `GENERIC`, `null`; may be null |
| `jobs[].createdAt` | string \| null | no | may be null |
| `jobs[].updatedAt` | string \| null | no | may be null |

<a id="schema-audio-pricing"></a>
### AudioPricing

| Field | Type | Required | Notes |
|---|---|---|---|
| `faraPerMin` | number | no | Fara per minute of finished audio, as billed. |
| `podcast` | object | no |  |
| `podcast.targetMinutes` | number | no |  |
| `podcast.maxMinutes` | number | no |  |
| `podcast.holdFara` | number | no | Fara held when a podcast job is created. |
| `audiobook` | object | no |  |
| `audiobook.targetMinutes` | number | no |  |
| `audiobook.minMinutes` | number | no |  |
| `audiobook.maxMinutes` | number | no |  |
| `audiobook.holdFara` | number | no | Fara held when an audiobook job is created. |

<a id="schema-ok-response"></a>
### OkResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `ok` | boolean | yes |  |

<a id="schema-script-segment-edit-request"></a>
### ScriptSegmentEditRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `text` | string | yes | New text for this script segment. |

<a id="schema-script-segment-edit-response"></a>
### ScriptSegmentEditResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `ok` | boolean | yes |  |
| `reviewVersion` | integer | yes |  |
| `estimatedMinutes` | number | no |  |
| `estimatedCost` | object \| null | no | may be null |

<a id="schema-voice-catalog"></a>
### VoiceCatalog

| Field | Type | Required | Notes |
|---|---|---|---|
| `voices` | object[] | yes |  |
| `voices[].id` | string | yes | Voice id, for example `female-warm`. |
| `voices[].gender` | string | yes | one of: `male`, `female` |
| `voices[].labelFa` | string | no | Name in Persian. |
| `voices[].labelEn` | string | no | Name in English. |
| `voices[].lineFa` | string | no | One-line description in Persian. |
| `voices[].lineEn` | string | no | One-line description in English. |
| `voices[].previewUrl` | string | no | Path of a short Persian sample (MP3) on this site. |
| `voices[].default` | boolean | no | The voice used for this gender when you send only `male` or `female`. |
| `moods` | object[] | yes |  |
| `moods[].id` | string | yes | one of: `neutral`, `friendly`, `formal`, `happy`, `sad`, `calm`, `energetic`, `serious` |
| `moods[].labelFa` | string | no |  |
| `moods[].labelEn` | string | no |  |
