Faraatarjomeh API
Pages

For AI agents: this page as Markdown at https://faraatarjomeh.com/api/v1/docs/guides/video.md; all docs in one file at llms-full.txt.

Translate a video

Turn a YouTube video or your own video file into a Persian video: Persian subtitles, a Persian voice, or both. Sequence: for a file, first POST /api/v1/uploads with purpose: "video" and send its chunks (Chunked uploads) → POST /api/v1/video/jobs/estimate (free price) → GET /api/v1/video/voices → POST /api/v1/video/jobs (holds Fara) → poll GET /api/v1/video/jobs/{id} → optional review (PATCH /api/v1/video/jobs/{id}/segments/{segmentId}, POST /api/v1/video/jobs/{id}/approve) → GET /api/v1/video/jobs/{id}/download.

At a glance#

Before you start#

Output modes#

outputMode You get Needs a voice (voiceSet) Captions file
farsi_subs Original audio + Persian subtitles no yes
farsi_voice Persian voice in place of the speech yes no
farsi_voice_subs Persian voice + Persian subtitles yes yes

Limits#

Limit Value
Source A YouTube link (url) or a finished chunked upload (uploadId). Send one, not both.
YouTube link Hosts: youtube.com, www.youtube.com, m.youtube.com, music.youtube.com, youtube-nocookie.com, www.youtube-nocookie.com, youtu.be. http or https.
Video file MP4, MOV, MKV, WebM or AVI, with a picture and a sound track. Sent as a chunked upload with purpose: "video".
File size Up to 1 GB (the chunked upload limit).
Video length No fixed limit today. If the server sets one, create and estimate answer 400 MEDIA_TOO_LONG.
Billing unit Whole minutes, rounded up, at least 1
Rate limits 120 requests per 60 s per API key (see RateLimit headers). Job creation: 300 uploads per hour per account.

Price#

POST /api/v1/video/jobs/estimate reads the video length and returns the price of each output type. It is free and holds nothing. For an upload, it reads the file without using the upload up, so you can still create the job from it. The price you see is the amount held at create. The final charge is the real cost; it can be higher than the hold when your balance covers the difference.

Estimate field Price for
costSubtitles outputMode: "farsi_subs"
costStandardVoice voice modes with voiceSet: "standard"
costPremiumVoice voice modes with voiceSet: "premium"
costClonedVoice voice modes with voiceSet: "premium" and voiceCloneMode: "source"

Translate only part of a video#

Send startSeconds and/or endSeconds (whole seconds from the start of the video) to the estimate and to the create call to translate only that part. Send only startSeconds to run from there to the end, or only endSeconds to run from 0. Leave both out for the whole video.

JSON
{ "url": "https://www.youtube.com/watch?v=VIDEO_ID", "startSeconds": 750, "endSeconds": 1050, "outputMode": "farsi_subs" }

Steps#

0. Upload the file (video files only)#

Skip this step for a YouTube link. For a file, start a chunked upload with purpose: "video", send every chunk, and keep the uploadId. See Upload large recordings in chunks for the chunk rules.

HTTP
POST /api/v1/uploads HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json
Idempotency-Key: 3a8e1f0c-7b2d-4c5e-9f6a-1d0b2c3e4f5a

{"purpose": "video", "filename": "How batteries work.mp4", "contentType": "video/mp4", "size": 524288000}
curl
curl -sS -X POST "https://faraatarjomeh.com/api/v1/uploads" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"purpose":"video","filename":"How batteries work.mp4","contentType":"video/mp4","size":524288000}'

The file name without its extension becomes the job's title (videoTitle).

1. Get the price#

HTTP
POST /api/v1/video/jobs/estimate HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json

{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}

Response 200 OK:

JSON
{
  "title": "How batteries work",
  "durationSeconds": 754,
  "costSubtitles": { "faraCharged": 11, "minutesBilled": 13 },
  "costStandardVoice": { "faraCharged": 42, "minutesBilled": 13 },
  "costPremiumVoice": { "faraCharged": 42, "minutesBilled": 13 },
  "costClonedVoice": { "faraCharged": 338, "minutesBilled": 13 }
}
curl
curl -sS -X POST "https://faraatarjomeh.com/api/v1/video/jobs/estimate" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"}'

