Faraatarjomeh API
Pages

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

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#

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).
  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.
  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.
  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). Report it to the user.

Waiting rules#

  1. Prefer webhooks if you have a public https endpoint (Webhooks). 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 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:

Safety rules#