Agentic Factor API

Use Agentic Factor from your own app, your agency's tools or another AI assistant. Describe work in plain words and it becomes a mission. Run the mission now or on a schedule, then read what it did. Webhooks tell your server when things happen.

Everything works exactly as it does in the app. A run uses credits at the same rate, one run of a mission happens at a time, and anything a run sends, posts, pays or deletes waits for a person's OK.

Approvals are decided only by a person. The API can list what is waiting and give you a link to it, but no API key can approve or reject anything. The person decides in Agentic Factor: on the website, in the phone app, or on the approval card in their AI assistant. There is no endpoint for it, by design.

Keys and scopes

Make a key on Settings → Developers. Name it after what will use it. A key is shown once, so copy it then. We keep only its hash, so a lost key can't be recovered: make a new one and revoke the old one. The same page shows when each key was last used.

Send the key with each request, in either header:

Authorization: Bearer afk_…
X-API-Key: afk_…

A key has one or more scopes:

ScopeLets it
readList missions, runs and results, the ready-made agents, and what waits for an OK
runStart a mission's run now
buildDescribe new work, set or remove a schedule, hire a ready-made agent

No scope decides an approval.

Requests and errors

Requests and answers are JSON. Every answer carries a request_id, also sent in the X-Request-Id header. Quote it if you write to us.

Errors have one shape:

{ "error": { "code": "insufficient_scope", "message": "This key can't start runs: give a key the \"run\" scope on Settings → Developers.", "needed": "run" }, "request_id": "req_…" }
StatusCodesMeaning
400invalid_*The body or a parameter is wrong; the message says which
401unauthorizedNo key, or the key isn't valid or has been revoked
402insufficient_creditsNot enough credits for this
403insufficient_scopeThe key lacks the scope this needs
404not_foundNothing with that id in this workspace (another workspace's ids look the same as ids that don't exist)
409run_in_progress, apps_not_connected, idempotency_in_progressThe mission is busy, its apps need connecting, or the first request with this Idempotency-Key is still running
413body_too_large, input_too_largeThe body is over 64 KB, or a run's input is over 32 KB
422idempotency_key_reusedThis Idempotency-Key was already used for a different request or body
429rate_limitedToo many requests: wait Retry-After seconds
5xxserver_errorOur side: retry with the same Idempotency-Key

Rate limits apply per key, per minute: 120 read requests, 30 run requests and 20 build requests.

Idempotency. Send Idempotency-Key: <any unique string> on a POST, PUT or DELETE. If you retry with the same key within 24 hours, you get the first answer back (marked Idempotent-Replayed: true) and nothing happens twice. A retried "run now" never starts two runs.

Endpoints

Method and pathScopeWhat it does
GET /mereadThe key, its workspace and scopes
POST /missionsbuildDescribe work; it's planned and built (answers 202 with a build)
GET /builds/{buildId}readA build: building, question, built (with the mission) or failed
GET /missionsreadMissions, newest first (?limit, ?before)
GET /missions/{id}readOne mission: its steps, schedule and last run
POST /missions/{id}/runsrunRun it now (continue_from, input)
GET /missions/{id}/runsreadIts last 50 runs
PUT /missions/{id}/schedulebuildRun it on a schedule (cron, timezone, label)
DELETE /missions/{id}/schedulebuildStop the schedule
GET /runs/{runId}readA run's status and outcome
GET /runs/{runId}/resultsreadWhat it produced: summary, final output, each step's output
GET /agentsreadReady-made agents and the questions hiring one asks
POST /agents/{slug}/hirebuildHire one, with answers
GET /approvalsreadWhat waits for a person's OK (?mission_id). Read-only

Describe work, then run it

curl https://agenticfactor.io/api/v1/missions \
  -H "Authorization: Bearer $AF_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: build-overdue-reminders-1" \
  -d '{"description": "Every Monday at 9, email a polite reminder for every Zoho Books invoice more than 30 days overdue. Keep a Google Sheet of who owes what."}'
# → 202 {"build": {"id": "…", "status": "building", "url": "…/api/v1/builds/…"}}

curl https://agenticfactor.io/api/v1/builds/$BUILD_ID -H "Authorization: Bearer $AF_KEY"
# → {"build": {"status": "built", "mission": {"id": "…", "steps": […], "needs_connecting": ["zoho_books"], …}}}

A build takes a minute or two. Poll it every 10–20 seconds, or listen for mission.built. If it answers "status": "question", ask the person, then POST /missions again with the same description and their reply in answers. If needs_connecting lists apps, the person connects them once on Connectors.

curl -X POST https://agenticfactor.io/api/v1/missions/$MISSION_ID/runs \
  -H "Authorization: Bearer $AF_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"input": {"customer": "Acme Pvt Ltd"}}'
# → 202 {"run": {"id": "…", "status": "queued", "url": "…/api/v1/runs/…", "results_url": "…"}}

curl -X PUT https://agenticfactor.io/api/v1/missions/$MISSION_ID/schedule \
  -H "Authorization: Bearer $AF_KEY" -H "Content-Type: application/json" \
  -d '{"cron": "0 9 * * 1", "timezone": "Asia/Kolkata", "label": "every Monday at 9"}'

input is optional (32 KB of JSON at most), and the run's first step starts from it. continue_from is an earlier run of the same mission that did only part of the work; the new run does the rest.

TypeScript