For an uploaded file, send uploadId in place of url. The answer has the same shape; title is the file name without its extension.

HTTP
POST /api/v1/video/jobs/estimate HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json

{"uploadId": "upl_66f5b7e1c3a2d4f6e8b01a2c"}

The upload must be complete (else 409 UPLOAD_INCOMPLETE). A file we cannot read as a video answers 400 UNSUPPORTED_VIDEO_FILE.

Compare the price with the user's budget and with credits.balance from GET /api/v1/account (Billing).

2. Pick a voice (voice modes only)#

HTTP
GET /api/v1/video/voices HTTP/1.1
Authorization: Bearer fara_sk_...

Response 200 OK:

JSON
{
  "voices": {
    "standard": [
      { "id": "male", "gender": "male", "label": "Male voice" },
      { "id": "female", "gender": "female", "label": "Female voice" }
    ],
    "premium": [
      { "id": "male", "gender": "male", "label": "Male Farsi voice" },
      { "id": "female", "gender": "female", "label": "Female Farsi voice" }
    ]
  },
  "catalog": [
    {
      "id": "female-warm",
      "gender": "female",
      "labelFa": "گرم",
      "labelEn": "Warm",
      "lineFa": "صمیمی و دلنشین",
      "lineEn": "Friendly and pleasant",
      "previewUrl": "/voices/female-warm.mp3",
      "default": true
    }
  ],
  "moods": [
    { "id": "neutral", "labelFa": "عادی", "labelEn": "Neutral" },
    { "id": "formal", "labelFa": "رسمی", "labelEn": "Formal" }
  ]
}

(Shortened: catalog lists every voice and moods every mood.)

curl
curl -sS "https://faraatarjomeh.com/api/v1/video/voices" -H "Authorization: Bearer $FARA_API_KEY"

Each key of voices is a voice set. Send it as voiceSet. catalog lists every voice: send its id as voiceId (both sets speak with these voices). male and female still work and pick that gender's default voice ("default": true). Any other voiceId is refused with 400. previewUrl is a short Persian sample you can play to the user. Always read the list from this call; voices can be added.

voiceSet Voice Price field
standard voiceId (a catalog id, male or female), or voiceGender. Default male. costStandardVoice
premium voiceId (a catalog id, male or female), or voiceGender. Default male. Needed for voiceCloneMode: "source"; then only the voice's gender is used, for speakers whose voice cannot be copied. costPremiumVoice, or costClonedVoice with voiceCloneMode: "source"

moods lists the moods. Send one as voiceMood, or auto (the default) to take the mood from what is said in the video. The mood guides both the Persian wording and the voice; with voiceCloneMode: "source" it guides only the wording. The mood does not change the price.

3. Create the job#

Send an Idempotency-Key (a new UUID per job). A success (and a 500/502/504) is stored for 24 hours: sending the same key again returns that first answer and never charges twice. A 4xx or 503 answer is not stored, so after you fix the request (or the user tops up) you can send it again with the same key.

HTTP
POST /api/v1/video/jobs HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json
Idempotency-Key: 0b6f3c8e-6a0e-4a55-9a3c-5d2f1e7b9c10

{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "outputMode": "farsi_voice_subs",
  "voiceSet": "standard",
  "voiceId": "male",
  "downloadQuality": "720p",
  "reviewBeforeRender": true
}

Response 201 Created:

JSON
{
  "jobId": "66f5a1c2e4b0a7d3c9f81234",
  "cost": { "faraCharged": 109, "minutesBilled": 13 }
}

cost.faraCharged is the amount held now.

For an uploaded file, send uploadId in place of url. All other fields are the same; downloadQuality is ignored.

HTTP
POST /api/v1/video/jobs HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json
Idempotency-Key: 9d4c2b1a-0e8f-4a7b-b6c5-3d2e1f0a9b87

{
  "uploadId": "upl_66f5b7e1c3a2d4f6e8b01a2c",
  "outputMode": "farsi_subs",
  "burnCaptions": true
}

A refused create (for example 402 INSUFFICIENT_CREDITS or 400 MEDIA_TOO_LONG) leaves the upload open. Fix the cause and create again with the same uploadId, until the upload's expiresAt. One upload makes one job: after a job is made, the same uploadId answers 409 UPLOAD_ALREADY_USED.

