# Faraatarjomeh API — full documentation > Every page of https://faraatarjomeh.com/api/v1/docs in one Markdown file, in reading order. Per-page Markdown and an index: https://faraatarjomeh.com/api/v1/docs/llms.txt. The contract: https://faraatarjomeh.com/api/v1/openapi.json. The endpoint-by-endpoint reference is not bundled here (it is large). Fetch it whole at https://faraatarjomeh.com/api/v1/docs/reference.md or one area at a time: https://faraatarjomeh.com/api/v1/docs/reference/account.md, https://faraatarjomeh.com/api/v1/docs/reference/translation.md, https://faraatarjomeh.com/api/v1/docs/reference/jobs.md, https://faraatarjomeh.com/api/v1/docs/reference/ai-tools.md, https://faraatarjomeh.com/api/v1/docs/reference/video.md, https://faraatarjomeh.com/api/v1/docs/reference/meetings.md, https://faraatarjomeh.com/api/v1/docs/reference/audio.md, https://faraatarjomeh.com/api/v1/docs/reference/farsi-tts.md, https://faraatarjomeh.com/api/v1/docs/reference/transcription.md, https://faraatarjomeh.com/api/v1/docs/reference/content.md, https://faraatarjomeh.com/api/v1/docs/reference/uploads.md, https://faraatarjomeh.com/api/v1/docs/reference/webhooks.md, https://faraatarjomeh.com/api/v1/docs/reference/payments.md, https://faraatarjomeh.com/api/v1/docs/reference/ai-assistants.md, https://faraatarjomeh.com/api/v1/docs/reference/profile.md. The same contract as JSON: https://faraatarjomeh.com/api/v1/openapi.json. # Faraatarjomeh API > HTTP API for Faraatarjomeh (فراترجمه): English→Persian document translation and related tools (video, meeting minutes, podcasts and audiobooks, Persian text-to-speech, transcription). Every feature of the website is available with an API key. Work is paid in Fara from the key owner's account. ## At a glance - Every capability in one list: [Everything the API can do](https://faraatarjomeh.com/api/v1/docs/capabilities.md) - Base URL: `https://faraatarjomeh.com` - All endpoints: under `/api/v1` - Auth: `Authorization: Bearer fara_sk_...` (secret key, server-to-server only) — [Authentication](https://faraatarjomeh.com/api/v1/docs/authentication.md) - Formats: JSON requests and responses; `multipart/form-data` for file uploads (or raw `application/octet-stream` chunks for [chunked uploads](https://faraatarjomeh.com/api/v1/docs/guides/chunked-uploads.md)); errors are `application/problem+json` (RFC 9457) - Money: prices and charges are in Fara; check the balance with `GET /api/v1/account` — [Billing](https://faraatarjomeh.com/api/v1/docs/billing.md) - Long work is asynchronous: create a job, then poll it or receive a webhook — [Conventions](https://faraatarjomeh.com/api/v1/docs/conventions.md), [Webhooks](https://faraatarjomeh.com/api/v1/docs/webhooks.md) - Safe retries: send `Idempotency-Key` on every POST that spends Fara - Machine-readable contract: [OpenAPI 3.1](https://faraatarjomeh.com/api/v1/openapi.json) · [error catalog (JSON)](https://faraatarjomeh.com/api/v1/docs/errors.json) · [llms.txt](https://faraatarjomeh.com/api/v1/docs/llms.txt) · [all docs in one file](https://faraatarjomeh.com/api/v1/docs/llms-full.txt) - Every page of these docs is also plain Markdown: add `.md` to its URL, or send `Accept: text/markdown`. ## The universal flow Every paid feature follows the same four steps: 1. **Price.** Ask for the price before spending (an analysis, an estimate, or a pricing endpoint). Compare it with the balance from `GET /api/v1/account`. 2. **Create.** Send the POST that starts the work, with an `Idempotency-Key`. Fara is held for the job. `402` with code `INSUFFICIENT_CREDITS` means the balance is too low. 3. **Wait.** Poll the job, or receive a webhook when its status changes. Some jobs stop at a review status and wait for you to approve. 4. **Collect.** Download the result. The hold becomes the real charge; unused Fara comes back. Failed or cancelled jobs cost nothing. ## Which page for which task | Task | Guide | First call | |---|---|---| | Try the API end to end in 5 minutes | [Quickstart](https://faraatarjomeh.com/api/v1/docs/quickstart.md) | `GET /api/v1/account` | | Translate a PDF (English → Persian) | [PDF translation](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md) | `POST /api/v1/translate/analyze` | | Summary, slides, mind map, LinkedIn posts, proofreading of a translated PDF | [Translation tools](https://faraatarjomeh.com/api/v1/docs/guides/translation-tools.md) | `GET /api/v1/translate/{jobId}/summary` | | Translate or dub a YouTube video or a video file | [Video](https://faraatarjomeh.com/api/v1/docs/guides/video.md) | `POST /api/v1/video/jobs/estimate` | | Minutes from a meeting recording | [Meeting minutes](https://faraatarjomeh.com/api/v1/docs/guides/meeting-minutes.md) | `GET /api/v1/meetings/pricing` | | Timed minutes, chapters, speaker names, context, revising by instruction, more documents, branding, categories, highlights, questions, analytics, delete (early access) | [Meetings: early-access features](https://faraatarjomeh.com/api/v1/docs/guides/meeting-extras.md) | `GET /api/v1/meetings/templates` | | Podcast or audiobook from a translated PDF | [Podcast and audiobook](https://faraatarjomeh.com/api/v1/docs/guides/podcast-audiobook.md) | `GET /api/v1/audio/pricing` | | Website or app text (i18n JSON, Markdown, HTML) in natural Persian, same structure | [Website and app copy](https://faraatarjomeh.com/api/v1/docs/guides/content-translation.md) | `POST /api/v1/content/translate` with `dryRun: true` | | Persian text written again in natural, native Persian (not a translation) | [Persian editing](https://faraatarjomeh.com/api/v1/docs/guides/persian-editing.md) | `POST /api/v1/content/edit` with `dryRun: true` | | Persian speech from text | [Persian text-to-speech](https://faraatarjomeh.com/api/v1/docs/guides/farsi-tts.md) | `GET /api/v1/farsi-tts/pricing` | | Text or subtitles from a recording | [Transcription](https://faraatarjomeh.com/api/v1/docs/guides/transcription.md) | `GET /api/v1/transcription/pricing` | | Send a large recording (up to 1 GB) in chunks, for a meeting, transcription or video job | [Chunked uploads](https://faraatarjomeh.com/api/v1/docs/guides/chunked-uploads.md) | `POST /api/v1/uploads` | | Get told when jobs finish | [Webhooks](https://faraatarjomeh.com/api/v1/docs/webhooks.md) | `POST /api/v1/webhook-endpoints` | | You are an AI agent acting for a user | [Rules for AI agents](https://faraatarjomeh.com/api/v1/docs/agents.md) | `GET /api/v1/account` | | Look up one endpoint | [API reference](https://faraatarjomeh.com/api/v1/docs/reference.md) | — | | Decide what to do with an error | [Errors](https://faraatarjomeh.com/api/v1/docs/errors.md) | — | ## What you cannot do with an API key These stay on the website, for the account owner: sign in, change password or profile, buy Fara, and create or revoke API keys. A key that calls them gets `403` with code `API_KEY_ROUTE_NOT_ALLOWED`. A key never has admin rights. ## Support Every response has an `X-Correlation-Id` header; error bodies repeat it as `request_id`. You may send your own id in an `X-Request-Id` request header and it is used instead. Include it when you contact support through https://faraatarjomeh.com/contact. --- # Everything the API can do > One list of every capability of the Faraatarjomeh API, by product, with what is free, what is paid, and what needs early access. Each line links to the guide with the full contract. Use it to plan an integration or to check whether a feature exists before building it yourself. ## At a glance - Products: PDF translation, translation tools, video translation and dubbing, meeting minutes, audio-to-text, Persian text-to-speech, podcast and audiobook. - Shared by all products: one price call, chunked uploads, webhooks, idempotent retries, the account and its ledger. - Paid work: Fara is held when the job starts, the real cost is charged when it finishes (it can be above the hold when your balance covers the difference), and failed or cancelled work costs nothing. See [Billing](https://faraatarjomeh.com/api/v1/docs/billing.md). - Early access: features marked **early access** need `meetings_api_v2` in `earlyAccess` of `GET /api/v1/account`. Ask us to turn it on. Other accounts get `403` [`FEATURE_NOT_ENABLED`](https://faraatarjomeh.com/api/v1/docs/errors.md#error-feature-not-enabled). - Not available to API keys: sign-in, buying Fara, and creating or revoking keys (website only). ## For every product | Capability | How | Cost | |---|---|---| | Price any job before spending | `POST /api/v1/estimate` (translation, meeting, audio-to-text, video, Persian voice, podcast, audiobook, paid meeting tools) | free | | Balance, held Fara, early-access list | `GET /api/v1/account` | free | | Ledger, filter by job or your reference | `GET /api/v1/account/transactions` (`?jobId=`, `?externalId=`) | free | | Send large files (up to 1 GB) in resumable chunks of 256 KB to 8 MB | `POST /api/v1/uploads` — [Chunked uploads](https://faraatarjomeh.com/api/v1/docs/guides/chunked-uploads.md) | free | | Get told when a job changes status (signed, retried for about 3 days) | `POST /api/v1/webhook-endpoints` — [Webhooks](https://faraatarjomeh.com/api/v1/docs/webhooks.md) | free | | Retry any POST safely | `Idempotency-Key` header — [Conventions](https://faraatarjomeh.com/api/v1/docs/conventions.md#idempotency) | free | | Cancel a running job and release its hold | `POST …/cancel` on every product | free | | Low-balance alert (**early access**) | `PATCH /api/v1/account/settings` with `lowBalanceThreshold` → `account.balance_low` webhook | free | | Spend limit per API key, per day or month (**early access**) | set on the website; over the limit → `402 SPEND_LIMIT_REACHED` | free | | Machine-readable contract | [OpenAPI 3.1](https://faraatarjomeh.com/api/v1/openapi.json), [error catalog](https://faraatarjomeh.com/api/v1/docs/errors.json), [llms.txt](https://faraatarjomeh.com/api/v1/docs/llms.txt) | free | ## PDF translation English PDF → Persian PDF and Word file, right-to-left. Word (`.docx`) and EPUB files are accepted as input when the site has that switched on; they are converted to PDF first. Guide: [PDF translation](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md). - Analyze first, free: word and page count, the price, a short sample translation when available (`POST /api/v1/translate/analyze`, or `POST /api/v1/translate/analyze-stream` with live progress). - `quality` is still accepted, but it no longer changes the result. The translation keeps the tone of the source. - One speed: every translation starts at once and runs fast; the analysis gives its estimated minutes. - Books up to 1,000 pages. - Scanned PDFs: read from page images, priced from page count; `NO_TEXT_LAYER` if nothing is readable (no charge). - Text in images: per image, optional (`translateImages`); asks when the balance is short (`images_waiting`). - Outputs: PDF and DOCX, made again on request if a file is missing. - Progress, retry, recover and cancel calls on the job; webhooks for analyzed, completed, partial, failed and cancelled. - One-call options: upload and start at once (`POST /api/v1/translate/upload`, fast only), and a magazine-layout translation that returns the PDF in the same answer (`POST /api/v1/translate/magazine-translate-pdf`). - Reformat a PDF that is already in Persian into a clean Persian PDF, without translating (`POST /api/v1/translate/extract-farsi-book-pdf`, free). ## Translation tools Extra content from a finished translation. Guide: [Translation tools](https://faraatarjomeh.com/api/v1/docs/guides/translation-tools.md). | Tool | Cost | |---|---| | Persian summary, and its PDF | free, made with the translation | | Slides (PPTX and PDF) | actual cost | | Mind map, and its PDF | actual cost | | LinkedIn posts | actual cost | | Podcast (two voices) or audiobook (one narrator) — [guide](https://faraatarjomeh.com/api/v1/docs/guides/podcast-audiobook.md) | per minute of audio | ## Video translation and dubbing A YouTube link or your own video file (MP4, MOV, MKV, WebM, AVI) → a Persian video. Guide: [Video](https://faraatarjomeh.com/api/v1/docs/guides/video.md). - Three outputs: Persian subtitles, a Persian voice, or both. - Voices: standard or premium, male or female, or the original speaker's own voice (premium). - Optional review: stop before the video is made, correct any line, then approve. - Downloads: MP4, a preview, and WebVTT captions. - Retry, resume and reprocess a job; webhooks for every status. ## Meeting minutes A meeting recording → minutes (summary, topics, decisions, action items). Guides: [Meeting minutes](https://faraatarjomeh.com/api/v1/docs/guides/meeting-minutes.md) and [Meetings: early-access features](https://faraatarjomeh.com/api/v1/docs/guides/meeting-extras.md). For every account: - Minutes in Persian or English (`outputLanguage`), as full minutes, a summary, key points, or the transcript only (`output`). - PDF, Word file, and a one-page A4 summary. - A free mind map (`mindmap: true` at upload). - The transcript as JSON (with word timings), TXT, SRT or WebVTT. - Your company logo on the documents. - Recordings up to 4 hours; large files through chunked uploads. With **early access**: | Capability | Cost | |---|---| | Upload by link (`audioUrl`, presigned links work) instead of sending the file | free | | Your own `externalId` and `metadata` on the job, webhooks and ledger; find jobs by them or by `Idempotency-Key` | free | | Attendee names, participants from your attendance data, and a meeting template (`general`, `standup`, `sales`, `interview`, `technical`, `board`) | free | | A word list for names and product words (heard by the transcriber, used by the minutes writer) | transcription costs 20% more | | Timed minutes: when each topic, decision and action item happened, and who said it | free | | Chapters | free | | Speaker list with samples; rename speakers everywhere | free | | Correct the transcript and rebuild the minutes from it | rebuild is paid | | Meeting context: chat, shared notes and events, used by the minutes and answers | free | | Revise the minutes by instruction (for example from your chat box), with the last 20 versions kept for undo | paid | | More documents from a finished meeting (full, summary, key points, transcript; PDF or Word) | 1 Fara each | | A mind map for a meeting created without one | 1 Fara | | Branding: company name, header, footer, confidentiality notice and colours | free | | Your own meeting categories; each meeting gets one category and 1-3 tags | free | | Highlights, each with the speaker's exact words and time | paid | | Ask a question about one meeting, or across up to 20 meetings, with citations | paid | | Recap email (subject, Markdown, HTML) | paid | | Analytics: talk time, turns, interruptions, pace, and text-based sentiment and engagement | paid | | Digest of several meetings | paid | | One list of every rebuild, revision, document and mind map on a meeting | free | | Webhooks when a revision, rebuild, document or mind map is ready | free | | Permanent delete, and auto-delete after a number of days | free | ## Audio-to-text A recording → text with speaker labels and timings, optionally translated into Persian or English. Guide: [Transcription](https://faraatarjomeh.com/api/v1/docs/guides/transcription.md). - Downloads: TXT, SRT, PDF and Word, for the original text and the translation. - Recordings up to 4 hours; large files through chunked uploads. - **Early access**: upload by link, `externalId` and `metadata`, lookups by them, and permanent delete or auto-delete. ## Website and app copy English website or app text → natural Persian in the same file: an i18n JSON file, Markdown pages, HTML or a list of strings. Keys, placeholders, ICU plurals, tags, links and code stay as they are; every string is checked before it comes back. A per-account translation memory makes strings sent again free and keeps terms the same. Priced at the model's token cost at our rate, never above the quote. Guide: [Website and app copy](https://faraatarjomeh.com/api/v1/docs/guides/content-translation.md). ## Persian editing Persian text in, natural native Persian out (not a translation): AI-written copy, literal translations and stiff prose rewritten the way an Iranian writer would write them today, in any register from formal to conversational, with the same meaning and the same file structure as for website copy. Each edit is checked (placeholders, every number, no added English, no summary) and comes back with a per-string `changed` flag and a short note. Priced at the model's token cost at our rate, never above the quote. Guide: [Persian editing](https://faraatarjomeh.com/api/v1/docs/guides/persian-editing.md). ## Persian text-to-speech Text → Persian speech (MP3). English text is translated first; you can read and edit the Persian text before the audio is made. Guide: [Persian text-to-speech](https://faraatarjomeh.com/api/v1/docs/guides/farsi-tts.md). ## Podcast and audiobook A finished translation → a Persian podcast (two voices talk about the book) or audiobook (one narrator). You choose the voices and their mood (`voiceMood`), read the script, edit any line, then approve. Guide: [Podcast and audiobook](https://faraatarjomeh.com/api/v1/docs/guides/podcast-audiobook.md). --- # Rules for AI agents > Instructions for an AI agent (or any automated client) that calls this API for a user. Every paid call spends the user's real money (Fara). Follow these rules exactly. ## At a glance - Read first: this page, then [Conventions](https://faraatarjomeh.com/api/v1/docs/conventions.md), then the guide for the task (see the table on [the overview](https://faraatarjomeh.com/api/v1/docs/index.md)). - Machine-readable: [OpenAPI](https://faraatarjomeh.com/api/v1/openapi.json), [error catalog](https://faraatarjomeh.com/api/v1/docs/errors.json), [all docs as one Markdown file](https://faraatarjomeh.com/api/v1/docs/llms-full.txt). - Branch on the error `code`, never on the human `detail` text. ## Getting access The user only needs an account with Fara on https://faraatarjomeh.com (new accounts get a sign-up gift). Then, in this order of preference: 1. **You speak MCP** (Claude, ChatGPT, Cursor, Claude Code and others): connect to `https://faraatarjomeh.com/api/v1/mcp`. The user signs in in the browser, picks a spending limit for you (500 Fara is suggested; it counts over the whole connection) and allows you; nothing to copy. See [AI assistants (MCP)](https://faraatarjomeh.com/api/v1/docs/guides/mcp.md). 2. **Any other agent or script:** sign in with a code. POST to `https://faraatarjomeh.com/api/v1/oauth/device`, show the user the code and link, poll `https://faraatarjomeh.com/api/v1/oauth/token`, and you get your own key with the monthly limit the user chose. See [Sign an agent in with a code](https://faraatarjomeh.com/api/v1/docs/authentication.md#sign-an-agent-in-with-a-code-no-key-to-copy). 3. **The user already has a key:** use it as `Authorization: Bearer fara_sk_...`. Files: send a public https link (`fileUrl` for documents, `audioUrl` for recordings); you never need a multipart upload. ## Spending rules 1. **Price before spending.** Get the price first (analysis, estimate, or pricing endpoint — each guide names it). Never start paid work without a price. 2. **Stay inside the approved budget.** Only spend what the user approved for this task. If the price is above that, stop and ask the user. If the user gave no budget, ask before the first paid call. 3. **Check the balance.** `GET /api/v1/account` → `credits.balance` is what can be spent now. If the price is more than the balance, tell the user to top up at https://faraatarjomeh.com; an API key cannot buy Fara. 4. **One job per intent.** Send a fresh `Idempotency-Key` (a UUID) with every POST that can spend Fara, store it with the task, and reuse the **same** key on every retry of that POST. A retry with the same key returns the first answer and never charges twice. Never create a second job to "retry" a job that is still running. 5. **Paid calls in the reference** are marked `x-spends-fara: true` in the OpenAPI document and "spends Fara" in [the reference](https://faraatarjomeh.com/api/v1/docs/reference.md). 6. **Account for what was spent.** The real cost of a job is the sum of `balanceChange` over its ledger rows: `GET /api/v1/account/transactions?jobId={jobId}` (see [Billing](https://faraatarjomeh.com/api/v1/docs/billing.md)). Report it to the user. ## Waiting rules 1. **Prefer webhooks** if you have a public https endpoint ([Webhooks](https://faraatarjomeh.com/api/v1/docs/webhooks.md)). Otherwise poll. 2. **Polling intervals:** first check after 10 s, then back off to every 30–60 s. Never poll faster than every 5 s per job. 3. **Unknown status values:** treat them as "still running". Only the terminal statuses listed in each guide's state machine end a job. 4. **Review statuses** (`awaiting_review`): the job waits for a decision. Approve automatically only if the user told you to; otherwise show the user what to review and wait. ## Error rules Every error is `application/problem+json` with a stable `code`. Look the code up in the [error catalog](https://faraatarjomeh.com/api/v1/docs/errors.json) and follow its `retry` rule: | `retry` | What to do | |---|---| | `do_not_retry` | Stop. Fix what the error names (or ask the user if `needsUser` is true). Sending it again fails the same way. | | `refresh_then_retry` | GET the resource again, rebuild the request from the fresh data, send it once more. | | `retry_later` | Send the same request with the same `Idempotency-Key` after `Retry-After` seconds, or back off 2 s, 4 s, 8 s … up to 5 minutes. Give up after about 30 minutes and tell the user. | | `check_then_retry` | `500`/`502`/`504`: the work may have happened and this answer is replayed for the same key. List the jobs (or the ledger) to see if it happened. Only if not, send again with a **new** `Idempotency-Key`. | | `wait` | Send nothing. The job already runs; poll it. | Special cases: - `402 INSUFFICIENT_CREDITS` — stop and tell the user the price and the balance (the body has `balance` and `estimatedCost`, `cost` or `required`). Give the user `topUpUrl` from the body: the website page where they add Fara (it suggests a pack that covers `shortfall`). An API key cannot buy Fara. After they pay, send the same request again. - `402 SPEND_LIMIT_REACHED` — the key's own limit, not the balance. Give the account owner `limitsUrl` to raise it. - `429 RATE_LIMITED` — wait `Retry-After` seconds. Read the `RateLimit` header to slow down before you hit the limit. - Network error or timeout on a POST — resend it with the same `Idempotency-Key`. You get the stored first answer or `409 IDEMPOTENCY_KEY_IN_USE` (wait and resend). ## Safety rules - The API key is a secret with access to the user's money. Never print it, log it, put it in a URL, or send it to any host other than `https://faraatarjomeh.com`. - Never send the key from a browser or a mobile app; only from a server or a local script. - Files you upload and results you download belong to the user. Do not share them elsewhere unless the user asked. - Deleting a result (`DELETE` calls) cannot be undone. Only delete when the user asked. --- # Quickstart: translate your first PDF > Translate one English PDF into Persian from your own server. The sequence is: `GET /api/v1/account` (balance) → `POST /api/v1/translate/analyze` (price, free) → `POST /api/v1/translate/start/{jobId}` (spends Fara) → `GET /api/v1/translate/status/{jobId}` until done (or a webhook) → `GET /api/v1/translate/download/{jobId}/{type}`. ## At a glance - Base URL: `https://faraatarjomeh.com`. All paths start with `/api/v1`. - Auth: `Authorization: Bearer $FARA_API_KEY` on every request — [Authentication](https://faraatarjomeh.com/api/v1/docs/authentication.md). - Scopes: `read` for GET, `write` for POST and DELETE. This quickstart needs both. - Spends Fara: only `POST /api/v1/translate/start/{jobId}`. Analysis, status and downloads are free. - Async: yes. Start returns `202` at once; the translation runs in the background. - Terminal statuses: `completed`, `completed_partial`, `failed`, `cancelled`. - Webhook events: `translation.analyzed`, `translation.images_waiting`, `translation.completed`, `translation.completed_partial`, `translation.failed`, `translation.cancelled` — [Webhooks](https://faraatarjomeh.com/api/v1/docs/webhooks.md). - Full detail for every step: [PDF translation guide](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md). ## Step 1: Create an API key 1. Sign in at https://faraatarjomeh.com. 2. Open **Profile → API access** and create a key with the `read` and `write` scopes. 3. Copy the key. It starts with `fara_sk_` and is shown only once. ## Step 2: Put the key in an environment variable ```bash export FARA_API_KEY="fara_sk_..." ``` Use the key only from a server or a local script. Anyone who has it can spend your Fara. ## Step 3: Check your balance ```http GET /api/v1/account HTTP/1.1 Authorization: Bearer fara_sk_... ``` Response `200 OK`: ```json { "id": "66f1c0a2b4e5d6f7a8b9c0d1", "email": "owner@example.com", "emailVerified": true, "credits": { "currency": "FARA", "faraPerUsd": 100, "balance": 460, "reserved": 0, "chargebackLiability": 0, "lifetimeUsage": 1210, "lastTransactionAt": "2026-09-25T10:12:03.120Z" }, "auth": { "type": "api_key", "keyId": "66f1c0a2b4e5d6f7a8b9c0ff", "scopes": ["read", "write"] } } ``` `credits.balance` is what you can spend now. Buying Fara happens on the website only. ```bash curl -s "https://faraatarjomeh.com/api/v1/account" -H "Authorization: Bearer $FARA_API_KEY" ``` ## Step 4: Analyze the PDF to get the price Analysis reads the PDF, counts pages and words, and returns the price. It is free. The file part must be sent with `Content-Type: application/pdf`, and the file must be 100 MB or smaller. When Word and EPUB input is on for the site, a `.docx` or EPUB file is accepted too; it is converted to PDF once and then analysed the same way, and the job shows `sourceFormat`. Use `POST /api/v1/translate/analyze`. It answers in one response with the job id and the price. Large or image-heavy files can take several minutes, so set your client timeout to 15 minutes. If the connection drops, send the same request again with the same `Idempotency-Key` (see Step 5): the analysis keeps running on the server and you get its answer. The other route, `POST /api/v1/translate/analyze-stream` with a Server-Sent Events progress stream, exists for showing progress to a person; see the [guide](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md#streaming-analysis). ```http POST /api/v1/translate/analyze HTTP/1.1 Authorization: Bearer fara_sk_... Idempotency-Key: 0f8c6a52-2d7e-4b8e-9d0a-51e3b6f2c4a1 Content-Type: multipart/form-data; boundary=----fara ------fara Content-Disposition: form-data; name="file"; filename="book.pdf" Content-Type: application/pdf ------fara-- ``` Response `200 OK`: ```json { "jobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "filename": "book.pdf", "fileSize": 4823311, "pageCount": 212, "wordCount": 68450, "charCount": 402113, "totalChunks": 46, "paragraphCount": 1420, "quality": "medium", "workflow": "chunk_4stage", "availableWorkflows": ["chunk_4stage"], "imageCount": 14, "estimatedMinutes": 32, "estimatedPrice": 380, "timeEstimate": { "totalMinutes": 32, "minutesPerChunk": 8, "minutesPerBatch": 8, "chunksPerBatch": 15, "estimatedBatches": 4, "sampleCount": 0, "isDefault": true, "source": "fallback", "quality": null, "lastUpdatedAt": null }, "qualityPreviews": null, "qualityEstimates": [ { "quality": "simple", "estimatedCost": 380, "estimatedCostEconomy": 380, "estimatedMinutes": 32 }, { "quality": "medium", "estimatedCost": 380, "estimatedCostEconomy": 380, "estimatedMinutes": 32 }, { "quality": "highest", "estimatedCost": 380, "estimatedCostEconomy": 380, "estimatedMinutes": 32 } ], "status": "analyzed" } ``` The price is in `qualityEstimates`: `estimatedCost`, in Fara. Every translation runs fast, so `estimatedCostEconomy` is the same number. `estimatedMinutes` is the time estimate for fast delivery. It is worked out from the real times of recent fast chunks (`source: "measured_median"`); `source: "fallback"` means there were too few of them yet, so the estimate uses a fixed time per chunk. A later analysis may show a different number. ```bash curl -s --max-time 900 -X POST "https://faraatarjomeh.com/api/v1/translate/analyze" \ -H "Authorization: Bearer $FARA_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -F "file=@book.pdf;type=application/pdf" ``` ## Step 5: Start the translation There is one delivery mode: every translation starts right away and runs fast. Send `"executionMode": "realtime"`, or leave it out. The value `economy_batch` is still accepted and runs as `realtime`. Any other value answers `400 INVALID_EXECUTION_MODE` and starts nothing. `quality` is still accepted so old clients keep working, but it no longer changes the result. The translation keeps the tone of the source text. **Why the `Idempotency-Key`:** if the request times out or the connection drops, send it again with the **same** key. You get the first answer back (header `Idempotent-Replayed: true`); the job is never started or charged twice. Error answers `4xx` and `503` are not stored, so after fixing the cause (for example a top-up) the same key works again. Use a new key for each new action. ```http POST /api/v1/translate/start/3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70 HTTP/1.1 Authorization: Bearer fara_sk_... Idempotency-Key: 7d4e1f0a-93c2-4b5e-8a61-2f0c9e7b3d58 Content-Type: application/json {"executionMode": "realtime"} ``` Response `202 Accepted`: ```json { "jobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "quality": "medium", "workflow": "chunk_4stage", "executionMode": "realtime", "availableWorkflows": ["chunk_4stage"], "message": "Translation started", "totalChunks": 46, "status": "pending" } ``` The balance is checked now (`402 INSUFFICIENT_CREDITS` if too low). Fara is held when the job begins running and the actual cost is charged when it finishes — see [Billing](https://faraatarjomeh.com/api/v1/docs/billing.md). ```bash JOB_ID="3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70" START_KEY=$(uuidgen) # keep it; reuse it if you must resend this request curl -s -X POST "https://faraatarjomeh.com/api/v1/translate/start/$JOB_ID" \ -H "Authorization: Bearer $FARA_API_KEY" \ -H "Idempotency-Key: $START_KEY" \ -H "Content-Type: application/json" \ -d '{"executionMode":"realtime"}' ``` ## Step 6: Wait until it is done Either: - **Webhook (best):** register an https endpoint once with `POST /api/v1/webhook-endpoints` and wait for `translation.completed`, `translation.completed_partial`, `translation.failed` or `translation.cancelled` — [Webhooks](https://faraatarjomeh.com/api/v1/docs/webhooks.md). - **Polling:** call `GET /api/v1/translate/status/{jobId}`. Poll every 30 seconds. Jobs started before economy delivery was removed may still show `batch_submitted`, `batch_waiting`, `batch_results_received` or `validating`; for those, poll every 10 minutes. If the status is `images_waiting`, the job waits for your choice on the pictures: send it with `POST /api/v1/jobs/{jobId}/images` (see the guide), or wait. ```http GET /api/v1/translate/status/3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70 HTTP/1.1 Authorization: Bearer fara_sk_... ``` Response `200 OK` (short form; the full field list is in the [guide](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md#poll-the-status)): ```json { "jobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "status": "completed", "filename": "book.pdf", "executionMode": "realtime", "estimatedPrice": 380, "estimatedPriceEconomy": null, "totalChunks": 46, "completedChunks": 46, "progress": 100, "createdAt": "2026-09-25T10:12:03.000Z", "completedAt": "2026-09-25T21:40:11.000Z", "customerErrorCode": null, "outputs": { "docx": "66f2a1c3d4e5f60718293a4b", "pdf": "66f2a1c3d4e5f60718293a4c" } } ``` The job is done when `status` is `completed` or `completed_partial` (finished, but more than a quarter of the text stayed in English). `failed` has a reason in `customerErrorCode`. Treat any other status as still running. ```bash curl -s "https://faraatarjomeh.com/api/v1/translate/status/$JOB_ID" -H "Authorization: Bearer $FARA_API_KEY" ``` ## Step 7: Download the PDF and DOCX `GET /api/v1/translate/download/{jobId}/{type}` with `type` = `pdf` (`application/pdf`) or `docx` (`application/vnd.openxmlformats-officedocument.wordprocessingml.document`). Download only the types whose `outputs` value is not `null`. Downloads are free and can be repeated. ```http GET /api/v1/translate/download/3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70/pdf HTTP/1.1 Authorization: Bearer fara_sk_... ``` Response `200 OK` with the file as the body, `Content-Type: application/pdf` and `Content-Disposition: attachment` with a suggested (Persian) file name. ```bash curl -sf -o book-fa.pdf "https://faraatarjomeh.com/api/v1/translate/download/$JOB_ID/pdf" \ -H "Authorization: Bearer $FARA_API_KEY" ``` ## State machine | status | terminal? | meaning | next action for the client | |---|---|---|---| | `analyzed` | no | priced, not started, nothing held | start it, or discard it with `DELETE /api/v1/translate/analyze/{jobId}` | | `pending` | no | queued | wait | | `processing`, `translating` | no | running | wait (poll every 30 s) | | `batch_submitted`, `batch_waiting`, `batch_results_received`, `validating` | no | older economy job (started before economy delivery was removed) waiting for its turn or being checked | wait (poll every 10 min) | | `completed` | yes | done | download | | `completed_partial` | yes | done, more than a quarter of the text stayed in English | download; see [fixing a finished job](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md#fix-a-finished-job) | | `failed` | yes | stopped; hold released | read `customerErrorCode`; see the [guide](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md#state-machine) | | `cancelled` | yes | cancelled; hold released | nothing | | anything else | no | still running | wait | ## Errors and recovery | HTTP | code | when | retry? | what the client should do | |---|---|---|---|---| | 400 | `BAD_REQUEST` | not a PDF, over 100 MB, no readable text, or the job is not `analyzed` at start | no | fix the input; read `detail` for the log only | | 415 | `UNSUPPORTED_FILE_TYPE` | Word/EPUB input is on, and the file is neither a PDF, a `.docx` nor an EPUB | no | send a PDF, a `.docx` or an EPUB; nothing was charged | | 422 | `DOCUMENT_PROTECTED`, `INVALID_DOCUMENT`, `DOCUMENT_CONVERSION_INCOMPLETE`, `DOCUMENT_CONVERSION_FAILED` | a Word or EPUB file that is locked, cannot be opened, or cannot be prepared in full | no | save the file as a PDF and send the PDF; nothing was charged | | 400 | `INVALID_EXECUTION_MODE` | `executionMode` is not `economy_batch` or `realtime` | no | send one of the two values, same key | | 401 | `INVALID_API_KEY` | wrong or revoked key | no | check `FARA_API_KEY` | | 402 | `INSUFFICIENT_CREDITS` | balance below the price (body has `balance`, `estimatedCost`) | no | tell the user to top up at https://faraatarjomeh.com; then send the start again (the same `Idempotency-Key` is fine: a 402 is not stored) | | 403 | `INSUFFICIENT_SCOPE` | key lacks `read` or `write` | no | use a key with both scopes | | 409 | `IDEMPOTENCY_KEY_IN_USE` | the first request with this key is still running | yes | wait `Retry-After` seconds, send again with the same key | | 429 | `RATE_LIMITED` | too many requests | yes | wait `Retry-After` seconds, same key | | 503 | `EXTRACTION_CAPACITY_EXCEEDED`, `SERVICE_UNAVAILABLE` | busy | yes | wait `Retry-After` (or 30 s), send again with the same key | | 500, 504 | `INTERNAL_ERROR`, `EXTRACTION_TIMEOUT` | failed on our side; this answer is stored under the key | once | check whether the job exists (`GET /api/v1/translate/resumable`, or the job status), then send again with a **new** key | Full list: [PDF translation guide](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md#errors-and-recovery) and [Errors](https://faraatarjomeh.com/api/v1/docs/errors.md). ## Rules for agents - Get the price (Step 4) before starting, and do not start if it is above what the user approved or above `credits.balance`. - Send an `Idempotency-Key` on every POST that spends Fara and reuse the same key when you retry that POST. - Poll no faster than every 30 s (every 10 min for the older economy waiting statuses). Prefer webhooks. - Branch on `code` in errors, never on the `detail` text. - Treat unknown `status` values as still running. - Do not create a second job to retry a job that is still running. ## Complete script Both scripts do Steps 3–7: check the balance, analyze, stop if the price is above your limit or your balance, start, poll, and download. They retry network errors, `409 IDEMPOTENCY_KEY_IN_USE`, `429` and `503` with the same `Idempotency-Key`. Python 3.9+ (`pip install requests`). Run: `python fara_translate.py book.pdf 500` ```python # fara_translate.py import os import sys import time import uuid import requests BASE_URL = "https://faraatarjomeh.com" API_KEY = os.environ["FARA_API_KEY"] TERMINAL = {"completed", "completed_partial", "failed", "cancelled"} def api(method, path, idempotency_key=None, json_body=None, files=None, stream=False): """Send one request. Retries network errors, 429, 503 and 409 IDEMPOTENCY_KEY_IN_USE with the SAME Idempotency-Key.""" headers = {"Authorization": f"Bearer {API_KEY}"} if idempotency_key: headers["Idempotency-Key"] = idempotency_key for attempt in range(1, 61): if files: for part in files.values(): part[1].seek(0) try: res = requests.request(method, BASE_URL + path, headers=headers, json=json_body, files=files, stream=stream, timeout=(10, 900)) except requests.RequestException: time.sleep(min(2 ** attempt, 60)) continue if res.ok: return res if stream else res.json() try: problem = res.json() except ValueError: problem = {} if res.status_code in (429, 503) or problem.get("code") == "IDEMPOTENCY_KEY_IN_USE": wait = int(res.headers.get("Retry-After") or min(2 ** attempt, 60)) time.sleep(max(wait, 10)) continue raise RuntimeError(f"{method} {path} -> {res.status_code} {problem.get('code')}: {problem.get('detail')}") raise RuntimeError(f"{method} {path}: gave up after retries") def main(): pdf_path = sys.argv[1] max_fara = float(sys.argv[2]) if len(sys.argv) > 2 else float("inf") balance = api("GET", "/api/v1/account")["credits"]["balance"] print(f"Balance: {balance} Fara") with open(pdf_path, "rb") as fh: files = {"file": (os.path.basename(pdf_path), fh, "application/pdf")} analysis = api("POST", "/api/v1/translate/analyze", idempotency_key=str(uuid.uuid4()), files=files) job_id = analysis["jobId"] price = analysis["estimatedPrice"] print(f"Job {job_id}: {analysis['pageCount']} pages, {analysis['wordCount']} words, price {price} Fara") if price > max_fara or price > balance: api("DELETE", f"/api/v1/translate/analyze/{job_id}") sys.exit(f"Not started: price {price} Fara, limit {max_fara}, balance {balance}") api("POST", f"/api/v1/translate/start/{job_id}", idempotency_key=str(uuid.uuid4()), json_body={"executionMode": "realtime"}) while True: job = api("GET", f"/api/v1/translate/status/{job_id}") print(f"{job['status']} {job['progress']}%") if job["status"] in TERMINAL: break time.sleep(30) if job["status"] not in ("completed", "completed_partial"): sys.exit(f"Job ended as {job['status']} ({job.get('customerErrorCode')})") for file_type, value in (job.get("outputs") or {}).items(): if not value: continue res = api("GET", f"/api/v1/translate/download/{job_id}/{file_type}", stream=True) with open(f"{job_id}.{file_type}", "wb") as out: for block in res.iter_content(chunk_size=1 << 16): out.write(block) print(f"Saved {job_id}.{file_type}") if __name__ == "__main__": main() ``` Node.js 20+ (no packages). Run: `node fara-translate.mjs book.pdf 500` ```js // fara-translate.mjs import { openAsBlob } from "node:fs"; import { writeFile } from "node:fs/promises"; import { randomUUID } from "node:crypto"; import { basename } from "node:path"; import { setTimeout as sleep } from "node:timers/promises"; const BASE_URL = "https://faraatarjomeh.com"; const API_KEY = process.env.FARA_API_KEY; if (!API_KEY) throw new Error("Set FARA_API_KEY"); const [pdfPath, maxFaraArg] = process.argv.slice(2); if (!pdfPath) throw new Error("Usage: node fara-translate.mjs book.pdf [maxFara]"); const maxFara = maxFaraArg ? Number(maxFaraArg) : Infinity; const TERMINAL = new Set(["completed", "completed_partial", "failed", "cancelled"]); // Retries network errors, 429, 503 and 409 IDEMPOTENCY_KEY_IN_USE with the SAME Idempotency-Key. async function api(method, path, { json, form, idempotencyKey, raw = false } = {}) { const headers = { Authorization: `Bearer ${API_KEY}` }; if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey; let body = form; if (json !== undefined) { headers["Content-Type"] = "application/json"; body = JSON.stringify(json); } for (let attempt = 1; attempt <= 60; attempt++) { let res; try { res = await fetch(BASE_URL + path, { method, headers, body }); } catch { await sleep(Math.min(2 ** attempt, 60) * 1000); continue; } if (res.ok) return raw ? res : res.json(); const problem = await res.json().catch(() => ({})); if (res.status === 429 || res.status === 503 || problem.code === "IDEMPOTENCY_KEY_IN_USE") { const wait = Number(res.headers.get("retry-after")) || Math.min(2 ** attempt, 60); await sleep(Math.max(wait, 10) * 1000); continue; } throw new Error(`${method} ${path} -> ${res.status} ${problem.code}: ${problem.detail}`); } throw new Error(`${method} ${path}: gave up after retries`); } const account = await api("GET", "/api/v1/account"); const balance = account.credits.balance; console.log(`Balance: ${balance} Fara`); const form = new FormData(); form.append("file", await openAsBlob(pdfPath, { type: "application/pdf" }), basename(pdfPath)); const analysis = await api("POST", "/api/v1/translate/analyze", { form, idempotencyKey: randomUUID() }); const jobId = analysis.jobId; const price = analysis.estimatedPrice; console.log(`Job ${jobId}: ${analysis.pageCount} pages, ${analysis.wordCount} words, price ${price} Fara`); if (price > maxFara || price > balance) { await api("DELETE", `/api/v1/translate/analyze/${jobId}`); console.error(`Not started: price ${price} Fara, limit ${maxFara}, balance ${balance}`); process.exit(1); } await api("POST", `/api/v1/translate/start/${jobId}`, { json: { executionMode: "realtime" }, idempotencyKey: randomUUID(), }); let job; for (;;) { job = await api("GET", `/api/v1/translate/status/${jobId}`); console.log(`${job.status} ${job.progress}%`); if (TERMINAL.has(job.status)) break; await sleep(30 * 1000); } if (job.status !== "completed" && job.status !== "completed_partial") { console.error(`Job ended as ${job.status} (${job.customerErrorCode})`); process.exit(1); } for (const [type, value] of Object.entries(job.outputs ?? {})) { if (!value) continue; const res = await api("GET", `/api/v1/translate/download/${jobId}/${type}`, { raw: true }); await writeFile(`${jobId}.${type}`, Buffer.from(await res.arrayBuffer())); console.log(`Saved ${jobId}.${type}`); } ``` --- # Authentication > Send a secret API key in the `Authorization` header of every request: `Authorization: Bearer fara_sk_...`. Keys are created on the website and act as their owner, with the `read` and/or `write` scope. ## At a glance - Header: `Authorization: Bearer ` on every request - Key format: `fara_sk_` + 46 letters and digits (54 characters). Regex: `^fara_sk_[0-9A-Za-z]{46}$` - Where to create: https://faraatarjomeh.com/profile → **API access** tab (login required). The full key is shown once. - Scopes: `read` (GET/HEAD) and `write` (POST, PUT, PATCH, DELETE) - Limit: 10 active keys per account (revoked and expired keys do not count) - Server-to-server only. Browsers cannot call the API with a key (cross-origin requests are refused). ## Create a key 1. Sign in at https://faraatarjomeh.com. 2. Open **Profile → API access → Create a key**. 3. Give it a name, choose scopes, and optionally an expiry (30, 90 or 365 days, or never). 4. Copy the key. It is shown only once; only a hash is stored. Keep the key in an environment variable or a secret store. These docs use `FARA_API_KEY`. ```bash export FARA_API_KEY="fara_sk_..." curl -s https://faraatarjomeh.com/api/v1/account -H "Authorization: Bearer $FARA_API_KEY" ``` ## Sign an agent in with a code (no key to copy) An agent can get its own key without the user copying one: the OAuth 2.0 device flow ([RFC 8628](https://www.rfc-editor.org/rfc/rfc8628)). The user only needs an account with Fara. 1. The agent asks for a code. `client_name` is the name the user sees (names of known assistants are refused). ```bash curl -s -X POST "https://faraatarjomeh.com/api/v1/oauth/device" -d "client_name=My site builder" -d "scope=read write" ``` Response `200 OK`: ```json { "device_code": "Zx3…(secret, keep it)", "user_code": "BCDF-GHJK", "verification_uri": "https://faraatarjomeh.com/connect?device", "verification_uri_complete": "https://faraatarjomeh.com/connect?device=BCDF-GHJK", "expires_in": 900, "interval": 5 } ``` 2. Show the user the code and `verification_uri_complete`. They open it, sign in or create an account, check the code, choose a monthly Fara limit (500 is suggested) and allow it. 3. Poll the token endpoint every `interval` seconds: ```bash curl -s -X POST "https://faraatarjomeh.com/api/v1/oauth/token" \ -d "grant_type=urn:ietf:params:oauth:grant-type:device_code" -d "device_code=$DEVICE_CODE" ``` Until the user acts the answer is `400` with `error`: `authorization_pending` (keep polling), `slow_down` (add 5 seconds to the interval), `access_denied` (the user said no: stop), or `expired_token` (start again). When the user allows it, the answer is `200`: ```json { "access_token": "fara_sk_…", "token_type": "Bearer", "expires_in": 31536000, "scope": "read write", "spend_limit": { "fara": 500, "period": "month" } } ``` `access_token` is an API key of the account, valid for a year, with the monthly limit the user chose. It is listed in the user's API tab, where they can change the limit or revoke it. Store it like any key. A request over the limit answers `402 SPEND_LIMIT_REACHED`. Like a connected AI assistant, this key cannot manage webhooks, change account settings, delete anything, cancel jobs, or retry, recover or re-run jobs (`403 CONNECTION_NOT_ALLOWED`); the account owner does those on the website. It stops working when the account's password is changed. AI assistants that speak MCP do not need this: they connect to `https://faraatarjomeh.com/api/v1/mcp` and sign in through the browser (see [AI assistants (MCP)](https://faraatarjomeh.com/api/v1/docs/guides/mcp.md)). ## Scopes | Scope | Allows | Typical use | |---|---|---| | `read` | GET and HEAD: see jobs, balance, ledger, download results | dashboards, reporting | | `write` | POST, PUT, PATCH, DELETE: create, change, approve, cancel jobs — **spends Fara** | integrations that start work | A request without the needed scope gets `403` with code `INSUFFICIENT_SCOPE` and `requiredScope` in the body. Most integrations need both scopes. ## What a key can reach A key can call every customer endpoint in [the reference](https://faraatarjomeh.com/api/v1/docs/reference.md). It cannot: - call admin endpoints (a key never has admin rights, even if its owner is an admin); - sign in, change the password or profile, or buy Fara; - create, list or revoke API keys. Those return `403` with code `API_KEY_ROUTE_NOT_ALLOWED`. ## Authentication errors | HTTP | code | Meaning | What to do | |---|---|---|---| | 401 | `INVALID_API_KEY` | Missing, malformed, revoked or unknown key | Check the header format and the key. If revoked, ask the owner for a new key. | | 401 | `API_KEY_EXPIRED` | The key's expiry date passed | Ask the owner for a new key. | | 403 | `ACCOUNT_DISABLED` | The owner's account is disabled | Contact support. | | 403 | `INSUFFICIENT_SCOPE` | Key lacks `read` or `write` | Use a key with the scope in `requiredScope`. | | 403 | `API_KEY_ROUTE_NOT_ALLOWED` | Endpoint is website-only | Do it on the website. | | 403 | `EMAIL_NOT_VERIFIED` | Owner's email is not verified | The owner verifies it on the website. | | 403 | `API_DISABLED` | API access is switched off right now | Retry later. | A `401` response also carries `WWW-Authenticate: Bearer realm="api", error="invalid_token"`. ## Rotating a key 1. Create a new key on the website. 2. Deploy it to your server. 3. Revoke the old key (Profile → API access → Revoke). Revocation takes effect on the next request. Idempotency keys are stored per account, not per API key, so a retry still works if you switch keys in the middle of it. ## Security - Never put the key in a web page, a mobile app, a URL, a log, or a code repository. - Use one key per integration so you can revoke one without stopping the others. - If a key leaks, revoke it at once. Anyone with the key can spend the account's Fara. - The key prefix `fara_sk_` is fixed so secret scanners can find leaked keys. --- # Billing and Fara > All paid work is charged in Fara from the API key owner's account, exactly like on the website. Get the price first, check `GET /api/v1/account`, then create the job. Fara is held when the job starts, the real cost is charged when it finishes, and unused or failed amounts come back. ## At a glance - Currency: Fara (integer amounts). 100 Fara = 1 US dollar of list price. - Balance: `GET /api/v1/account` → `credits.balance` (spendable now) and `credits.reserved` (held by running jobs, already taken out of `balance`) - Ledger: `GET /api/v1/account/transactions` (cursor paging, `?jobId=` filter) - Buying Fara: website only (https://faraatarjomeh.com/pricing, https://faraatarjomeh.com/profile). An API key cannot buy. Pack prices are listed before value added tax; the tax (`vatRate` in `GET /api/v1/payment/packages`) is added at checkout and does not change the Fara you get. - Not enough Fara: `402` with code `INSUFFICIENT_CREDITS` - Retrying a paid POST safely: `Idempotency-Key` header — see [Conventions](https://faraatarjomeh.com/api/v1/docs/conventions.md#idempotency) ## Check the balance ```http GET /api/v1/account HTTP/1.1 Authorization: Bearer fara_sk_... ``` ```json { "id": "66f1c0a2b4e5d6f7a8b9c0d1", "email": "owner@example.com", "emailVerified": true, "credits": { "currency": "FARA", "faraPerUsd": 100, "balance": 460, "reserved": 40, "chargebackLiability": 0, "lifetimeUsage": 1210, "lastTransactionAt": "2026-09-25T10:12:03.120Z" }, "auth": { "type": "api_key", "keyId": "66f1c0a2b4e5d6f7a8b9c0ff", "scopes": ["read", "write"] } } ``` | Field | Meaning | |---|---| | `credits.balance` | Fara you can spend now. Holds for running jobs are already subtracted. | | `credits.reserved` | Fara held for jobs that have not finished. Shown for information; do not subtract it again. | | `credits.chargebackLiability` | If above 0, a payment was reversed; no new Fara can be held until it is settled (`402 CHARGEBACK_LIABILITY_OUTSTANDING`). | ## Where each price comes from | Feature | Price call | Price field | |---|---|---| | PDF translation | `POST /api/v1/translate/analyze` (or the analysis stream) | price estimates per quality level — see [PDF translation](https://faraatarjomeh.com/api/v1/docs/guides/pdf-translation.md) | | Translation tools (slides, mind map, LinkedIn, proofread) | none — the cost is small and depends on the text; it is held before and charged after | `faraCost` in the response | | Video | `POST /api/v1/video/jobs/estimate` | per output mode | | Meeting minutes | `GET /api/v1/meetings/pricing` | `faraPerMin` | | Podcast / audiobook | `GET /api/v1/audio/pricing` | per minute, and the hold for the longest length | | Persian text-to-speech | `GET /api/v1/farsi-tts/pricing` | per minute of speech | | Transcription | `GET /api/v1/transcription/pricing` | per minute, with and without translation | | Meeting tools (early access) | `POST /api/v1/meetings/estimate` | hold per tool; see [Meetings: early-access features](https://faraatarjomeh.com/api/v1/docs/guides/meeting-extras.md#paid-tools) | PDF translation has one price. Every translation starts at once and runs fast (`executionMode: "realtime"`, or leave it out). `executionMode: "economy_batch"` is still accepted and runs as `realtime`. ## Life of a charge | Step | What happens to Fara | Ledger rows | |---|---|---| | Job is created (media jobs, tools) or starts running (PDF translation) | The estimated amount is **held**: taken out of `balance`, counted in `reserved` | `credit_hold` (`settlementStatus: "reserved"`) | | Job finishes | The **real cost** is charged. If the hold was larger, the difference comes back. | hold → `settlementStatus: "charged"`; `credit_refund` for the difference, or an extra `*_charge` row if the real cost was higher | | Job fails or is cancelled | The whole hold comes back | `credit_refund` (hold → `settlementStatus: "released"`) | | Job was charged but its result could not be delivered | The charge is refunded in full | `service_failure_refund` | Rules by feature: - **PDF translation:** the balance is checked when you start (`402` if too low). The hold is taken when the job actually starts running; if the balance dropped below the price in between, the job fails with `customerErrorCode: "INSUFFICIENT_CREDITS"` and nothing is charged. The final charge is the real cost, which can differ from the estimate. If more than half of the document could not be translated and stays in English, nothing is charged. Economy jobs are charged the real economy cost. - **Video, meeting minutes, podcast/audiobook, Persian text-to-speech, transcription:** the hold is taken when you create the job. The final charge is the real cost. If it is above the hold, the difference is charged as an extra ledger row when your balance covers it; if it does not, only the hold is charged. - **Translation tools** (slides, mind map, LinkedIn posts, proofreading): synchronous. Fara is held before the result is made and charged right after; the response has `faraCost`. Each POST makes a new result and a new charge — always send an `Idempotency-Key`. - **Section resends** (`POST /api/v1/translate/{jobId}/resend-chunks`): held before, charged for what was re-translated; nothing if nothing succeeded. - **Free:** analysis, estimates, pricing, status, downloads, the document summary, and re-making files from results you already paid for (custom PDF, slide files, mind map PDF, summary PDF, regenerate). ## What did a job cost? The real cost of a job is the **sum of `balanceChange`** of its ledger rows (negative = spent): ```http GET /api/v1/account/transactions?jobId=3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70&limit=100 HTTP/1.1 Authorization: Bearer fara_sk_... ``` ```json { "data": [ { "id": "66f1c2...", "type": "credit_refund", "amount": 12, "balanceChange": 12, "balanceAfter": 472, "jobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "relatedJobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "description": "Refund for overestimated hold on job 3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "createdAt": "2026-09-25T10:40:00.000Z" }, { "id": "66f1c1...", "type": "credit_hold", "amount": 40, "balanceChange": -40, "balanceAfter": 460, "jobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "relatedJobId": "3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "description": "Credit hold for translation job 3f1c2b7e-9a4d-4c1e-8f7a-2b9c4d5e6f70", "settlementStatus": "charged", "createdAt": "2026-09-25T10:12:03.000Z" } ], "hasMore": false, "nextCursor": null } ``` Here the job cost 40 − 12 = **28 Fara**. The `jobId` filter also returns the job's tool charges and section resends, which are stored under derived ids (`slides--