API reference for developers
This reference helps you send logs to Botmotive, read its rules feed and script your sites over HTTP.
It is a reference, not a tutorial. Most site owners never need it: the WordPress plugin, log drains and guards call these routes for you. See Getting started first.
The base URL of the hosted service is https://api.botmotive.io. All bodies are JSON unless noted.
Authentication
There are two kinds of credential.
| Credential | Prefix | For | How to send it |
|---|---|---|---|
| Site token | bm_ |
Machines: log drains, the WordPress plugin, guards | Authorization: Bearer <token>. Ingest also accepts ?token=<token>, but only from a token whose only scope is ingest. |
| User session | bms_ |
People and scripts acting as a person | Authorization: Bearer <token> only. Never in the URL. |
A site token belongs to one site and cannot read dashboard data. A site can have several, each with a name and scopes:
ingest: send logs, push robots.txt and known URLs.guard: read the rules feed.site: trigger classification.
A token without a route's scope gets 401, the same as a wrong token. Creating a site gives you a token named "Default" with every scope, shown once. Owners can add a token per connection, for example one with only ingest for a log drain, and revoke one without touching the others. POST /v1/sites/:siteId/token replaces the Default token, and the old one stops working at once.
A user session comes from POST /v1/auth/login and lasts 30 days. It reaches a site only through a membership. Each membership has a role: owner or member.
Auth column values below:
- none: no credential.
- site token: one of the site's
bm_tokens, with the scope the route needs. - user: any valid session.
- member: a session whose user belongs to the site. A site you do not belong to returns
404, not403, so site IDs cannot be probed. - owner: a member with the
ownerrole. Other members get403. - either: a member session or a site token with the
sitescope.
Routes
Accounts and sites
| Route | Auth | Purpose |
|---|---|---|
POST /v1/auth/signup |
none | {email, password} (password 10 to 200 characters) → {user, token}. Where email is set up, returns 202 {pending: true} and emails a confirmation link instead. Can be turned off by the operator. |
POST /v1/auth/login |
none | {email, password} → {user, token}. |
POST /v1/auth/logout |
user | Ends the session. |
GET /v1/me |
user | The user and their sites, each with its role. |
POST /v1/sites |
user | {id, name, domain?, platform?, plugin_only?, default_token?} creates a site you own. Returns its ingest token once. platform is where the site runs: wordpress, nextjs, vercel, django, laravel, cloudflare, fastly, server or railway. domain is the site's address, saved as a bare hostname. With default_token: false the site starts with no token and token is null. |
POST /v1/sites/:siteId/token |
owner | Replaces the Default token. The old one stops working; other tokens keep working. Rotates the guard key too. |
POST /v1/sites/:siteId/guard-key/rotate |
owner | Replaces the site's guard key (payer tokens, Sign-In-With-X nonces, host proof). Guards get the new key on their next feed fetch; the old key is still accepted for 1 hour. Revoking a guard token or replacing Default does this too. |
GET /v1/sites/:siteId/tokens |
owner | Named tokens with their scopes, creator, last_used (updated at most hourly) and revoked_at. Never the secret. |
POST /v1/sites/:siteId/tokens |
owner | {name, scopes?} creates a token. scopes is a list of ingest, guard and site, all by default. Returns {token, secret}; the secret is shown once. At most 50 live tokens per site. |
DELETE /v1/sites/:siteId/tokens/:id |
owner | Revokes one token at once. It stays in the list as revoked. Revoking a token with the guard scope rotates the guard key. |
POST /v1/connect/codes |
owner | Used by the dashboard for the WordPress Connect button. {site_id, site_url, return_url, nonce_hash, confirm_domain?} → {code, redirect}. A site with no domain yet takes the plugin's host as its domain, so confirm_domain must equal that host. The plugin's token gets the ingest and guard scopes. return_url must be https on the same site (www. aside) and the plugin's wp-admin/admin-post.php?action=botmotive_connect. The code works once, for 10 minutes. |
POST /v1/connect/complete |
none; the code | The plugin's server trades {code, nonce} for {site_id, site_name, token}. The nonce must hash (sha256) to nonce_hash, and a wrong one uses the code up. |
Site IDs are 2 to 40 characters: lowercase letters, digits and dashes, starting with a letter or digit.
Ingest and site files
| Route | Auth | Purpose |
|---|---|---|
POST /v1/ingest/:siteId?source=… |
site token (ingest) |
Request logs. See Ingest. |
PUT /v1/sites/:siteId/robots |
site token (ingest) |
robots.txt body as plain text. Stored as a new version only when it changes. |
PUT /v1/sites/:siteId/known-urls |
site token (ingest) |
{"paths": [...]} from the sitemap. Replaces the last push. Up to 50,000 paths of up to 2,000 characters, 6 pushes an hour per site (429 with Retry-After beyond). Paths not pushed again within 30 days are dropped. |
GET /v1/sites/:siteId/rules |
site token (guard) |
The rules feed. See Rules feed. |
Classification and results
| Route | Auth | Purpose |
|---|---|---|
POST /v1/sites/:siteId/classify?window=15m|24h|7d |
either | Classify the most recent completed window now. |
GET /v1/sites/:siteId/bots?window=15m|today|24h|7d |
member | Latest labels and insights, each with its fixes and applied actions. today is the current day so far, marked provisional. |
GET /v1/sites/:siteId/setup |
member | First-run state: whether a full day has been labelled (reported), the first request's time, requests so far, the newest tab with results (newest), and when the first 15-minute and daily results are due. The dashboard adds ?viewing=1 on the site's main page, which counts the first time someone sees a full report. |
GET /v1/sites/:siteId/history?days=7|30 |
member | Traffic by visitor type, fix markers, and host prices for the cost tile. |
GET /v1/sites/:siteId/scorecard |
member | Per claimed bot over 7 days: real and fake requests, robots.txt violations. |
GET /v1/sites/:siteId/paths?days=7|30 |
member | Top paths per bot type, login attempts and probes. |
GET /v1/sites/:siteId/referrals?days=7|30 |
member | Per company: pages its crawlers fetched against visitors it sent back. |
GET /v1/sites/:siteId/llms-txt?days=7|30 |
member | Requests for /llms.txt and /llms-full.txt, and reads per AI crawler. |
GET /v1/sites/:siteId/crawl-value |
member | AI crawls over the last 30 days scaled to a month, per bot, with the site's price per crawl. |
GET /v1/sites/:siteId/license.xml |
member | The site's RSL license as XML, for hosts without the plugin or a guard. |
GET /v1/sites/:siteId/alerts |
member | Recent alerts. |
Fixes
| Route | Auth | Purpose |
|---|---|---|
POST /v1/sites/:siteId/actions |
member | Apply a fix: {actor_key | insight_id, fix_id, window?, confirmed?}. |
GET /v1/sites/:siteId/actions |
member | Active actions. |
DELETE /v1/sites/:siteId/actions/:id |
member | Undo an action. |
GET, POST, DELETE /v1/sites/:siteId/self |
member | "This is me": {actor_key}. Counts that actor as the owner from the next run and hides it at once. |
window defaults to 24h and must match the window the actor_key or insight_id came from. When a fix carries a guardrail, the first call returns 409:
{ "error": "confirmation_required", "confirm": "This removes your site from Google's search results over time. Continue?" }
Show the message to a person, then repeat the call with "confirmed": true. Only an owner can apply a guarded fix. A member gets 403. Success returns 201 with {action, snippets, note}.
Settings, integrations and billing
| Route | Auth | Purpose |
|---|---|---|
GET, PUT /v1/sites/:siteId/settings |
member to read, owner to change | {cost_per_gb, cost_per_server_hour, alerts_email, digest_email, domain, ai_policy, rsl, crawl_price, chat_webhook}. PUT is a partial update. |
POST /v1/sites/:siteId/chat/test |
owner | Posts a test message to the Slack or Discord webhook. |
PUT /v1/sites/:siteId/railway |
owner | {token, service_id, environment_id, domain?} connects a Railway service. The token is checked, then stored encrypted. |
GET /v1/sites/:siteId/railway |
member | Connection status: cursor, last pull, last error. Never the token. |
DELETE /v1/sites/:siteId/railway |
owner | Stop pulling. |
GET /v1/billing |
user | Plan, status, usage and whether billing is on. |
POST /v1/billing/checkout, /v1/billing/portal |
user | {plan} → Stripe Checkout or customer portal URL. 503 while billing is off. |
POST /v1/stripe/webhook |
Stripe signature | Subscription events from Stripe. |
Settings value rules:
cost_per_gb,cost_per_server_hour: a number from 0 to 10,000, ornull.crawl_price: a number above 0 and up to 100, ornull.domain: a host name such asexample.com, ornull.ai_policy:null, or{"search": "allow"|"block", "assistants": "allow"|"block", "training": "allow"|"block", "enforce": true|false}.chat_webhook: a Slackhttps://hooks.slack.com/services/…or Discordhttps://discord.com/api/webhooks/…URL.nullor""removes it. It is never returned.GETreturnschat("slack","discord"ornull) instead.
Ingest
POST /v1/ingest/:siteId?source=cf_logpush|vercel|fastly|wp_plugin|railway|nginx
The body can be NDJSON, a JSON array, or {"records": [...]}. It may be gzipped: send Content-Encoding: gzip, or just send gzip bytes. With source=nginx, the body can also be raw access log lines, either Botmotive's JSON log format or the standard combined format.
Example with nginx log lines:
gzip -c /var/log/nginx/botmotive.log | curl -sS \
-H "Authorization: Bearer $BOTMOTIVE_TOKEN" \
-H "Content-Encoding: gzip" \
--data-binary @- \
"https://api.botmotive.io/v1/ingest/my-blog?source=nginx"
Example with one Cloudflare Logpush record:
curl -sS -H "Authorization: Bearer $BOTMOTIVE_TOKEN" \
--data-binary '{"ClientIP":"203.0.113.9","ClientRequestUserAgent":"Mozilla/5.0","ClientRequestURI":"/","ClientRequestMethod":"GET","EdgeStartTimestamp":1790834400000000000,"EdgeResponseStatus":200,"EdgeResponseBytes":28000}' \
"https://api.botmotive.io/v1/ingest/my-blog?source=cf_logpush"
As a Cloudflare Logpush destination, which cannot send headers the usual way:
https://api.botmotive.io/v1/ingest/<site>?source=cf_logpush&header_Authorization=Bearer%20<token>
If a drain can't send any header, put the token in the URL instead:
https://api.botmotive.io/v1/ingest/<site>?source=nginx&token=<token>
URLs leak more easily than headers: CDN logs, provider dashboards and support tickets keep them. So a ?token= must be an ingest-only token, one with the ingest scope and no other. Botmotive answers any other token in the URL, including the Default token, with 401 and an error that says to make an ingest-only token. Make one in Settings under Tokens: click New token and tick only Send traffic logs. Or call POST /v1/sites/:siteId/tokens with {"name": "Log drain", "scopes": ["ingest"]}. The same token works as a Bearer header too.
The response says how many records were kept:
{ "accepted": 1, "skipped": 0, "sample_errors": [] }
Records older than 35 days, or more than one day in the future, are skipped. A line that cannot be read is skipped, not the whole batch. sample_errors shows a few reasons.
Rules feed
GET /v1/sites/:siteId/rules
The WordPress plugin and the guards poll this with the site token. It answers with an ETag. Send it back in If-None-Match to get 304 Not Modified when nothing changed.
curl -sS -H "Authorization: Bearer $BOTMOTIVE_TOKEN" \
-H 'If-None-Match: "3f1c9a0b5d2e7f41"' \
"https://api.botmotive.io/v1/sites/my-blog/rules"
Response:
{
"version": "3f1c9a0b5d2e7f41",
"rules": [
{ "id": "12", "action": "block", "match": { "cidrs": ["198.51.100.0/24"] } },
{ "id": "13", "action": "throttle", "match": { "cidrs": ["203.0.113.7/32"] }, "limit_per_min": 20 },
{ "id": "14", "action": "deny_path", "match": { "paths": ["^/\\.env$"] } },
{ "id": "policy-GPTBot", "action": "block", "match": { "user_agent": "GPTBot" } }
],
"robots_txt": "User-agent: GPTBot\nDisallow: /\n\nUser-agent: *\nContent-Signal: search=yes, ai-input=yes, ai-train=no",
"license_xml": ""
}
Rule fields:
action:allow,throttle,block,deny_pathordisable_xmlrpc.match: every field present must match.cidrsare address ranges.asnsare network numbers.user_agentis a case-insensitive substring.pathsare anchored regular expressions.limit_per_minorlimit_per_hour: the per-IP limit forthrottle.
Enforcers apply path denials first, then blocks, then allows, then throttles. Rules that match only on asns need a CDN, since the plugin and guards cannot see network numbers.
robots_txt is the managed robots.txt section: opt-outs and AI bot rules. license_xml is the RSL license, or "" when it is off. Whoever serves /license.xml also adds the License: line to robots.txt.
Limits
| What | Limit |
|---|---|
| Sign-in | 10 failed attempts per email and IP, or per IP, in 15 minutes, then 429. |
| Sign-up | 5 per IP an hour, then 429. |
| Account changes (password, email, delete) | Need the current password. 10 attempts in 15 minutes, then 429. |
| Classify | One run per site at a time. A second call returns 409. |
| Ingest body | 16 MB uncompressed, and 100,000 records per request. Records are counted as the body inflates: more than 101,000 lines (except inside a JSON array), or 400,000 { and [ outside strings, is refused. Vercel drain deliveries may be 20 MB compressed and 64 MB uncompressed. |
| robots.txt and known URLs body | 20 MB. |
| Other bodies | 1 MB, or 16 KB for /v1/auth/ routes. |
| Monthly usage | When billing is on, ingest returns 402 once the site owner reaches twice their plan's monthly requests. |
A body over its limit returns 413.
Errors
Errors return JSON with an error message, for example {"error": "unauthorized"}.
| Status | Meaning |
|---|---|
400 |
Bad input. The message says which field. |
401 |
Missing or wrong credential, or a ?token= that isn't ingest-only. |
402 |
Plan limit reached: no room for another site, or the monthly allowance is used up. |
403 |
Owners only, or sign-up is closed. |
404 |
Not found, or you are not a member of the site. |
409 |
Confirmation needed for a fix, a classify run already going, or a taken site ID or email. |
413 |
Body too large. |
429 |
Too many attempts. |
503 |
Billing or email is not set up on this server, or ingest is busy: retry after the Retry-After seconds with the same batch. |