Skip to content

Runs API

Add a site, start an agent run, wait for it and read the result, from a script or from your own AI agent. Everything the dashboard does with sites and runs works with an API key.

Get an API key

Sign in, open your account menu and choose API keys. Create a key and copy it: it is shown once. Keep it in an environment variable, never in a chat or in your code:

export AGENTFRENDLY_API_KEY=afk_...

Send it on every request as Authorization: Bearer $AGENTFRENDLY_API_KEY. A key acts for your account on sites and runs. It cannot create or revoke keys, and revoking it on the API keys screen stops it at once. An account can have 10 keys, and each key can make 120 requests a minute.

Endpoints

  • GET /api/accounts/session: check the key; returns the account's email and how many runs it has left.
  • GET /api/sites, POST /api/sites, DELETE /api/sites/{siteId}: list, add and remove the web apps you test.
  • POST /api/sites/{siteId}/verify: prove you control a site's domain.
  • GET /api/agent-runs/profiles: the agents a run can use.
  • POST /api/agent-runs/jobs: start a run.
  • GET /api/agent-runs/jobs, GET /api/agent-runs/jobs/{runId}: list runs, and get one run's status and results.
  • GET /api/agent-runs/jobs/{runId}/report: the report as Markdown.

The OpenAPI description has every field.

Start a run and read it

Add the site once.

curl -sS https://agentfrendly.com/api/sites -H "Authorization: Bearer $AGENTFRENDLY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"origin":"https://your-product.com"}'

Agents run only on sites whose domain you have proven you control. The proof covers the site's registrable domain, returned as domain, and every host under it. Publish one of these, with the verificationToken from the answer:

  • a DNS TXT record at _agentfrendly.your-product.com with the value agentfrendly-verify=VERIFICATION_TOKEN, or
  • a file at https://your-product.com/.well-known/agentfrendly-verify.txt with the line agentfrendly-verify=VERIFICATION_TOKEN.

Then check it. The answer is the site with verifiedAt set, or 422 with what was found and what to publish. Runs check the proof again once it is 24 hours old, so keep it published. Extra hosts must be on another site of yours that you have verified.

curl -sS -X POST https://agentfrendly.com/api/sites/SITE_ID/verify -H "Authorization: Bearer $AGENTFRENDLY_API_KEY"

Start a run with the site's id and agent names from /api/agent-runs/profiles. Agents get no browser: they use your site's API, MCP server and docs, and must find those themselves. This spends runs from your account's balance: tasks × agents × attempts, at most 30 per request and 10 a day. Runs are bought in packs on the website; GET /api/accounts/session returns how many are left as credits.

curl -sS https://agentfrendly.com/api/agent-runs/jobs -H "Authorization: Bearer $AGENTFRENDLY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "siteId": "SITE_ID",
    "siteUrl": "https://your-product.com",
    "tasks": [{ "goal": "Find the monthly price of the Team plan and report it." }],
    "profiles": ["claude-sonnet"],
    "attempts": 3
  }'

The answer comes back at once with "status": "queued". Ask for the run about every 10 seconds until its status is done, failed or interrupted, then read the report:

curl -sS https://agentfrendly.com/api/agent-runs/jobs/RUN_ID -H "Authorization: Bearer $AGENTFRENDLY_API_KEY"
curl -sS https://agentfrendly.com/api/agent-runs/jobs/RUN_ID/report -H "Authorization: Bearer $AGENTFRENDLY_API_KEY"

rows holds the result per task and agent: successes out of runs, and falseClaims, the attempts where the agent said it succeeded and the check disagreed. The report lists every attempt that did not succeed with its last steps.

Errors

Failed requests return JSON with an error message that says what to do.

  • 400: the request is not valid. The message names the field.
  • 401: the key is missing, wrong or revoked. Create a new one on the API keys screen.
  • 402: the account holds fewer runs than the request needs. The message and the needed and balance fields say how many. Buy runs on the website, signed in, then send the request again. Listing agents answers 402 too until the account has held runs. Sites still work.
  • 403: the site, or the domain of an extra host, is not verified. The message says what to publish.
  • 404: no such site or run on your account.
  • 409: the report is not ready because no attempt has finished.
  • 422: the site's ownership proof was not found. The message says what was found and what to publish.
  • 429: the key made more than 120 requests in a minute (wait for the seconds in Retry-After), a site was checked more than 10 times in a minute, or a daily run limit was reached (it starts again at midnight UTC).
  • 503: the runner is starting. Try again in a few seconds.

MCP server

The same operations are MCP tools at https://agentfrendly.com/mcp (Streamable HTTP), with the same key in the Authorization header. See For agents.