curl
curl -sS -X POST "https://faraatarjomeh.com/api/v1/video/jobs" \
  -H "Authorization: Bearer $FARA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ","outputMode":"farsi_voice_subs","voiceSet":"standard","voiceId":"male","reviewBeforeRender":true}'

Create request fields#

Field Type Required Default Allowed values Notes
url string url or uploadId — YouTube link See the host list in Limits.
uploadId string url or uploadId — upl_... A finished chunked upload with purpose: "video". Not with url.
outputMode string yes — farsi_subs, farsi_voice, farsi_voice_subs
voiceSet string for farsi_voice and farsi_voice_subs — standard, premium A key of voices from GET /api/v1/video/voices. Ignored for farsi_subs.
voiceId string no male a catalog id from GET /api/v1/video/voices, male, female Anything else answers 400.
voiceGender string no male male, female Used when voiceId is left out.
voiceMood string no auto auto, or a moods id (neutral, friendly, formal, happy, sad, calm, energetic, serious) Voice modes only. auto takes the mood from the video.
downloadQuality string no best best, 360p, 480p, 720p, 1080p Quality of the source video to fetch from YouTube. Also the most the output can be. Ignored for an upload.
startSeconds number no 0 whole seconds, 0 or more Start of the part to translate. Inside the video; see Translate only part of a video.
endSeconds number no the video's end whole seconds, more than startSeconds End of the part to translate. The part must be at least 5 seconds.
burnCaptions boolean no false true, false Subtitle modes only. true draws the subtitles into the picture. false adds them as a separate caption track in the MP4.
voiceCloneMode string no stock stock, source source keeps each original speaker's voice. Only with a voice mode and voiceSet: "premium".
voiceCloneConsent boolean when voiceCloneMode is source false true Must be true: the user confirms they have the right to reuse the speakers' voices.
reviewBeforeRender boolean no the account's saved preference, else false true, false true stops the job at awaiting_review before the final video is made. Sending it also saves it as the account's default (the website uses the same setting).

4. Wait for the job#

HTTP
GET /api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234 HTTP/1.1
Authorization: Bearer fara_sk_...

Response 200 OK (trimmed; the job is wrapped in job):

JSON
{
  "job": {
    "_id": "66f5a1c2e4b0a7d3c9f81234",
    "status": "awaiting_review",
    "stage": "review",
    "progress": 60,
    "sourceType": "youtube",
    "sourceUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "originalFilename": null,
    "videoTitle": "How batteries work",
    "durationSeconds": 754,
    "outputMode": "farsi_voice_subs",
    "voiceGender": null,
    "downloadQuality": "720p",
    "subtitlesEnabled": true,
    "burnCaptions": false,
    "reviewBeforeRender": true,
    "reviewVersion": 0,
    "reviewAutoContinueAt": "2026-09-25T10:14:05.000Z",
    "reviewAutoContinuedAt": null,
    "translationSegments": [
      { "id": "0001", "start": 0.0, "end": 3.4, "text": "Welcome back to the channel.", "farsi": "به کانال خوش آمدید." },
      { "id": "0002", "start": 3.4, "end": 7.9, "text": "Today we look at how batteries work.", "farsi": "امروز می‌بینیم باتری‌ها چطور کار می‌کنند." }
    ],
    "cost": { "faraCharged": 109, "minutesBilled": 13 },
    "customerErrorCode": null,
    "createdAt": "2026-09-25T10:02:11.000Z",
    "updatedAt": "2026-09-25T10:13:05.000Z",
    "completedAt": null,
    "failedAt": null
  }
}
curl
curl -sS "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234" -H "Authorization: Bearer $FARA_API_KEY"

Poll every 30 seconds, or use webhooks. Stop on completed, failed or cancelled. Handle awaiting_review (step 5) if you asked for review.

Job fields you use#

