# API reference: Farsi TTS

> The Farsi TTS 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

- **Farsi TTS**: [GET /api/v1/farsi-tts/voices](#listFarsiTtsVoices), [GET /api/v1/farsi-tts/pricing](#getFarsiTtsPricing), [GET /api/v1/farsi-tts/jobs](#listFarsiTtsJobs), [POST /api/v1/farsi-tts/jobs](#createFarsiTtsJob), [GET /api/v1/farsi-tts/jobs/{id}](#getFarsiTtsJob), [DELETE /api/v1/farsi-tts/jobs/{id}](#deleteFarsiTtsJob), [PATCH /api/v1/farsi-tts/jobs/{id}/text](#editFarsiTtsText), [POST /api/v1/farsi-tts/jobs/{id}/approve](#approveFarsiTtsText), [POST /api/v1/farsi-tts/jobs/{id}/cancel](#cancelFarsiTtsJob), [GET /api/v1/farsi-tts/jobs/{id}/download](#downloadFarsiTtsAudio)

## Farsi TTS

Persian text to speech.

<a id="listFarsiTtsVoices"></a>
### GET /api/v1/farsi-tts/voices

List voices and moods for text to speech

- operationId `listFarsiTtsVoices` · 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/farsi-tts/voices" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="getFarsiTtsPricing"></a>
### GET /api/v1/farsi-tts/pricing

Get text-to-speech pricing

- operationId `getFarsiTtsPricing` · scope `read` · free

**Response `200`**

[`FarsiTtsPricing`](#schema-farsi-tts-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/farsi-tts/pricing" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="listFarsiTtsJobs"></a>
### GET /api/v1/farsi-tts/jobs

List text-to-speech jobs

- operationId `listFarsiTtsJobs` · 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 |

**Response `200`**

[`FarsiTtsJobList`](#schema-farsi-tts-job-list)

**Responses**

- `200` Jobs. (`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/farsi-tts/jobs" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="createFarsiTtsJob"></a>
### POST /api/v1/farsi-tts/jobs

Turn text into Persian speech

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

English text is translated to Persian first. Fara is held from the text length (with room for edits), charged at the actual cost when done, and released on failure or cancel. The job stops at `awaiting_review` so you can edit the Persian text, then approve.

**Parameters**

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

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

[`FarsiTtsCreateRequest`](#schema-farsi-tts-create-request)

**Response `201`**

[`FarsiTtsJobEnvelope`](#schema-farsi-tts-job-envelope)

**Responses**

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

**Example**

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

<a id="getFarsiTtsJob"></a>
### GET /api/v1/farsi-tts/jobs/{id}

Get a text-to-speech job with its text

- operationId `getFarsiTtsJob` · scope `read` · free

**Parameters**

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

**Response `200`**

[`FarsiTtsJobEnvelope`](#schema-farsi-tts-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/farsi-tts/jobs/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="deleteFarsiTtsJob"></a>
### DELETE /api/v1/farsi-tts/jobs/{id}

Delete a text-to-speech job permanently

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

Removes the text and the audio 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/farsi-tts/jobs/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="editFarsiTtsText"></a>
### PATCH /api/v1/farsi-tts/jobs/{id}/text

Edit the Persian text

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

Only while `awaiting_review`, and only up to `reservedChars`. No `If-Match` is needed here.

**Parameters**

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

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

[`FarsiTtsTextRequest`](#schema-farsi-tts-text-request)

**Response `200`**

[`FarsiTtsTextResponse`](#schema-farsi-tts-text-response)

**Responses**

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

**Example**

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

<a id="approveFarsiTtsText"></a>
### POST /api/v1/farsi-tts/jobs/{id}/approve

Approve the text and make the audio

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

Uses the Fara already held; nothing new is held. If the work cannot be queued, answers 503 `SERVICE_BUSY` with `Retry-After`: the job is marked failed and the hold is released.

**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`**

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

**Responses**

- `200` Approved. (`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/farsi-tts/jobs/$ID/approve" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="cancelFarsiTtsJob"></a>
### POST /api/v1/farsi-tts/jobs/{id}/cancel

Cancel a text-to-speech job

- operationId `cancelFarsiTtsJob` · 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/farsi-tts/jobs/$ID/cancel" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="downloadFarsiTtsAudio"></a>
### GET /api/v1/farsi-tts/jobs/{id}/download

Download the MP3

- operationId `downloadFarsiTtsAudio` · 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/farsi-tts/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-farsi-tts-create-request"></a>
### FarsiTtsCreateRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `text` | string | yes | Text to speak. English text is translated to Persian first. |
| `sourceLang` | string | yes | one of: `en`, `fa` |
| `voiceId` | string | no | A voice `id` from GET /api/v1/farsi-tts/voices, or `male` / `female`. Default `male`. |
| `voiceGender` | string | no | Used when `voiceId` is left out. Default `male`. — one of: `male`, `female` |
| `voiceMood` | string | no | Mood of the voice. Default `neutral`. — one of: `neutral`, `friendly`, `formal`, `happy`, `sad`, `calm`, `energetic`, `serious` |

<a id="schema-farsi-tts-job-envelope"></a>
### FarsiTtsJobEnvelope

| Field | Type | Required | Notes |
|---|---|---|---|
| `job` | object | yes |  |
| `job._id` | string | yes | Job id. |
| `job.displayName` | string \| null | no | The name the customer gave the job (null: the original name is shown). — may be null |
| `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.sourceLang` | string | no |  |
| `job.voiceGender` | string | no |  |
| `job.voiceKey` | string \| null | no | The chosen voice `id`. — may be null |
| `job.voiceMood` | string \| null | no | may be null |
| `job.inputText` | string | no |  |
| `job.farsiText` | string | no | Persian text that will be spoken. Editable while `awaiting_review`. |
| `job.reservedChars` | integer | no | Most characters the held Fara covers. |
| `job.estimatedMinutes` | number | no |  |
| `job.estimatedCost` | object \| null | no | 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-farsi-tts-job-list"></a>
### FarsiTtsJobList

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobs` | object[] | yes |  |
| `jobs[]._id` | string | yes | Job id. |
| `jobs[].displayName` | string \| null | no | The name the customer gave the job (null: the original name is shown). — may be null |
| `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[].sourceLang` | string | no |  |
| `jobs[].voiceGender` | string | no |  |
| `jobs[].voiceKey` | string \| null | no | The chosen voice `id`. — may be null |
| `jobs[].voiceMood` | string \| null | no | may be null |
| `jobs[].inputText` | string | no |  |
| `jobs[].farsiText` | string | no | Persian text that will be spoken. Editable while `awaiting_review`. |
| `jobs[].reservedChars` | integer | no | Most characters the held Fara covers. |
| `jobs[].estimatedMinutes` | number | no |  |
| `jobs[].estimatedCost` | object \| null | no | 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-farsi-tts-pricing"></a>
### FarsiTtsPricing

| Field | Type | Required | Notes |
|---|---|---|---|
| `faraPerMin` | number | no | Fara per minute of speech, as billed. |
| `charsPerMinute` | number | no | Characters of text per minute of speech. |
| `maxInputChars` | integer | no |  |
| `holdHeadroom` | number | no | The hold is this many times the estimate, to allow for edits. |

<a id="schema-farsi-tts-text-request"></a>
### FarsiTtsTextRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `text` | string | yes | New Persian text. |

<a id="schema-farsi-tts-text-response"></a>
### FarsiTtsTextResponse

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

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

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

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