const AF = 'https://agenticfactor.io/api/v1';
const headers = { Authorization: `Bearer ${process.env.AF_KEY}`, 'Content-Type': 'application/json' };

async function af<T>(path: string, init: RequestInit = {}): Promise<T> {
  const res = await fetch(`${AF}${path}`, { ...init, headers: { ...headers, ...init.headers } });
  const body = await res.json();
  if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message} (${body.request_id})`);
  return body as T;
}

// Run a mission and wait for it to end.
const { run } = await af<{ run: { id: string } }>(`/missions/${missionId}/runs`, {
  method: 'POST', headers: { 'Idempotency-Key': crypto.randomUUID() }, body: JSON.stringify({}),
});
let status = 'queued';
while (['queued', 'running', 'paused'].includes(status)) {
  await new Promise(r => setTimeout(r, 15_000));
  const { run: now } = await af<{ run: { status: string; waiting_for_approval: boolean } }>(`/runs/${run.id}`);
  status = now.status;
  if (now.waiting_for_approval) console.log('Waiting for a person to approve it in Agentic Factor.');
}
const results = await af(`/runs/${run.id}/results`);

A run that waits for an approval stays paused until the person decides, which may take a while. A webhook is better than polling for that.

Runs and outcomes

A run's status is queued, running, paused (waiting for a person's OK), completed or failed. Once it ends, outcome says how well it did what the mission asks:

  • met: it did what the mission asks.
  • partly: it did fewer than asked. The note says what's left, and continue_from does the rest.
  • not_met: it finished without doing what the mission is for, or it stopped before finishing.
  • declined: a person said no at the approval step (or chose to stop at a question), so that step didn't go ahead. Their decision, not a failure.
  • nothing_to_do: there was nothing to do this time.

Delivered work is never reported as a failure. said puts the run in plain words.

Webhooks

On Settings → Developers, add an https endpoint and choose its events. Its signing secret (whsec_…) is shown once. We POST JSON like this:

{
  "id": "evt_9f2c…",
  "type": "run.finished",
  "created_at": "2026-11-21T09:00:12.000Z",
  "workspace_id": "…",
  "data": { "run_id": "…", "mission_id": "…", "mission_title": "Overdue invoice reminders", "status": "completed", "outcome": "partly", "note": "Sent 18 of 20: 2 customers have no email address.", "results_url": "…", "link": "…" }
}
EventWhenData
run.finishedA run endedrun_id, mission_id, status (completed, failed, or stopped after a rejection), outcome (met, partly, not_met, nothing_to_do, declined), note, results_url
approval.neededA run waits for a personapproval_id, kind (approval or question), mission_id, step, approve_url, the link where the person decides
approval.decidedA person approved, rejected or answeredapproval_id, decision, decided_via, decided_at, reason
mission.builtDescribed work became a missionbuild_id, mission_id, steps, needs_connecting, credits

Answer with any 2xx within 10 seconds, and do the slow work afterwards. Anything else is retried: 7 attempts over about 21 hours (after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours). An endpoint is switched off after 50 deliveries fail in a row; switch it back on from the same page. The delivery log there shows each attempt. An event keeps its id across retries, so use the id to ignore repeats. Send a test sends a webhook.test event.

Endpoints must be https on port 443 or 8443, on a public address. We never call private, loopback or link-local addresses, and we check every redirect the same way.

Checking the signature

Each delivery has AF-Signature: t=<unix seconds>,v1=<hex>. The v1 value is the HMAC-SHA256 of <t>.<raw body>, keyed with your signing secret. Check it against the raw body, before parsing it, and refuse anything older than 5 minutes:

import { createHmac, timingSafeEqual } from 'crypto';

export function verifyAgenticFactor(rawBody: string, header: string | null, secret: string): boolean {
  if (!header) return false;
  const parts = Object.fromEntries(header.split(',').map(p => p.trim().split('=', 2)));
  const t = Number(parts.t);
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > 300) return false;
  const expected = Buffer.from(createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex'));
  const got = Buffer.from(String(parts.v1 ?? ''));
  return got.length === expected.length && timingSafeEqual(got, expected);
}

// Next.js route handler
export async function POST(req: Request) {
  const raw = await req.text();
  if (!verifyAgenticFactor(raw, req.headers.get('af-signature'), process.env.AF_WEBHOOK_SECRET!)) {
    return new Response('bad signature', { status: 400 });
  }
  const event = JSON.parse(raw);
  // …queue your work, keyed by event.id…
  return new Response('ok');
}
import hmac, hashlib, time

def verify_agentic_factor(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(p.strip().split("=", 1) for p in (header or "").split(",") if "=" in p)
    t = int(parts.get("t", "0"))
    if abs(time.time() - t) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))

Approvals

GET /approvals lists what waits for a person's OK. Each item shows the step, what it wants to do (actions), a preview of what goes out, and an approve_url. Show the person the link, or let the approval.needed webhook alert them. They decide in Agentic Factor, and the approval.decided webhook tells you the result. The run then carries on by itself.

Nothing in this API can approve, reject or answer on their behalf. A request that tries, by any route, is refused.

The older trigger URL

POST /api/v1/trigger/{missionId} still works, with an API key from Settings → Developers. It is the same as POST /missions/{id}/runs, and its {"payload": …} body becomes the run's input. New code should use /missions/{id}/runs.

Make an API key