Field Type Notes
_id string Job id (24 hex characters).
status string See State machine.
stage string Progress label for display only: queued, downloading, transcribing, translating, review, synthesizing, muxing, finalizing, done. More values can appear. Never branch on it.
progress number 0–100, for display.
sourceType string youtube or upload.
sourceUrl string or null The YouTube link. null for an upload.
originalFilename string or null The uploaded file's name. null for a YouTube link.
videoTitle, durationSeconds string, number From YouTube, or from the uploaded file (title = file name without its extension).
sourceDurationSeconds, startSeconds, endSeconds number, number, number The length of the whole video, and the translated part (null for the whole video). durationSeconds is the length of the part.
outputMode, downloadQuality, voiceGender, voiceKey, voiceMood, voiceCloneMode, burnCaptions, subtitlesEnabled What the job was created with. voiceKey is the chosen voice id.
detectedMood With voiceMood: "auto": the mood taken from the video, once known.
reviewBeforeRender boolean Whether this job stops for review. Fixed at create.
reviewVersion integer Send it in If-Match on segment edits and approve.
reviewAutoContinueAt string or null When a waiting review continues by itself. null when there is no timer.
reviewAutoContinuedAt string or null Set when the review continued by itself.
translationSegments array Present from review on. Each item: id, start, end (seconds), text (original), farsi (Persian, editable), sometimes translationMissing: true. Other fields can appear.
cost object faraCharged is the hold while running and the real charge after completed. After completion it also has heldFara and refundedFara.
customerErrorCode string or null Why a failed job failed. null otherwise.
completedAt, failedAt string or null

Ignore fields not listed here.

5. Review (only when reviewBeforeRender is true)#

The job stops at awaiting_review after the Persian text is ready and before the voice and the final video are made. You can edit the Persian text of any segment, then approve.

Auto-continue. A waiting job continues by itself at reviewAutoContinueAt. Edits saved before that moment are kept. Read the wait with GET /api/v1/video/preferences → reviewAutoContinueSeconds (default 60 seconds; 0 means no timer). With no timer, a job left in review for 3 days is cancelled and its Fara is released. So decide fast: edit and approve within the window, or let it continue.

Save the review preference (optional; it is also saved when you send reviewBeforeRender on create):

HTTP
PUT /api/v1/video/preferences HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json

{"reviewBeforeRender": true}

Response 200 OK (GET /api/v1/video/preferences answers the same shape):

JSON
{ "preferences": { "reviewBeforeRender": true }, "reviewAutoContinueSeconds": 60 }
curl
curl -sS -X PUT "https://faraatarjomeh.com/api/v1/video/preferences" \
  -H "Authorization: Bearer $FARA_API_KEY" -H "Content-Type: application/json" \
  -d '{"reviewBeforeRender":true}'

5a. Edit one segment#

Send the job's current reviewVersion in If-Match. Both If-Match: 0 and If-Match: "0" work. Weak tags (W/"0") are refused.

HTTP
PATCH /api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/segments/0002 HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: application/json
If-Match: "0"

{"farsi": "امروز می‌بینیم باتری چگونه کار می‌کند."}

Response 200 OK:

JSON
{ "ok": true, "reviewVersion": 1 }
curl
curl -sS -X PATCH "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/segments/0002" \
  -H "Authorization: Bearer $FARA_API_KEY" -H "Content-Type: application/json" \
  -H 'If-Match: "0"' \
  -d '{"farsi":"امروز می‌بینیم باتری چگونه کار می‌کند."}'
Body field Type Required Notes
farsi string yes New Persian text. It is cleaned (spacing, stray marks). Maximum length: 4 × the length of the segment's original text + 100 characters, else 413. An empty string makes that spoken segment silent. Send no other field.

Use the returned reviewVersion for the next edit. Every edit adds 1.

5b. Approve#

HTTP
POST /api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/approve HTTP/1.1
Authorization: Bearer fara_sk_...
If-Match: "1"
Idempotency-Key: 5d1f7a92-3c0b-4e8e-b1a4-8f2e6c7d9a01

Response 200 OK:

JSON
{ "ok": true, "status": "active", "reviewVersion": 1 }

If some spoken segments have empty Persian text, the answer also has "untranslatedSpeechSegmentIds": ["0007"]. Those parts will be silent. Approval still goes through.

curl
curl -sS -X POST "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/approve" \
  -H "Authorization: Bearer $FARA_API_KEY" -H 'If-Match: "1"' \
  -H "Idempotency-Key: $(uuidgen)"

Approve uses the Fara already held. It holds nothing new.

6. Download#

All three downloads need status: "completed", else 409.

