# API reference: Content

> The Content endpoints (6 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

- **Content**: [POST /api/v1/content/translate](#translateContent), [POST /api/v1/content/edit](#editContent), [GET /api/v1/content/jobs](#listContentJobs), [GET /api/v1/content/jobs/{id}](#getContentJob), [DELETE /api/v1/content/jobs/{id}](#deleteContentJob), [DELETE /api/v1/content/memory](#clearContentMemory)

## Content

Website and app copy (JSON, Markdown, HTML, strings) into Persian, in the same structure.

<a id="translateContent"></a>
### POST /api/v1/content/translate

Translate website or app copy into Persian

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

Send English copy as JSON (an i18n file), Markdown, HTML or strings; get the same structure back with natural Persian: same keys, same placeholders (`{name}`, `{{count}}`, `%s`, ICU plural), same tags, links and code. Every string is checked before it is returned (placeholders kept, no English left, length limits); a string that fails is listed in `failed` and keeps its English text.

Price: the model's token cost at our rate, never more than `quote.maxFara`, which is held when the work starts. Strings in your translation memory are free. Price first with `dryRun: true` (or POST /api/v1/estimate with `content_translation`).

Up to about 1,000 words of new text is answered in the same call (200, with `content`). More, or `async: true`, answers 202 with the job: poll GET /api/v1/content/jobs/{id} or listen for `content.completed` webhooks. A request whose strings all come from memory answers 200 at once with `id: null` and nothing charged.

**Parameters**

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

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

[`ContentTranslateRequest`](#schema-content-translate-request)

**Response `200`**

**Responses**

- `200` Translated (or, with `dryRun`, the quote: `ContentTranslationQuoteResponse`). (`application/json`)
- `202` Started in the background. Poll the job in `links.self`. (`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/content/translate" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"format":"json","content":"string"}'
```

<a id="editContent"></a>
### POST /api/v1/content/edit

Edit Persian text into natural, native Persian

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

Not a translation: send Persian text (AI copy, a literal translation, stiff prose, or ordinary copy) as JSON, Markdown, HTML or strings, and get every sentence back written again, in full, the way an Iranian writer would write it today (headings are written again as headings; buttons, labels and fixed section names keep their usual wording), with the same meaning and the same structure: same keys, placeholders, tags, links and code. Strings without Persian letters, text in Arabic, Urdu, Kurdish or Pashto, and single slugs, paths and file names are left as they are; digits stay as written by default.

Every edit is checked before it is returned: placeholders kept, every number of the original still there with the same value, the English words of the original and `keep` words kept, no English added, no summary (the length stays near the original), length limits. An edit that does not pass is not used: the string keeps its original text and is listed in `failed`. `changes` says, per string, whether it changed and why, in one short Persian note.

Price: the model's token cost at our rate, never more than `quote.maxFara`, which is held when the work starts. Price first with `dryRun: true`. Small work answers in the same call (200); more, or `async: true`, answers 202 with the job to poll at GET /api/v1/content/jobs/{id}.

**Parameters**

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

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

[`ContentEditRequest`](#schema-content-edit-request)

**Response `200`**

**Responses**

- `200` Edited (or, with `dryRun`, the quote: `ContentEditQuoteResponse`). (`application/json`)
- `202` Started in the background. Poll the job in `links.self`. (`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/content/edit" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"format":"json","content":"string"}'
```

<a id="listContentJobs"></a>
### GET /api/v1/content/jobs

List content translation jobs

- operationId `listContentJobs` · scope `read` · free

Newest first, without `content`. Jobs and results are kept for 7 days.

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

**Response `200`**

[`ContentTranslationJobList`](#schema-content-translation-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/content/jobs" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="getContentJob"></a>
### GET /api/v1/content/jobs/{id}

Get a content job (translation or editing), with the result when finished

- operationId `getContentJob` · scope `read` · free

**Parameters**

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

**Response `200`**

**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/content/jobs/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY"
```

<a id="deleteContentJob"></a>
### DELETE /api/v1/content/jobs/{id}

Delete a finished content translation job

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

Removes the job and its result. Ledger rows and translation memory stay. A running job answers 409 `JOB_NOT_FINISHED`.

**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/content/jobs/$ID" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

<a id="clearContentMemory"></a>
### DELETE /api/v1/content/memory

Clear your translation memory

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

Removes the stored translations of the account, or of one `project`. Later requests translate (and charge for) every string again. Memory not used for a year is removed on its own.

**Parameters**

| Name | In | Type | Required | Notes |
|---|---|---|---|---|
| `project` | query | string | no | Only this project's memory. Leave out to clear all. — max length 100 |
| `Idempotency-Key` | header | string | no | see /api/v1/docs/conventions#idempotency |

**Response `200`**

[`ContentMemoryCleared`](#schema-content-memory-cleared)

**Responses**

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

**Example**

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

## Schemas

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

<a id="schema-content-edit-request"></a>
### ContentEditRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `format` | string | yes | How `content` is written: `json`, `markdown`, `html` or `strings`, as for translation. — one of: `json`, `markdown`, `html`, `strings` |
| `content` | object \| any[] \| string | yes | The Persian text, in the shape `format` names. The answer has the same shape with the edited text. Strings without Persian letters (English, code, numbers) are left as they are. |
| `brief` | string | no | What the text is and who reads it, in one or two sentences (up to 2000 characters). — max length 2000 |
| `tone` | string | no | The register. `source` (default): keep each text's own register. `neutral`: polite everyday written Persian. `formal`: official. `friendly`: warm, written. `conversational`: everyday spoken Persian as Iranians write it in chats. — one of: `source`, `neutral`, `formal`, `friendly`, `conversational` |
| `digits` | string | no | `source` (default): digits stay as written. `persian` or `latin`: write numbers in those digits. The values never change. — one of: `source`, `persian`, `latin` |
| `keep` | string[] | no | Words and names to leave exactly as written. Up to 500. |
| `glossary` | object \| object[] | no | Terms to write one way everywhere: `{ "as the text has it": "write this" }` (or a list of `{ term, use }`). Where a string has the first form, the edit has the second, and the first form is never written. Whole words; up to 500 entries. To pin a word as it is, use `keep`. |
| `orthography` | string | no | `source` (default): the writer's spelling style stays where Persian accepts more than one form (half-spaces in compounds, لطفا / لطفاً, متاسفانه / متأسفانه, the ezafe mark on ه); only plain mistakes are corrected. `standard`: standard Persian orthography (half-spaces in compounds and affixes, tanvin, hamza); the ezafe mark on ه still follows the text. — one of: `source`, `standard` |
| `minWords` | integer | no | Strings with fewer words than this are left as they are (labels, buttons, short headings). Default 1: every Persian string is read. — min 1; max 20 |
| `depth` | string | no | Deprecated and ignored: every sentence is written again in full. Accepted so older requests do not fail. — one of: `full`, `light` |
| `maxGrowthPercent` | integer | no | An edit may not be longer than the original by more than this percentage; for text with line breaks (`<br>`, a new line) the limit holds for each line. An edit over the limit is tried once more, then the string keeps its original text and is listed in `failed`. — min 0; max 100 |
| `onlyChanged` | boolean | no | `true`: `changes` lists only the strings that changed. Default false: one entry per Persian string. |
| `notes` | object | no | Per string: where it is used, and an optional length limit, as for translation. |
| `skipKeys` | string[] | no | `json`: key paths to leave as they are. Parts are joined by dots; `*` matches inside one part and `**` any number of parts: `meta.*`, `**.url`, `items.*.title` (or `items[*].title`). A pattern that matches no string is reported in `warnings`. |
| `frontMatterKeys` | string[] | no | `markdown`: front-matter keys whose values are edited. Default `title`, `description`, `summary`, `excerpt`, `subtitle`. |
| `setDirection` | boolean | no | `html`: on a full page, set `lang="fa" dir="rtl"` on `<html>`. Default false for editing (the page keeps its own). |
| `project` | string | no | Your name for the site or app (letters, digits, `_ . -`). Edits are remembered per project, apart from translations. — max length 100 |
| `memory` | string | no | `use` (default): strings edited before come back the same and are free. `refresh`: edit again. `off`: do not read or save memory. — one of: `use`, `refresh`, `off` |
| `async` | boolean | no | Always run in the background and answer 202, even for small work. |
| `dryRun` | boolean | no | Only price the request: nothing is edited, held or charged. |
| `externalId` | string | no | Your own reference for this job (up to 200 characters). |
| `metadata` | object | no | Up to 20 keys of your own (strings, numbers, booleans; 4 KB as JSON). |

<a id="schema-content-memory-cleared"></a>
### ContentMemoryCleared

| Field | Type | Required | Notes |
|---|---|---|---|
| `deleted` | integer | yes | Memory entries removed. |

<a id="schema-content-translate-request"></a>
### ContentTranslateRequest

| Field | Type | Required | Notes |
|---|---|---|---|
| `format` | string | yes | How `content` is written: `json` (any object or array, e.g. an i18n file), `markdown`, `html` (a page or a fragment), or `strings` (a string or an array of strings). — one of: `json`, `markdown`, `html`, `strings` |
| `content` | object \| any[] \| string | yes | The English text, in the shape `format` names. The answer has the same shape: the same keys in the same order, the same Markdown and HTML structure, with Persian text. |
| `brief` | string | no | What the product is and who reads it, in one or two sentences (up to 2000 characters). The more we know, the better the Persian fits. — max length 2000 |
| `tone` | string | no | `neutral` (default): polite everyday Persian. `formal`: official. `friendly`: warm and conversational. The reader is always addressed as «شما». — one of: `neutral`, `formal`, `friendly` |
| `digits` | string | no | Numbers in Persian digits (`persian`, default) or Latin digits (`latin`). Digits inside placeholders, links and code never change. — one of: `persian`, `latin` |
| `glossary` | object \| object[] | no | Terms that must be translated one way, as `{ "dashboard": "پیشخوان" }` or `[{ "term": "dashboard", "translation": "پیشخوان" }]`. A translation equal to the term keeps it in English. Up to 500 terms. |
| `keep` | string[] | no | Words and names to leave in English everywhere (brand and product names). Up to 500. |
| `notes` | object | no | Per string: where it is used, and an optional length limit. Keys are the JSON key paths (`hero.title`, `plans[0].name`) or, for `strings`, the index (`"0"`). A value is a note (`"button"`) or `{ "note": "button", "maxLength": 20 }`. The Persian is never longer than `maxLength` characters. |
| `skipKeys` | string[] | no | `json`: key paths to leave as they are. Parts are joined by dots; `*` matches inside one part and `**` any number of parts: `meta.*`, `**.url`, `items.*.title` (or `items[*].title`). A pattern that matches no string is reported in `warnings`. Values that look like data (ids, paths, colours, dates, file names) are left out already. |
| `frontMatterKeys` | string[] | no | `markdown`: front-matter keys whose values are translated. Default `title`, `description`, `summary`, `excerpt`, `subtitle`. |
| `setDirection` | boolean | no | `html`: on a full page, set `lang="fa" dir="rtl"` on `<html>`. Default true. |
| `project` | string | no | Your name for the site or app (letters, digits, `_ . -`). Translation memory is kept per project, so two products do not share translations. Default: one shared memory for the account. — max length 100 |
| `memory` | string | no | `use` (default): strings translated before for this account and project come back the same and are free; new ones are saved. `refresh`: translate everything again and save the new Persian. `off`: do not read or save memory. — one of: `use`, `refresh`, `off` |
| `async` | boolean | no | Always run in the background and answer 202, even for small work. |
| `dryRun` | boolean | no | Only price the request: nothing is translated, held or charged. |
| `externalId` | string | no | Your own reference for this job (up to 200 characters). Echoed in the job and its webhook events. |
| `metadata` | object | no | Up to 20 keys of your own (strings, numbers, booleans; 4 KB as JSON). Echoed in the job and its webhook events. |

<a id="schema-content-translation-job-list"></a>
### ContentTranslationJobList

| Field | Type | Required | Notes |
|---|---|---|---|
| `jobs` | object \| object[] | yes |  |
