# API reference: Translation

> The Translation endpoints (24 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

- **Translation**: [GET /api/v1/translate/estimate](#getTranslationTimeModel), [POST /api/v1/translate/analyze](#analyzeDocument), [POST /api/v1/translate/analyze-stream](#startDocumentAnalysis), [POST /api/v1/translate/analyze-stream/{analysisId}/resume](#resumeDocumentAnalysis), [GET /api/v1/translate/analyze-stream/{analysisId}/progress](#streamDocumentAnalysis), [DELETE /api/v1/translate/analyze-stream/{analysisId}](#cancelDocumentAnalysis), [GET /api/v1/translate/{id}/analysis](#getDocumentAnalysis), [GET /api/v1/translate/resumable](#listResumableUploads), [GET /api/v1/translate/pdf-styles](#getPdfStyleOptions), [POST /api/v1/translate/{jobId}/custom-pdf](#renderCustomPdf), [POST /api/v1/translate/extract-farsi-book-pdf](#formatFarsiBookPdf), [POST /api/v1/translate/magazine-translate-pdf](#translateMagazinePdf), [POST /api/v1/translate/start/{jobId}](#startTranslation), [POST /api/v1/translate/{jobId}/translate-rest](#translateRestAfterPreview), [POST /api/v1/translate/{jobId}/page-range](#translatePageRange), [DELETE /api/v1/translate/analyze/{jobId}](#discardAnalyzedDocument), [POST /api/v1/translate/upload](#uploadAndTranslate), [GET /api/v1/translate/status/{jobId}](#getTranslationStatus), [GET /api/v1/translate/download/{jobId}/{type}](#downloadTranslationFile), [GET /api/v1/translate/{jobId}/bilingual](#getBilingualContent), [POST /api/v1/translate/{jobId}/regenerate](#regenerateTranslationFiles), [POST /api/v1/translate/{jobId}/resend-chunks](#retranslateFailedSections), [POST /api/v1/translate/{jobId}/resend-empty](#retranslateEmptySections), [GET /api/v1/translate/history](#listTranslationHistory)

## Translation

Analyze, price, translate, and download documents.

<a id="getTranslationTimeModel"></a>
### GET /api/v1/translate/estimate

Get the time estimate model

- operationId `getTranslationTimeModel` · scope `read` · free

Numbers used to estimate how long a fast translation takes: the median of recent real chunk times (a fixed fallback when there are too few), and how many chunks run at once. For the estimate of a real document, analyze it.

**Response `200`**

**Responses**

- `200` Time model. (`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/translate/estimate" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="analyzeDocument"></a>
### POST /api/v1/translate/analyze

Analyze a PDF and get a price

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

Uploads a PDF, reads its text locally, and returns the page and word counts, the price in Fara per quality level (`qualityEstimates`), and a time estimate. Nothing is charged. Structured extraction is deferred until translation starts. The returned `jobId` has status `analyzed`; start it with POST /api/v1/translate/start/{jobId}. Large files can take several minutes: use a long client timeout, or the streaming version to show progress. A file over 100 MB, a file part that is not `application/pdf`, or a missing `file` answers 400 `BAD_REQUEST`. A scanned PDF (no text layer) is accepted: `scannedSource` is `true`, `wordCount` and the price are estimated from the page count, `qualityPreviews` is `null`, and the text is read from the page images when translation starts. The final charge is the real cost, as for every job. A file that cannot be accepted answers 422 `EXTRACTION_EMPTY_OR_SCANNED`; a broken or encrypted one 400 `INVALID_PDF`. When Word and EPUB input is on for the site, `file` may also be a Word `.docx` or an EPUB file (up to 100 MB). It is checked by its content, converted to PDF once, and then handled as a PDF. The job then has `sourceFormat` (`docx` or `epub`); it is null for a PDF upload. A file we cannot accept answers 415 `UNSUPPORTED_FILE_TYPE`, or 422 with one of `DOCUMENT_PROTECTED`, `INVALID_DOCUMENT`, `DOCUMENT_CONVERSION_INCOMPLETE` or `DOCUMENT_CONVERSION_FAILED`.

**Parameters**

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

**Request body** `multipart/form-data` (required)

[`AnalyzeRequest`](#schema-analyze-request)

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

[`DocumentUrlRequest`](#schema-document-url-request)

**Response `200`**

[`Analysis`](#schema-analysis)

**Responses**

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

**Example**

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

<a id="startDocumentAnalysis"></a>
### POST /api/v1/translate/analyze-stream

Upload a PDF for analysis with a progress stream

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

Stores the PDF and returns at once with an `analysisId`. Local text extraction starts only when you open GET /api/v1/translate/analyze-stream/{analysisId}/progress; open it within 30 minutes or the upload expires. When the stream sends `complete`, the `analysisId` is the job id to start. Nothing is charged; structured extraction is deferred until translation starts. A scanned PDF (no text layer) is accepted: `scannedSource` is `true`, `wordCount` and the price are estimated from the page count, `qualityPreviews` is `null`, and the text is read from the page images when translation starts. The final charge is the real cost, as for every job. A file that cannot be accepted sends an `EXTRACTION_EMPTY_OR_SCANNED` error event. A file over 100 MB, a file part that is not `application/pdf`, or a missing `file` answers 400 `BAD_REQUEST`.

**Parameters**

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

**Request body** `multipart/form-data` (required)

[`AnalyzeRequest`](#schema-analyze-request)

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

[`DocumentUrlRequest`](#schema-document-url-request)

**Response `200`**

[`AnalysisSession`](#schema-analysis-session)

**Responses**

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

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/translate/analyze-stream" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"fileUrl":"string"}'
```

<a id="resumeDocumentAnalysis"></a>
### POST /api/v1/translate/analyze-stream/{analysisId}/resume

Resume a saved local document analysis

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

Resumes your saved analysis with its original PDF, without uploading it again. Reading stays local and is free. Returns the same analysisId and stream URL, or the completed analysis snapshot when already available. Open the returned progress stream to continue. An active analysis returns ANALYSIS_IN_PROGRESS (409); reconnect to its existing stream. Once translation has started, use the translation job endpoints instead.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `analysisId` | path | string | yes | Analysis id returned by POST /api/v1/translate/analyze-stream. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

| Field | Type | Required | Notes |
|---|---|---|---|
| `analysisId` | string | yes |  |
| `sseUrl` | string | yes |  |
| `status` | string | no |  |
| `analysis` | object | no | Result of document analysis. Nothing is charged for analysis. |
| `analysis.jobId` | string | yes | Id of the analyzed job. Use it to start the translation. |
| `analysis.filename` | string | no |  |
| `analysis.fileSize` | integer \| null | no | Bytes. — may be null |
| `analysis.pageCount` | integer \| null | no | may be null |
| `analysis.wordCount` | integer \| null | no | may be null |
| `analysis.charCount` | integer \| null | no | may be null |
| `analysis.totalChunks` | integer | no | Number of translation sections. |
| `analysis.paragraphCount` | integer \| null | no | may be null |
| `analysis.quality` | string \| null | no | may be null |
| `analysis.workflow` | string | no | Default translation workflow. |
| `analysis.availableWorkflows` | string[] | no | Workflows you may pass to start. |
| `analysis.imageCount` | integer | no |  |
| `analysis.scannedSource` | boolean | no | True when the PDF has no text layer. The text is read from the page images when translation starts; wordCount and the price are estimated from the page count, and qualityPreviews is null. |
| `analysis.sourceLanguageNotice` | string | no | Present only as `persian` when the PDF text is already mostly Persian. Such a document can be translated into another language: send `targetLanguage` at start. qualityPreviews is null (no sample translation is made). — one of: `persian` |
| `analysis.estimatedMinutes` | integer \| null | no | Minutes for fast delivery, from recent real chunk times (see `timeEstimate`). — may be null |
| `analysis.estimatedPrice` | number \| null | no | Estimated price in Fara. Every translation runs fast; `qualityEstimates[].estimatedCostEconomy` is the same number. — may be null |
| `analysis.timeEstimate` | object | no | How `estimatedMinutes` was computed: `totalMinutes`, `chunksPerBatch` (chunks that run at once), `estimatedBatches` (waves), `minutesPerChunk`, `sampleCount`, `isDefault`, `source` (`measured_median` or `fallback`). Display only. |
| `analysis.qualityPreviews` | object \| null | no | Short sample translations of one passage, one entry per quality level. The entries have the same text now. Null when previews are off or all failed. — may be null |
| `analysis.qualityPreviews.sourceExcerpt` | object | no | The English passage used: `text`, `sourceChunkNumber`, `totalChunks`, `charCount`, `wordCount`. |
| `analysis.qualityPreviews.variants` | object[] | no |  |
| `analysis.qualityPreviews.generatedAt` | string \| null | no | may be null |
| `analysis.qualityEstimates` | object[] | no | Price and time per quality level; all three cost the same. Use this as the quote; the balance check at start is computed the same way. |
| `analysis.qualityEstimates[].quality` | string | yes | one of: `simple`, `medium`, `highest` |
| `analysis.qualityEstimates[].estimatedCost` | number | yes | Fara for fast (`realtime`) delivery. |
| `analysis.qualityEstimates[].estimatedCostEconomy` | number | yes | Kept for old clients. Equal to `estimatedCost`, because every translation runs fast. |
| `analysis.qualityEstimates[].estimatedMinutes` | integer | yes | Minutes for fast delivery. |
| `analysis.status` | string | yes | `analyzed`. |
| `analysis.freePreviewOffer` | object \| null | no | The free first pages: each verified account may translate the first pages of one PDF free, once. Start with `freePreview: true`. Null when switched off. — may be null |
| `analysis.freePreviewOffer.available` | boolean | no | True when this account can translate the first pages of this document free now. |
| `analysis.freePreviewOffer.pages` | integer | no | How many leading pages are free. |
| `analysis.freePreviewOffer.freePages` | integer | no | Free pages of this document (fewer when the document is shorter). |
| `analysis.freePreviewOffer.wholeDocument` | boolean | no | The whole document fits in the free pages. |
| `analysis.freePreviewOffer.reason` | string \| null | no | Why it is not available: `disabled`, `not_verified`, `used`, `rest_of_preview`, or null. — may be null |
| `analysis.imageTranslation` | object | no | Translating the text inside images (charts, diagrams, infographics). The number of images with text is known only after the document is read, so the price is per image and is added to the charge. Switch it off with `translateImages: false` at start. |
| `analysis.imageTranslation.available` | boolean | no | True when image translation can be chosen for this document. |
| `analysis.imageTranslation.default` | boolean | no | True: it is on unless the start request sends `translateImages: false`. |
| `analysis.imageTranslation.pricePerImage` | number | no | Expected price in Fara of one image that has text to translate. Images without text cost nothing. |
| `analysis.previewOf` | string | no | On the rest of a previewed book: the free preview job it follows. Its prices already take off the free pages' share. |
| `analysis.pageRangeOffer` | object \| null | no | On a whole-file analysis while the page-range feature is on: the chapters offered for POST /api/v1/translate/{jobId}/page-range. Absent on a part and while the feature is off. — may be null |
| `analysis.pageRangeOffer.pageCount` | integer | no | Pages in the file. |
| `analysis.pageRangeOffer.chapters` | array \| null | no | Chapters from the PDF outline, in order. Null when the PDF has no usable outline. — may be null |
| `analysis.pageRange` | object \| null | no | On a part of a file: the pages it covers. Absent on a whole file. — may be null |
| `analysis.pageRange.from` | integer | no | First page of the part (1-based). |
| `analysis.pageRange.to` | integer | no | Last page of the part (1-based, inclusive). |
| `analysis.pageRange.totalPages` | integer \| null | no | Pages in the whole file. — may be null |
| `analysis.pageRange.sourceJobId` | string \| null | no | The job the part was cut from, or null for an upload. — may be null |

**Responses**

- `200` Saved analysis resumed or already complete. (`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/translate/analyze-stream/$ANALYSIS_ID/resume" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="streamDocumentAnalysis"></a>
### GET /api/v1/translate/analyze-stream/{analysisId}/progress

Follow analysis progress (Server-Sent Events)

- operationId `streamDocumentAnalysis` · scope `read` · free

A `text/event-stream`. Each event is `data: <JSON>` (see `AnalysisProgressEvent`). Comment lines (`:`) are keep-alives every 15 seconds. The stream ends after a `complete` or `error` event, or after 20 minutes with no events.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `analysisId` | path | string | yes | Analysis id returned by POST /api/v1/translate/analyze-stream. |

**Responses**

- `200` Event stream. (`text/event-stream`)
- Errors: `401`, `403`, `404`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/translate/analyze-stream/$ANALYSIS_ID/progress" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="cancelDocumentAnalysis"></a>
### DELETE /api/v1/translate/analyze-stream/{analysisId}

Cancel a running analysis

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

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `analysisId` | path | string | yes | Analysis id returned by POST /api/v1/translate/analyze-stream. |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`MessageResponse`](#schema-message-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 DELETE "https://faraatarjomeh.com/api/v1/translate/analyze-stream/$ANALYSIS_ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="getDocumentAnalysis"></a>
### GET /api/v1/translate/{id}/analysis

Get a saved analysis

- operationId `getDocumentAnalysis` · scope `read` · free

Same shape as the analysis result. Use it to show the price again later.

**Parameters**

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

**Response `200`**

[`Analysis`](#schema-analysis)

**Responses**

- `200` Analysis. (`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/translate/$ID/analysis" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="listResumableUploads"></a>
### GET /api/v1/translate/resumable

List analyzed or still-analyzing uploads

- operationId `listResumableUploads` · scope `read` · free

Documents that were analyzed but not started, and analyses still running.

**Response `200`**

[`ResumableUploads`](#schema-resumable-uploads)

**Responses**

- `200` Uploads. (`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/translate/resumable" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="getPdfStyleOptions"></a>
### GET /api/v1/translate/pdf-styles

Get PDF style options

- operationId `getPdfStyleOptions` · scope `read` · free

Defaults and allowed ranges for custom PDF styles.

**Response `200`**

| Field | Type | Required | Notes |
|---|---|---|---|
| `defaults` | object | no |  |
| `options` | object | no |  |

**Responses**

- `200` Style options. (`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/translate/pdf-styles" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="renderCustomPdf"></a>
### POST /api/v1/translate/{jobId}/custom-pdf

Make a PDF of a finished translation with your own styles

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

Returns the PDF directly. It is not stored. Free.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json`

[`CustomPdfRequest`](#schema-custom-pdf-request)

**Responses**

- `200` The PDF. (`application/pdf`)
- 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/translate/$JOB_ID/custom-pdf" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

<a id="formatFarsiBookPdf"></a>
### POST /api/v1/translate/extract-farsi-book-pdf

Reformat a Persian PDF

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

Takes a PDF that already contains Persian text and returns a clean, formatted Persian PDF. No translation. Free. A file over 100 MB, a file part that is not `application/pdf`, or a missing `file` answers 400 `BAD_REQUEST`.

**Parameters**

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

**Request body** `multipart/form-data` (required)

[`FarsiBookRequest`](#schema-farsi-book-request)

**Responses**

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

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/translate/extract-farsi-book-pdf" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F "file=@./your-file"
```

<a id="translateMagazinePdf"></a>
### POST /api/v1/translate/magazine-translate-pdf

Translate a magazine-style PDF in one call

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

Translates the PDF and returns the translated PDF in the same response. No job is created. Fara is held from the page count (350 words per page), then charged from the words actually translated; on failure it is released. This can take many minutes, so use a long client timeout. The answer is a file, so an `Idempotency-Key` repeat gets 409 `IDEMPOTENCY_KEY_ALREADY_USED` (with `originalStatus`) instead of a replay. A file over 100 MB, a file part that is not `application/pdf`, or a missing `file` answers 400 `BAD_REQUEST`.

**Parameters**

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

**Request body** `multipart/form-data` (required)

[`MagazineRequest`](#schema-magazine-request)

**Responses**

- `200` The translated PDF. (`application/pdf`)
- Errors: `400`, `401`, `402`, `403`, `409`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/translate/magazine-translate-pdf" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F "file=@./your-file"
```

<a id="startTranslation"></a>
### POST /api/v1/translate/start/{jobId}

Start translating an analyzed document

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

Queues the translation. With `freePreview: true` only the first pages are translated, free (see `freePreviewOffer`). The balance is checked now against the price (402 `INSUFFICIENT_CREDITS` with `balance` and `estimatedCost`; 503 when the balance could not be checked). Fara is held when the job begins running and charged at the actual cost when it finishes; the actual cost can be higher or lower than the estimate. Leave `executionMode` out (every translation runs fast); `economy_batch` is accepted and runs as `realtime`. An unknown value answers 400 `INVALID_EXECUTION_MODE`. A job that is not `analyzed` (already started, cancelled, or deleted) answers 400 `BAD_REQUEST`; two starts at the same moment answer 409. Poll GET /api/v1/translate/status/{jobId}, or listen for `translation.completed` webhooks.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json`

[`StartTranslationRequest`](#schema-start-translation-request)

**Response `202`**

[`StartTranslationResponse`](#schema-start-translation-response)

**Responses**

- `202` Queued. (`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/translate/start/$JOB_ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

<a id="translateRestAfterPreview"></a>
### POST /api/v1/translate/{jobId}/translate-rest

Translate the rest after the free first pages

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

After a free preview completes, makes a new `analyzed` job for the whole document from the same upload. Nothing is charged here: start it with POST /api/v1/translate/start/{jobId} like any analyzed job. Its prices take off the free pages' share (price × (1 − free pages ÷ total pages)). Asking again returns the same job (200); the first call answers 201. A job that is not a free preview answers 400 `NOT_A_FREE_PREVIEW`; a preview still running 409 `PREVIEW_NOT_FINISHED`; a preview that covered every page 409 `PREVIEW_COVERED_WHOLE_DOCUMENT`; a preview whose file is gone 410 `PREVIEW_SOURCE_GONE`.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`Analysis`](#schema-analysis)

**Responses**

- `200` The rest job already made. (`application/json`)
- `201` The rest job, ready to start. (`application/json`)
- Errors: `400`, `401`, `403`, `404`, `409`, `410`, `422`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/translate/$JOB_ID/translate-rest" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="translatePageRange"></a>
### POST /api/v1/translate/{jobId}/page-range

Translate part of a file (a page range or chapters)

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

Only when the page-range feature is on; otherwise 404 `FEATURE_DISABLED`. Give `pageFrom` and `pageTo`, or `chapters` (indexes from the job's `pageRangeOffer`). The pages are cut from the stored original and made into a new analysis, returned like POST /api/v1/translate/analyze-stream (`analysisId`, `sseUrl`). The part is priced by that analysis; the parent job is not charged. The same range again within 30 minutes returns the same part while that part is still usable; if the same range is still being prepared by another request, the call waits a few seconds, then answers 409 `PAGE_RANGE_BUSY`. A range covering the whole file answers 400 `INVALID_PAGE_RANGE`; `PAGE_RANGE_OUT_OF_BOUNDS` and `PAGE_RANGE_NOT_CONTIGUOUS` are 400 too. A part of a part answers 409 `PAGE_RANGE_PARENT_IS_PART`; a job not analysed yet 409 `JOB_NOT_READY`. A missing original answers 410 `PAGE_RANGE_SOURCE_GONE`. When the pages cannot be cut the answer is 422 `PAGE_RANGE_UNAVAILABLE`; the whole file is never used instead.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

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

[`PageRangeRequest`](#schema-page-range-request)

**Response `200`**

[`AnalysisSession`](#schema-analysis-session)

**Responses**

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

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/translate/$JOB_ID/page-range" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

<a id="discardAnalyzedDocument"></a>
### DELETE /api/v1/translate/analyze/{jobId}

Discard an analyzed document

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

Only for jobs still `analyzed` (not started).

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`MessageResponse`](#schema-message-response)

**Responses**

- `200` Discarded. (`application/json`)
- 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/translate/analyze/$JOB_ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="uploadAndTranslate"></a>
### POST /api/v1/translate/upload

Upload a PDF and start translating at once

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

Analyze and start in one call. The job runs fast at the fast price. To see the price first, use analyze + start instead. Use a new `Idempotency-Key` for every file: for uploads the key only covers the URL, not the file. A file over 100 MB, a file part that is not `application/pdf`, or a missing `file` answers 400 `BAD_REQUEST`. When Word and EPUB input is on for the site, `file` may also be a Word `.docx` or an EPUB file (up to 100 MB). It is checked by its content, converted to PDF once, and then handled as a PDF. The job then has `sourceFormat` (`docx` or `epub`); it is null for a PDF upload. A file we cannot accept answers 415 `UNSUPPORTED_FILE_TYPE`, or 422 with one of `DOCUMENT_PROTECTED`, `INVALID_DOCUMENT`, `DOCUMENT_CONVERSION_INCOMPLETE` or `DOCUMENT_CONVERSION_FAILED`. A PDF with no readable text answers 400 `BAD_REQUEST`.

**Parameters**

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

**Request body** `multipart/form-data` (required)

[`UploadRequest`](#schema-upload-request)

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

[`DocumentUrlRequest`](#schema-document-url-request)

**Response `202`**

[`UploadResponse`](#schema-upload-response)

**Responses**

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

**Example**

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

<a id="getTranslationStatus"></a>
### GET /api/v1/translate/status/{jobId}

Get translation status and prices

- operationId `getTranslationStatus` · scope `read` · free

Progress, the price while the job is `analyzed`, outputs, and which sections failed. The recommended endpoint to poll (every 30 s for fast jobs, every 10 minutes in economy waiting states); it answers for every job you have not deleted.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |

**Response `200`**

[`TranslationStatus`](#schema-translation-status)

**Responses**

- `200` Status. (`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/translate/status/$JOB_ID" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="downloadTranslationFile"></a>
### GET /api/v1/translate/download/{jobId}/{type}

Download a translation output

- operationId `downloadTranslationFile` · scope `read` · free

`pdf` and `docx` need a `completed` or `completed_partial` job. `slides-pptx` and `slides-pdf` need slide files (POST /api/v1/translate/{jobId}/slides/generate-files). `podcast-audio` and `audiobook-audio` need a made podcast or audiobook.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `type` | path | string | yes | Which file. — one of: `pdf`, `docx`, `slides-pptx`, `slides-pdf`, `podcast-audio`, `audiobook-audio` |

**Responses**

- `200` The file. (`application/pdf`, `application/vnd.openxmlformats-officedocument.wordprocessingml.document`, `application/vnd.openxmlformats-officedocument.presentationml.presentation`, `audio/mpeg`, `audio/wav`)
- Errors: `401`, `403`, `404`, `410`, `429`, `503` — problem+json, see /api/v1/docs/errors

**Example**

```bash
curl -sS -X GET "https://faraatarjomeh.com/api/v1/translate/download/$JOB_ID/$TYPE" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="getBilingualContent"></a>
### GET /api/v1/translate/{jobId}/bilingual

Get the English and Persian text side by side

- operationId `getBilingualContent` · scope `read` · free

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |

**Response `200`**

[`BilingualContent`](#schema-bilingual-content)

**Responses**

- `200` Paragraph pairs. (`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/translate/$JOB_ID/bilingual" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="regenerateTranslationFiles"></a>
### POST /api/v1/translate/{jobId}/regenerate

Rebuild the PDF and DOCX from the current translation

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

Free. Only for `completed` or `completed_partial` jobs.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json`

[`RegenerateRequest`](#schema-regenerate-request)

**Response `200`**

[`RegenerateResponse`](#schema-regenerate-response)

**Responses**

- `200` Rebuilt. (`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/translate/$JOB_ID/regenerate" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

<a id="retranslateFailedSections"></a>
### POST /api/v1/translate/{jobId}/resend-chunks

Translate failed or empty sections again

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

Re-translates only the sections that failed, then rebuilds the files. Synchronous: answers when done, which can take several minutes. Only for `completed`, `completed_partial`, or `failed` jobs (400 otherwise). Uses the job's one retry when it re-translates anything. Fara is held first and the actual cost of what was re-translated is charged; nothing when nothing was re-translated. `type=empty` re-translates nothing on current jobs; use `all`. If sections still fail, the job is locked for our team (`retryLocked`, `adminReviewRequired` in the answer).

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `type` | query | string | no | Which sections to send again. — one of: `all`, `failed`, `empty`; default: `"all"` |
| `retryableOnly` | query | string | no | Only sections that failed for a temporary reason. — one of: `true`, `false`; default: `"false"` |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Request body** `application/json`

[`ResendChunksRequest`](#schema-resend-chunks-request)

**Response `200`**

[`ResendChunksResponse`](#schema-resend-chunks-response)

**Responses**

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

**Example**

```bash
curl -sS -X POST "https://faraatarjomeh.com/api/v1/translate/$JOB_ID/resend-chunks" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

<a id="retranslateEmptySections"></a>
### POST /api/v1/translate/{jobId}/resend-empty

Translate empty sections again (old path)

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

Deprecated. Answers `307` to POST /api/v1/translate/{jobId}/resend-chunks?type=empty, which re-translates nothing on current jobs. Use POST /api/v1/translate/{jobId}/resend-chunks with `type=all` instead.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `jobId` | path | string | yes | Translation job id (returned by analysis or upload). |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Responses**

- `307` Redirect to resend-chunks with `type=empty`.
- 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/translate/$JOB_ID/resend-empty" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="listTranslationHistory"></a>
### GET /api/v1/translate/history

List translated documents

- operationId `listTranslationHistory` · scope `read` · free

Page-based. Lists every translation of the account in every state (queued, running, waiting in an older economy state, priced but not started, failed, cancelled, completed). Deleted translations are not listed. Includes which extra tools (slides, mind map, and so on) exist for each finished document. Analyzed uploads that were never started are listed for 7 days after they were created.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `page` | query | integer | no | Page number, starting at 1. — default: `1`; min 1 |
| `limit` | query | integer | no | Items per page (1-100). — default: `20`; min 1; max 100 |
| `status` | query | string | no | Filter by status. — one of: `all`, `pending`, `processing`, `completed`, `failed`, `completed_partial`; default: `"all"` |
| `sortBy` | query | string | no | Sort field. — one of: `createdAt`, `filename`; default: `"createdAt"` |
| `sortOrder` | query | string | no | Sort order. — one of: `asc`, `desc`; default: `"desc"` |
| `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`**

[`TranslationHistory`](#schema-translation-history)

**Responses**

- `200` One page. (`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/translate/history" \
  -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-analysis"></a>
### Analysis

Result of document analysis. Nothing is charged for analysis.

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | yes | Id of the analyzed job. Use it to start the translation. |
| `filename` | string | no |  |
| `fileSize` | integer \| null | no | Bytes. — may be null |
| `pageCount` | integer \| null | no | may be null |
| `wordCount` | integer \| null | no | may be null |
| `charCount` | integer \| null | no | may be null |
| `totalChunks` | integer | no | Number of translation sections. |
| `paragraphCount` | integer \| null | no | may be null |
| `quality` | string \| null | no | may be null |
| `workflow` | string | no | Default translation workflow. |
| `availableWorkflows` | string[] | no | Workflows you may pass to start. |
| `imageCount` | integer | no |  |
| `scannedSource` | boolean | no | True when the PDF has no text layer. The text is read from the page images when translation starts; wordCount and the price are estimated from the page count, and qualityPreviews is null. |
| `sourceLanguageNotice` | string | no | Present only as `persian` when the PDF text is already mostly Persian. Such a document can be translated into another language: send `targetLanguage` at start. qualityPreviews is null (no sample translation is made). — one of: `persian` |
| `estimatedMinutes` | integer \| null | no | Minutes for fast delivery, from recent real chunk times (see `timeEstimate`). — may be null |
| `estimatedPrice` | number \| null | no | Estimated price in Fara. Every translation runs fast; `qualityEstimates[].estimatedCostEconomy` is the same number. — may be null |
| `timeEstimate` | object | no | How `estimatedMinutes` was computed: `totalMinutes`, `chunksPerBatch` (chunks that run at once), `estimatedBatches` (waves), `minutesPerChunk`, `sampleCount`, `isDefault`, `source` (`measured_median` or `fallback`). Display only. |
| `qualityPreviews` | object \| null | no | Short sample translations of one passage, one entry per quality level. The entries have the same text now. Null when previews are off or all failed. — may be null |
| `qualityPreviews.sourceExcerpt` | object | no | The English passage used: `text`, `sourceChunkNumber`, `totalChunks`, `charCount`, `wordCount`. |
| `qualityPreviews.variants` | object[] | no |  |
| `qualityPreviews.variants[].quality` | string | no | one of: `simple`, `medium`, `highest` |
| `qualityPreviews.variants[].status` | string | no | `ok` or `error`. |
| `qualityPreviews.variants[].text` | string | no | Sample Persian translation. Empty on `error`. |
| `qualityPreviews.variants[].error` | string | no |  |
| `qualityPreviews.variants[].processingTimeMs` | integer \| null | no | may be null |
| `qualityPreviews.variants[].isEmpty` | boolean | no |  |
| `qualityPreviews.generatedAt` | string \| null | no | may be null |
| `qualityEstimates` | object[] | no | Price and time per quality level; all three cost the same. Use this as the quote; the balance check at start is computed the same way. |
| `qualityEstimates[].quality` | string | yes | one of: `simple`, `medium`, `highest` |
| `qualityEstimates[].estimatedCost` | number | yes | Fara for fast (`realtime`) delivery. |
| `qualityEstimates[].estimatedCostEconomy` | number | yes | Kept for old clients. Equal to `estimatedCost`, because every translation runs fast. |
| `qualityEstimates[].estimatedMinutes` | integer | yes | Minutes for fast delivery. |
| `status` | string | yes | `analyzed`. |
| `freePreviewOffer` | object \| null | no | The free first pages: each verified account may translate the first pages of one PDF free, once. Start with `freePreview: true`. Null when switched off. — may be null |
| `freePreviewOffer.available` | boolean | no | True when this account can translate the first pages of this document free now. |
| `freePreviewOffer.pages` | integer | no | How many leading pages are free. |
| `freePreviewOffer.freePages` | integer | no | Free pages of this document (fewer when the document is shorter). |
| `freePreviewOffer.wholeDocument` | boolean | no | The whole document fits in the free pages. |
| `freePreviewOffer.reason` | string \| null | no | Why it is not available: `disabled`, `not_verified`, `used`, `rest_of_preview`, or null. — may be null |
| `imageTranslation` | object | no | Translating the text inside images (charts, diagrams, infographics). The number of images with text is known only after the document is read, so the price is per image and is added to the charge. Switch it off with `translateImages: false` at start. |
| `imageTranslation.available` | boolean | no | True when image translation can be chosen for this document. |
| `imageTranslation.default` | boolean | no | True: it is on unless the start request sends `translateImages: false`. |
| `imageTranslation.pricePerImage` | number | no | Expected price in Fara of one image that has text to translate. Images without text cost nothing. |
| `previewOf` | string | no | On the rest of a previewed book: the free preview job it follows. Its prices already take off the free pages' share. |
| `pageRangeOffer` | object \| null | no | On a whole-file analysis while the page-range feature is on: the chapters offered for POST /api/v1/translate/{jobId}/page-range. Absent on a part and while the feature is off. — may be null |
| `pageRangeOffer.pageCount` | integer | no | Pages in the file. |
| `pageRangeOffer.chapters` | array \| null | no | Chapters from the PDF outline, in order. Null when the PDF has no usable outline. — may be null |
| `pageRange` | object \| null | no | On a part of a file: the pages it covers. Absent on a whole file. — may be null |
| `pageRange.from` | integer | no | First page of the part (1-based). |
| `pageRange.to` | integer | no | Last page of the part (1-based, inclusive). |
| `pageRange.totalPages` | integer \| null | no | Pages in the whole file. — may be null |
| `pageRange.sourceJobId` | string \| null | no | The job the part was cut from, or null for an upload. — may be null |

<a id="schema-analysis-session"></a>
### AnalysisSession

| Field | Type | Required | Notes |
|---|---|---|---|
| `analysisId` | string | yes | Id of this analysis. It becomes the job id when analysis finishes. |
| `filename` | string | no |  |
| `fileSize` | integer | no |  |
| `sseUrl` | string | yes | Path of the progress stream. |

<a id="schema-analyze-request"></a>
### AnalyzeRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `file` | file | yes | The PDF (up to 100 MB). When Word and EPUB input is on, a `.docx` or EPUB file is accepted too. |
| `quality` | string | no | Deprecated. Still accepted; it no longer changes the result. — one of: `simple`, `medium`, `highest` |

<a id="schema-bilingual-content"></a>
### BilingualContent

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | yes |  |
| `filename` | string | no |  |
| `createdAt` | string \| null | no | may be null |
| `updatedAt` | string \| null | no | may be null |
| `revision` | integer | no | Changes each time the translation is edited or re-translated. |
| `status` | string | no |  |
| `paragraphs` | object[] | yes |  |
| `paragraphs[].sequenceNumber` | integer | no |  |
| `paragraphs[].english` | string | no |  |
| `paragraphs[].farsi` | string | no |  |
| `paragraphs[].farsiEdited` | string \| null | no | may be null |
| `paragraphs[].isHeading` | boolean | no |  |
| `paragraphs[].headingLevel` | integer \| null | no | may be null |
| `metadata` | object | no | Document details and the price paid. |
| `detectedSections` | object[] | no |  |
| `documentTitle` | string \| null | no | may be null |

<a id="schema-custom-pdf-request"></a>
### CustomPdfRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `styles` | object | no | Style options. See GET /api/v1/translate/pdf-styles for fields and ranges (for example `fontSize`, `lineHeight`, `textAlign`, `coverStyle`, margins). |
| `title` | string | no | Title on the cover and header. |
| `showHeader` | boolean | no | Default true. |
| `printQuality` | boolean | no | True for full-resolution figures (bigger file). |

<a id="schema-document-url-request"></a>
### DocumentUrlRequest

JSON alternative to the upload form: the document comes from `fileUrl`.

| Field | Type | Required | Notes |
|---|---|---|---|
| `fileUrl` | string | yes | An https link to the document (PDF, or Word `.docx` / EPUB when that input is on; up to 100 MB). We download it instead of an upload: any account, up to 3 redirects, private addresses refused. The file's bytes decide its type. |
| `pageFrom` | string | no | As in the upload form (page-range feature). |
| `pageTo` | string | no | As in the upload form (page-range feature). |

<a id="schema-farsi-book-request"></a>
### FarsiBookRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `file` | file | yes | A PDF that already contains Persian text (up to 100 MB). |
| `title` | string | no |  |
| `showHeader` | string | no | `true` or `false`. |
| `styles` | string | no | JSON string of style options (see GET /api/v1/translate/pdf-styles). |

<a id="schema-magazine-request"></a>
### MagazineRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `file` | file | yes | The PDF (up to 100 MB). |
| `mode` | string | no | Layout mode. Default `phase1`. |
| `quality` | string | no | Deprecated. Does not change the result. — one of: `simple`, `medium`, `highest` |

<a id="schema-message-response"></a>
### MessageResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `message` | string | no |  |
| `jobId` | string | no |  |
| `analysisId` | string | no |  |

<a id="schema-page-range-request"></a>
### PageRangeRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `pageFrom` | integer | no | First page to translate (1-based, inclusive). Give with `pageTo`. |
| `pageTo` | integer | no | Last page to translate (1-based, inclusive). |
| `chapters` | integer[] | no | Or: indexes of consecutive chapters from the job's `pageRangeOffer.chapters`, instead of pages. |

<a id="schema-regenerate-request"></a>
### RegenerateRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `revision` | integer | no | Optional: the `revision` you last read. Mismatch gives 409 `STALE_REVISION`. |

<a id="schema-regenerate-response"></a>
### RegenerateResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `success` | boolean | no |  |
| `docxFileId` | string | no |  |
| `pdfFileId` | string \| null | no | may be null |
| `pdfGenerated` | boolean | no |  |
| `regeneratedAt` | string \| null | no | may be null |

<a id="schema-resend-chunks-request"></a>
### ResendChunksRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `revision` | integer | no | Optional: the `revision` from GET /api/v1/translate/{jobId}/bilingual. If the translation changed since, you get 409 `STALE_REVISION`. |

<a id="schema-resend-chunks-response"></a>
### ResendChunksResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | no |  |
| `type` | string | no |  |
| `retryableOnly` | boolean | no |  |
| `totalResent` | integer | no | Sections sent again. |
| `successCount` | integer | no |  |
| `failedCount` | integer | no |  |
| `stillEmptyCount` | integer | no |  |
| `stillEmpty` | string[] | no |  |
| `stillFailed` | string[] | no |  |
| `regenerated` | boolean | no | True when the output files were rebuilt. |
| `regenerationError` | string \| null | no | may be null |
| `warnings` | object[] | no |  |
| `results` | object[] | no | One entry per section tried. |
| `results[].blockId` | string | no |  |
| `results[].success` | boolean | no |  |
| `results[].errorCode` | string | no |  |
| `results[].retryable` | boolean | no |  |
| `results[].error` | string | no |  |
| `retryLocked` | boolean | no | Present and true when sections still failed: the job is now locked for our team. |
| `adminReviewRequired` | boolean | no |  |
| `reviewReasonCode` | string | no |  |

<a id="schema-resumable-uploads"></a>
### ResumableUploads

| Field | Type | Required | Notes |
|---|---|---|---|
| `items` | object[] | no | Newest first. |
| `items[].kind` | string | no | `analyzed` (ready to start) or `extracting` (analysis still running). |
| `items[].jobId` | string | no |  |
| `items[].analysisId` | string | no |  |
| `items[].filename` | string \| null | no | may be null |
| `items[].fileSize` | integer \| null | no | may be null |
| `items[].progress` | number | no |  |
| `items[].phase` | string | no |  |
| `items[].createdAt` | string \| null | no | may be null |

<a id="schema-start-translation-request"></a>
### StartTranslationRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `executionMode` | string | no | Deprecated. Every translation runs fast: send `realtime`, or leave it out. `economy_batch` is still accepted and runs as `realtime`. Any other value answers 400 `INVALID_EXECUTION_MODE`. — one of: `economy_batch`, `realtime` |
| `quality` | string | no | Deprecated. It no longer changes the result: the translation keeps the tone of the source. Still accepted, so old clients keep working. — one of: `simple`, `medium`, `highest` |
| `workflow` | string | no | One of `availableWorkflows` from the analysis. Leave out for the default. |
| `freePreview` | boolean | no | Translate only the first pages free (see `freePreviewOffer` in the analysis). Once per account; always fast delivery; no balance needed. 403 `FREE_PREVIEW_ALREADY_USED`, `FREE_PREVIEW_UNAVAILABLE` or `EMAIL_NOT_VERIFIED` when it cannot be used. A document in Persian kept in Persian (`targetLanguage` left out or `fa`) gets no free preview: 403 `FREE_PREVIEW_UNAVAILABLE`. |
| `targetLanguage` | string | no | The language to translate into. Leave out for Persian (`fa`). Another language (`en`, `ar`, `de`, `fr`, `es`, `ru`, `tr`, `zh`) is accepted only for a document in Persian (`sourceLanguageNotice: "persian"` in the analysis); such a job runs in the standard mode, keeps every image as it is and makes no book summary. The rest of a free preview goes into the preview's language when this is left out. — one of: `fa`, `en`, `ar`, `de`, `fr`, `es`, `ru`, `tr`, `zh` |
| `translateImages` | boolean | no | Translate the text inside images (charts, diagrams, infographics). On by default. Each image with text adds about `imageTranslation.pricePerImage` Fara to the charge, paid from the balance left after the translation's own hold; images the balance does not cover keep their original picture. Send `false` to keep every image as it is, at no extra cost. |

<a id="schema-start-translation-response"></a>
### StartTranslationResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | yes |  |
| `quality` | string | no |  |
| `workflow` | string | no |  |
| `executionMode` | string | no | one of: `economy_batch`, `realtime` |
| `availableWorkflows` | string[] | no |  |
| `message` | string | no |  |
| `totalChunks` | integer | no |  |
| `status` | string | yes | `pending`. |
| `freePreview` | boolean | no | True when only the free first pages are translated. |
| `freePreviewPages` | integer | no | On a free preview: how many leading pages are free. |
| `translateImages` | boolean | no | Whether the text inside images is translated for this job. |
| `targetLanguage` | string | no | The language the job translates into. — one of: `fa`, `en`, `ar`, `de`, `fr`, `es`, `ru`, `tr`, `zh` |

<a id="schema-translation-history"></a>
### TranslationHistory

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobs` | object[] | yes |  |
| `jobs[].jobId` | string | no |  |
| `jobs[].filename` | string | no |  |
| `jobs[].displayName` | string \| null | no | The name the customer gave the job (null: the original name is shown). — may be null |
| `jobs[].createdAt` | string \| null | no | may be null |
| `jobs[].updatedAt` | string \| null | no | may be null |
| `jobs[].status` | string | no |  |
| `jobs[].executionMode` | string | no |  |
| `jobs[].totalChunks` | integer \| null | no | Chunks in the job, when known. — may be null |
| `jobs[].completedChunks` | integer \| null | no | Chunks finished so far, when known. — may be null |
| `jobs[].pageCount` | integer \| null | no | Pages in the PDF, when known. — may be null |
| `jobs[].paragraphCount` | integer | no |  |
| `jobs[].englishWordCount` | integer | no |  |
| `jobs[].farsiWordCount` | integer | no |  |
| `jobs[].outputsGenerated` | boolean | no |  |
| `jobs[].hasLinkedInPosts` | boolean | no |  |
| `jobs[].hasSlides` | boolean | no |  |
| `jobs[].hasMindmap` | boolean | no |  |
| `jobs[].hasSummary` | boolean | no |  |
| `jobs[].hasPodcast` | boolean | no |  |
| `jobs[].hasAudiobook` | boolean | no |  |
| `total` | integer | yes |  |
| `page` | integer | yes |  |
| `totalPages` | integer | yes |  |

<a id="schema-translation-status"></a>
### TranslationStatus

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | yes |  |
| `status` | string | yes | `analyzed` (priced, not started), `pending`, `processing`, `translating`, `batch_submitted`, `batch_waiting`, `batch_results_received`, `validating` (only on jobs started before economy delivery was removed), `images_waiting` (the text is done; the pictures wait for your choice, see POST /api/v1/jobs/{jobId}/images), and the end states `completed`, `completed_partial`, `failed`, `cancelled`. Treat any other value as still running. |
| `filename` | string \| null | no | may be null |
| `pageCount` | integer \| null | no | may be null |
| `outputPageCount` | integer \| null | no | may be null |
| `wordCount` | integer \| null | no | may be null |
| `charCount` | integer \| null | no | may be null |
| `paragraphCount` | integer \| null | no | may be null |
| `quality` | string \| null | no | may be null |
| `workflow` | string \| null | no | may be null |
| `availableWorkflows` | string[] | no |  |
| `estimatedPrice` | number | no | Estimated price in Fara. Before start: the fast price. After start: the price of the chosen delivery. |
| `estimatedPriceEconomy` | number \| null | no | Only while `analyzed`. Kept for old clients; every translation runs fast, so use `estimatedPrice`. — may be null |
| `executionMode` | string | no | one of: `economy_batch`, `realtime` |
| `translationMode` | string | no | Economy tier: `economy` or `standard`. Absent on jobs stored before the Economy tier. — one of: `economy`, `standard` |
| `keepLayout` | boolean | no | Economy tier: the page-design tick. Economy jobs have it off. |
| `summary` | boolean | no | Economy tier: the book-summary tick. |
| `noSummary` | boolean | no | Standard only: `true` when the translation was started without the book summary. Standard makes the summary unless this is set. |
| `expectedBy` | integer \| null | no | Economy jobs only: the promised time as ms since 1970-01-01 UTC. Null otherwise. — may be null |
| `canSwitchToStandard` | boolean | no | Economy tier: true when this failed Economy job can be switched to Standard (the retry call with `translationMode: "standard"`). Always false otherwise. |
| `economyFailure` | string \| null | no | Economy tier: why this failed Economy job failed, in words the customer may see: `incomplete` (part of the text could not be read), `extraction` (the file could not be read in full) or `unavailable` (Economy was not available). Null for any other job. — one of: `incomplete`, `extraction`, `unavailable`, `null`; may be null |
| `translateImages` | boolean | no | Whether the text inside images is translated for this job (the choice sent at start; true before start). |
| `targetLanguage` | string | no | The language the job translates into (`fa` unless another language was sent at start). — one of: `fa`, `en`, `ar`, `de`, `fr`, `es`, `ru`, `tr`, `zh` |
| `sourceLanguageNotice` | string | no | Present only as `persian` for a document in Persian (see the analysis). — one of: `persian` |
| `suggestedTargetLanguage` | string | no | A document in Persian waiting at the price screen only: the language to offer first (the free preview's language for the rest of a previewed book, else `en`). — one of: `en`, `ar`, `de`, `fr`, `es`, `ru`, `tr`, `zh` |
| `pageRangeOffer` | object \| null | no | On a whole-file job while the page-range feature is on: the chapters offered for POST /api/v1/translate/{jobId}/page-range. Absent on a part and while the feature is off. — may be null |
| `pageRangeOffer.pageCount` | integer | no | Pages in the file. |
| `pageRangeOffer.chapters` | array \| null | no | Chapters from the PDF outline, in order. Null when the PDF has no usable outline. — may be null |
| `pageRange` | object \| null | no | On a part of a file: the pages it covers. Absent on a whole file. — may be null |
| `pageRange.from` | integer | no | First page of the part (1-based). |
| `pageRange.to` | integer | no | Last page of the part (1-based, inclusive). |
| `pageRange.totalPages` | integer \| null | no | Pages in the whole file. — may be null |
| `pageRange.sourceJobId` | string \| null | no | The job the part was cut from, or null for an upload. — may be null |
| `imageTranslation` | object \| null | no | Translating the text inside images (charts, diagrams, infographics). The number of images with text is known only after the document is read, so the price is per image and is added to the charge. Switch it off with `translateImages: false` at start. — may be null |
| `imageTranslation.available` | boolean | no | True when image translation can be chosen for this document. |
| `imageTranslation.default` | boolean | no | True: it is on unless the start request sends `translateImages: false`. |
| `imageTranslation.pricePerImage` | number | no | Expected price in Fara of one image that has text to translate. Images without text cost nothing. |
| `totalChunks` | integer | no |  |
| `completedChunks` | integer | no |  |
| `processingStage` | string \| null | no | `extracting`, `preparing`, `translating`, or null. Display only. — may be null |
| `translationStep` | integer \| null | no | Rough progress marker while translating. Display only; use `progress` for how far the job is. — may be null |
| `progress` | integer | no | 0-100. |
| `createdAt` | string \| null | no | may be null |
| `completedAt` | string \| null | no | may be null |
| `error` | string \| null | no | Always null for API keys. — may be null |
| `errorCode` | string \| null | no | Always null for API keys. Use `customerErrorCode`. — may be null |
| `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 |
| `userRetryCount` | integer | no |  |
| `retryLocked` | boolean | no |  |
| `adminReviewRequired` | boolean | no |  |
| `reviewReasonCode` | string \| null | no | may be null |
| `outputs` | object \| null | no | may be null |
| `outputs.docx` | string \| null | no | may be null |
| `outputs.pdf` | string \| null | no | may be null |
| `hasEmptyChunks` | boolean | no |  |
| `emptyChunkCount` | integer | no |  |
| `emptyChunkNumbers` | integer[] | no |  |
| `hasFailedChunks` | boolean | no |  |
| `failedChunkCount` | integer | no |  |
| `failedChunkNumbers` | integer[] | no |  |
| `images` | object \| null | no | Only while `status` is `images_waiting`. Can be null for a moment after a choice or a cancel, or when the record cannot be read; then read it again. |
| `retryableChunkCount` | integer | no |  |
| `retryableChunkNumbers` | integer[] | no |  |
| `failedChunksDetail` | object[] | no | One entry per section that did not translate. |
| `failedChunksDetail[].chunkNumber` | integer | no |  |
| `failedChunksDetail[].error` | string | no | Text for logs. Do not parse. Not always present. |
| `failedChunksDetail[].isTimeout` | boolean | no |  |
| `failedChunksDetail[].isCircuitOpen` | boolean | no |  |
| `failedChunksDetail[].retryable` | boolean | no |  |
| `failedChunksDetail[].failedAt` | string | no | Not always present. |
| `hasQualityWarnings` | boolean | no |  |
| `qualitySummary` | object \| null | no | Quality summary. — may be null |
| `qualityFlaggedChunkNumbers` | integer[] | no |  |
| `outputWarnings` | object[] | no | Always empty for API keys. |
| `outputWarningCount` | integer | no |  |
| `source` | string | no | Internal detail. Ignore. |
| `freePreviewOffer` | object \| null | no | The free first pages: each verified account may translate the first pages of one PDF free, once. Only while `analyzed`; null otherwise or when switched off. — may be null |
| `freePreviewOffer.available` | boolean | no | True when this account can translate the first pages of this document free now. |
| `freePreviewOffer.pages` | integer | no | How many leading pages are free. |
| `freePreviewOffer.freePages` | integer | no | Free pages of this document (fewer when the document is shorter). |
| `freePreviewOffer.wholeDocument` | boolean | no | The whole document fits in the free pages. |
| `freePreviewOffer.reason` | string \| null | no | Why it is not available: `disabled`, `not_verified`, `used`, `rest_of_preview`, or null. — may be null |
| `freePreview` | object \| null | no | On a free preview job; null on other jobs. — may be null |
| `freePreview.pages` | integer \| null | no | Free pages translated. — may be null |
| `freePreview.totalPages` | integer \| null | no | Pages in the whole document. — may be null |
| `freePreview.hasRest` | boolean | no | The document has pages after the free part. |
| `freePreview.restEstimatedPrice` | number \| null | no | About what the rest costs, in Fara, at the default delivery. — may be null |
| `freePreview.restJobId` | string \| null | no | The job made by POST /api/v1/translate/{jobId}/translate-rest, once made. — may be null |
| `previewOf` | string \| null | no | On the rest of a previewed book: the free preview job it follows. — may be null |

<a id="schema-upload-request"></a>
### UploadRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `file` | file | yes | The PDF (up to 100 MB). When Word and EPUB input is on, a `.docx` or EPUB file is accepted too. |
| `pageFrom` | string | no | Applies when the page-range feature is on (otherwise ignored): first page to translate, 1-based. Give it with `pageTo`; the file is cut to these pages before analysis, and the job is a part of the file. |
| `pageTo` | string | no | Applies when the page-range feature is on (otherwise ignored): last page to translate, 1-based, inclusive. |
| `quality` | string | no | Deprecated. It no longer changes the result; the translation keeps the tone of the source. Still accepted. — one of: `simple`, `medium`, `highest` |
| `workflow` | string | no | Translation workflow. Leave out for the default. |

<a id="schema-upload-response"></a>
### UploadResponse

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobId` | string | yes |  |
| `workflow` | string | no |  |
| `availableWorkflows` | string[] | no |  |
| `message` | string | no |  |
| `totalChunks` | integer | no |  |
| `status` | string | yes | `pending`. |