Call Returns Notes
GET /api/v1/video/jobs/{id}/download video/mp4, Content-Disposition: attachment Supports one Range: bytes=start-end → 206 with Content-Range. A bad range → 416 with Content-Range: bytes */total.
GET /api/v1/video/jobs/{id}/preview same file, Content-Disposition: inline For players. Same Range rules.
GET /api/v1/video/jobs/{id}/captions text/vtt; charset=utf-8 Only for farsi_subs and farsi_voice_subs. farsi_voice → 404.
HTTP
GET /api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/download HTTP/1.1
Authorization: Bearer fara_sk_...
Range: bytes=0-1048575

Response 206 Partial Content, headers Content-Type: video/mp4, Accept-Ranges: bytes, Content-Range: bytes 0-1048575/48213377, body = the bytes.

curl
curl -sS -o video-fa.mp4 "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/download" \
  -H "Authorization: Bearer $FARA_API_KEY"
curl -sS -o captions.vtt "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/captions" \
  -H "Authorization: Bearer $FARA_API_KEY"

To list jobs: GET /api/v1/video/jobs?limit=20&offset=0 → { "jobs": [ ... ] } (newest first, limit at most 50). Add q to search by name: the name you gave the job or its original file name, ignoring case, at most 100 characters.

Delete#

HTTP
DELETE /api/v1/video/jobs/{id} HTTP/1.1
Authorization: Bearer fara_sk_...

Response 204 No Content. Removes the video, its subtitles and output files from our servers. This cannot be undone. Ledger rows (billing history) stay. Only a finished job (completed, failed or cancelled) can be deleted. A job that is still running or queued, or waiting for review, answers 409 with JOB_NOT_FINISHED: cancel it first. After the delete the job answers 404. Open to every account.

Cancel#

HTTP
POST /api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/cancel HTTP/1.1
Authorization: Bearer fara_sk_...

Response 200 OK: { "ok": true }. The held Fara is released. Works from pending, active, awaiting_review and failed. Refused with 409 once the job is completed or cancelled, or once the last step has started (stage is finalizing or done).

curl
curl -sS -X POST "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/cancel" -H "Authorization: Bearer $FARA_API_KEY"

Retry, resume and reprocess#

Call Allowed when What it does Fara
POST /api/v1/video/jobs/{id}/resume status: "failed" Starts the job again. If the review was already passed, it restarts from the voice step; otherwise from the start. Holds cost.faraCharged again (the first hold was released when it failed). Charged at the real cost when it finishes.
POST /api/v1/video/jobs/{id}/resume status: "pending_finalization" Finishes the charge and publishes the video. Uses the existing hold.
POST /api/v1/video/jobs/{id}/resume status: "pending" or "active" Re-queues a job that stopped moving. Stalled jobs are also picked up automatically within about 20 minutes, so you rarely need this. Uses the existing hold. If the hold is gone, the job is cancelled instead.
POST /api/v1/video/jobs/{id}/reprocess status: "completed" or "failed", and the job already passed review (or ran without review) Makes the final video again from the saved Persian text. Holds cost.faraCharged again and charges the real cost, including any difference above that hold when your balance covers it. On a completed job this is a second charge.

Send an Idempotency-Key on both. Responses:

JSON
{ "ok": true, "queued": true, "name": "translate" }
JSON
{ "ok": true, "postprocessAttempt": 1790000000000 }

The first is from resume (name is translate or resume; for a pending/active job the body can instead be { "ok": true, "queued": false, "alreadyQueued": true, "jobId": "..." }). The second is from reprocess.

curl
curl -sS -X POST "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234/resume" \
  -H "Authorization: Bearer $FARA_API_KEY" -H "Idempotency-Key: $(uuidgen)"

State machine#

status Terminal? Meaning Next action for the client
pending no Queued, or fetching, transcribing and translating. Poll.
awaiting_review no Persian text ready; waiting for review (only jobs created with reviewBeforeRender: true). Edit segments, then approve; or let it auto-continue at reviewAutoContinueAt; or cancel.
active no Making the voice and the final video. Poll.
retrying no A resume or reprocess call is being set up. Lasts seconds. Poll.
finalizing no Charging and publishing the result. Cannot be cancelled. Poll.
pending_finalization no The video is made but the charge did not go through yet. The result is held back. Call resume (no new hold), or wait: it is retried automatically.
completed yes Done and charged. Download.
failed yes (retryable) Stopped. Hold released. customerErrorCode says why. Read customerErrorCode. Retry with resume (new hold) only if the code allows it (see below).
cancelled yes Cancelled by you, or an abandoned review. Hold released. Nothing. Create a new job if needed.

Transitions:

Treat any status not in this table as "still running".

customerErrorCode on a failed job#

Code Meaning Retry with resume?
YOUTUBE_UNAVAILABLE YouTube refuses our server right now. The video is fine. Not soon. Wait at least 10 minutes; tell the user it can last hours.
SERVICE_BUSY Temporary problem on our side. Yes, after a few minutes.
TOOK_TOO_LONG Ran past the time limit. Once. If it fails again, try a shorter video.
NO_SPEECH_FOUND No usable speech or audio in the video, or the uploaded file has no sound track. No.
MEDIA_TOO_LONG The video is longer than the limit. No.
VOICE_CONSENT_REQUIRED Voice matching needs consent. No. Create a new job with voiceCloneConsent: true or voiceCloneMode: "stock".
INSUFFICIENT_CREDITS Not enough Fara. After the user tops up.
GENERIC Anything else, for example an uploaded file with no picture. Once. Not for an upload with no picture: send a real video file.

Billing#

  1. POST /api/v1/video/jobs checks the balance and holds the estimate for the chosen mode (cost.faraCharged in the answer). 402 if the balance is too low. Nothing is held on a 4xx answer.
  2. Review, edits and approve use the same hold.
  3. When the video is made, the real cost is charged. 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. Anything held and not used is released. The job then shows cost.faraCharged (charged), cost.heldFara (held) and cost.refundedFara (released).
  4. On failed or cancelled the whole hold is released. Nothing is charged.
  5. resume on a failed job and reprocess hold again (same amount as cost.faraCharged) and follow steps 3–4.

See Billing for the ledger.

Webhook events#

Event When
video.awaiting_review The job stopped for review.
video.completed The video is ready.
video.failed The job failed. The event has no error code; GET the job for customerErrorCode.
video.cancelled The job was cancelled.

Payload:

JSON
{
  "type": "video.completed",
  "timestamp": "2026-09-25T10:41:30.512Z",
  "id": "evt_4be1f0a3c2d9e8b7a6f5e4d3c2b1a090",
  "data": {
    "object": "video",
    "id": "66f5a1c2e4b0a7d3c9f81234",
    "status": "completed",
    "createdAt": "2026-09-25T10:02:11.000Z",
    "updatedAt": "2026-09-25T10:41:22.000Z",
    "links": { "self": "https://faraatarjomeh.com/api/v1/video/jobs/66f5a1c2e4b0a7d3c9f81234" }
  }
}

Always GET links.self for the current state. A status that lasts only a few seconds (for example a short review window) may not produce an event. See Webhooks for signing and retries.

Errors and recovery#

All errors are application/problem+json. Branch on code. See Errors.

HTTP code When Retry? What the client should do
400 BAD_REQUEST Not a YouTube link, both url and uploadId sent, an uploadId started for another purpose, bad outputMode, voiceSet, voiceId, voiceGender, voiceMood, downloadQuality, voiceCloneMode, missing consent; or YouTube says the video is private, removed or not available. no Fix the request. For an unavailable video, tell the user.
400 MEDIA_TOO_LONG The video is longer than the server limit. no Tell the user.
400 UNSUPPORTED_VIDEO_FILE The uploaded file is not a video we can read, or its length could not be read (estimate or create). no Ask the user for an MP4, MOV, MKV, WebM or AVI file with a sound track.
404 UPLOAD_NOT_FOUND No such upload on this account, or it was cancelled. no Start a new upload.
409 UPLOAD_INCOMPLETE Not every chunk has arrived. missing lists the indexes. refresh Send the missing chunks, then call again.
409 UPLOAD_ALREADY_USED The upload already made a job (jobId). no Use that job.
410 UPLOAD_EXPIRED The upload passed its expiresAt; the file is gone. no Upload the file again.
422 UPLOAD_CHECKSUM_MISMATCH The joined file does not match the sha256 sent at upload start. Nothing was created or charged. no Upload the file again (a new upload).
402 INSUFFICIENT_CREDITS Balance below the hold. Body has cost ({ faraCharged, minutesBilled }, the hold) and balance. no Tell the user the price and balance; they top up at https://faraatarjomeh.com. After the top-up, send the same request again; the same Idempotency-Key is fine (4xx answers are not stored).
402 CHARGEBACK_LIABILITY_OUTSTANDING A payment was reversed. no Tell the user to settle it on the website.
404 NOT_FOUND No such job for this account, or no such segment. no Check the id.
404 FEATURE_DISABLED Video translation is off on this server. later Try again much later (minutes to hours).
409 CONFLICT Wrong status for the call (for example edit when not awaiting_review, download before completed, cancel after finalizing, retry already started), or voice matching not available now. refresh GET the job, then decide from its status.
409 HOLD_NOT_FOUND The job's hold is gone. On approve the job is cancelled. no Create a new job.
409 REVIEW_VERSION_CONFLICT If-Match is not the current reviewVersion. Body has currentVersion. refresh GET the job, re-apply your edit on the fresh segments, send with the new version.
400 INVALID_REVIEW_VERSION If-Match is not a whole number. no Send the number, bare or in double quotes.
428 REVIEW_VERSION_REQUIRED If-Match missing on edit or approve. yes GET the job, send If-Match: <reviewVersion>.
413 PAYLOAD_TOO_LARGE Segment text too long. no Shorten it.
422 PRONUNCIATION_GENERATED_AFTER_APPROVAL The edit body had a pronunciation field. no Send only farsi.
409 IDEMPOTENCY_KEY_IN_USE The first request with this key is still running. yes Wait Retry-After (2 s), resend with the same key.
422 IDEMPOTENCY_KEY_REUSED This key already has a stored answer for a different request. no Use a new key for a new request.
429 RATE_LIMITED Too many requests. yes Wait Retry-After seconds.
500, 502, 504 INTERNAL_ERROR, UPSTREAM_ERROR, UPSTREAM_TIMEOUT Unknown outcome: the job may or may not exist. This answer is stored, so the same Idempotency-Key only replays it. check first List jobs with GET /api/v1/video/jobs and look for one with the same sourceUrl (or, for an upload, the same originalFilename) created in the last minutes. For an upload, GET /api/v1/uploads/{uploadId} also shows "status": "used" and the jobId if a job was made. Only if there is none, send the request again with a NEW Idempotency-Key.
503 YOUTUBE_UNAVAILABLE YouTube refuses our server (estimate or create). later Wait at least 10 minutes. Do not loop on the same link.
503 CREDIT_RESERVATION_UNAVAILABLE Could not hold Fara right now. yes Wait Retry-After (5 s), resend with the same Idempotency-Key.
503 SERVICE_UNAVAILABLE Could not queue the job. The hold is released. yes Back off (2 s, 4 s, 8 s …), resend with the same Idempotency-Key.

Rules for agents#

Complete script#

Both scripts: estimate → create (subtitles only) → poll → download the MP4 and captions. They use a YouTube link; for a file, upload it first (see Chunked uploads) and send {"uploadId": ...} in place of {"url": ...} in both calls. Set FARA_API_KEY and FARA_BASE_URL, and set MAX_FARA to the user's budget.

Python
# Python 3.9+, pip install requests
import os, time, uuid, sys
import requests

BASE = os.environ.get("FARA_BASE_URL", "https://faraatarjomeh.com").rstrip("/")
KEY = os.environ["FARA_API_KEY"]
H = {"Authorization": f"Bearer {KEY}"}
URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
MAX_FARA = 50

def check(r):
    if r.status_code >= 400:
        p = r.json() if "json" in r.headers.get("Content-Type", "") else {}
        raise SystemExit(f"{r.status_code} {p.get('code')}: {p.get('detail')}")
    return r

est = check(requests.post(f"{BASE}/api/v1/video/jobs/estimate", headers=H, json={"url": URL}, timeout=120)).json()
price = est["costSubtitles"]["faraCharged"]
print("title:", est["title"], "price:", price, "Fara")
if price > MAX_FARA:
    sys.exit("price is above the budget")

body = {"url": URL, "outputMode": "farsi_subs", "reviewBeforeRender": False}
idem = str(uuid.uuid4())  # same key on every retry of this create; on 500/502/504 check the job list first
for attempt in range(5):
    r = requests.post(f"{BASE}/api/v1/video/jobs", headers={**H, "Idempotency-Key": idem}, json=body, timeout=120)
    if r.status_code in (409, 429, 503) and r.json().get("code") in ("IDEMPOTENCY_KEY_IN_USE", "RATE_LIMITED", "CREDIT_RESERVATION_UNAVAILABLE", "SERVICE_UNAVAILABLE"):
        time.sleep(int(r.headers.get("Retry-After", 2 ** attempt)))
        continue
    break
job_id = check(r).json()["jobId"]
print("job:", job_id)

while True:
    job = check(requests.get(f"{BASE}/api/v1/video/jobs/{job_id}", headers=H, timeout=60)).json()["job"]
    print(job["status"], job.get("stage"), job.get("progress"))
    if job["status"] in ("completed", "failed", "cancelled"):
        break
    time.sleep(30)

if job["status"] != "completed":
    sys.exit(f"job ended as {job['status']} ({job.get('customerErrorCode')})")

for path, name in (("download", "video-fa.mp4"), ("captions", "captions.vtt")):
    with requests.get(f"{BASE}/api/v1/video/jobs/{job_id}/{path}", headers=H, stream=True, timeout=600) as d:
        check(d)
        with open(name, "wb") as f:
            for chunk in d.iter_content(1 << 20):
                f.write(chunk)
print("charged:", job["cost"]["faraCharged"], "Fara")
Node.js
// Node.js 20+ (ESM: save as video.mjs)
import { writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";

const BASE = (process.env.FARA_BASE_URL ?? "https://faraatarjomeh.com").replace(/\/+$/, "");
const H = { Authorization: `Bearer ${process.env.FARA_API_KEY}` };
const URL_ = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
const MAX_FARA = 50;
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

async function call(path, init = {}) {
  const res = await fetch(`${BASE}${path}`, { ...init, headers: { ...H, ...init.headers } });
  if (!res.ok) {
    const p = await res.json().catch(() => ({}));
    const err = new Error(`${res.status} ${p.code}: ${p.detail}`);
    err.code = p.code;
    err.retryAfter = Number(res.headers.get("retry-after")) || 0;
    throw err;
  }
  return res;
}
const json = (path, body, headers = {}) =>
  call(path, { method: "POST", headers: { "Content-Type": "application/json", ...headers }, body: JSON.stringify(body) }).then((r) => r.json());

const est = await json("/api/v1/video/jobs/estimate", { url: URL_ });
const price = est.costSubtitles.faraCharged;
console.log("title:", est.title, "price:", price, "Fara");
if (price > MAX_FARA) throw new Error("price is above the budget");

const idem = randomUUID(); // same key on every retry of this create; on 500/502/504 check the job list first
const RETRY = new Set(["IDEMPOTENCY_KEY_IN_USE", "RATE_LIMITED", "CREDIT_RESERVATION_UNAVAILABLE", "SERVICE_UNAVAILABLE"]);
let created;
for (let attempt = 0; ; attempt++) {
  try {
    created = await json("/api/v1/video/jobs", { url: URL_, outputMode: "farsi_subs", reviewBeforeRender: false }, { "Idempotency-Key": idem });
    break;
  } catch (e) {
    if (!RETRY.has(e.code) || attempt >= 4) throw e;
    await sleep((e.retryAfter || 2 ** attempt) * 1000);
  }
}
const jobId = created.jobId;
console.log("job:", jobId);

let job;
for (;;) {
  ({ job } = await (await call(`/api/v1/video/jobs/${jobId}`)).json());
  console.log(job.status, job.stage, job.progress);
  if (["completed", "failed", "cancelled"].includes(job.status)) break;
  await sleep(30_000);
}
if (job.status !== "completed") throw new Error(`job ended as ${job.status} (${job.customerErrorCode})`);

for (const [path, name] of [["download", "video-fa.mp4"], ["captions", "captions.vtt"]]) {
  const res = await call(`/api/v1/video/jobs/${jobId}/${path}`);
  await writeFile(name, Buffer.from(await res.arrayBuffer()));
}
console.log("charged:", job.cost.faraCharged, "Fara");

For a dubbed video with review, create with outputMode: "farsi_voice_subs", a voice from GET /api/v1/video/voices and reviewBeforeRender: true; when the status is awaiting_review, PATCH segments with If-Match and approve before reviewAutoContinueAt.