REST API
The InfraFence REST API v1 - API keys, scopes, rate limits, errors, pagination and every endpoint for servers, events, incidents, bans and the allow list.
Last updated:
The InfraFence API lets your own tools read and change what the dashboard shows: servers and their status, security events and incidents, bans and the allow list. It can also create install tokens to add servers. It is a JSON API over HTTPS at https://infrafence.com/api/v1.
The API is for organizations on a paid plan: Basic, Pro or AutoMode. It is not available on the free Starter plan or during the 14-day free trial. See Billing and plans.
To be told when something happens, use the signed webhooks of the alert channels: the API answers your requests, the webhooks call you.
The OpenAPI 3.1 description of the API is public, no key needed: https://infrafence.com/api/v1/openapi.json. Import it into Postman, Insomnia or a client generator.
Get an API key
Under Settings › API, owners and admins create and revoke keys. Members see the list.
- Click Create API key.
- Give it a Name, the tool that will use it (for example "Billing system").
- Choose the Access: Read only, or Read and write.
- Copy the key. It is shown once and cannot be recovered: if you lose it, revoke it and create a new one.
- Keys belong to the organization, not to the person who created them.
- An organization has at most 20 active keys.
- Revoke stops a key at once. It cannot be undone.
- The list shows when each key was last used.
- There is no test mode: every key works on your real servers. Try writes on a test server first.
A key looks like ifk_ followed by 40 letters and digits. Keep it secret like a password, and use it only from your own servers, never in a web page or a mobile app.
Authentication
Send the key in the Authorization header of every request:
curl https://infrafence.com/api/v1/servers \
-H "Authorization: Bearer ifk_..."A missing, unknown or revoked key gets 401 unauthorized. After 30 failed authentications in a minute from the same address, that address gets 429 rate_limited for the rest of the minute.
Every request is checked against the organization's plan. An organization that is not on a paid plan, or whose payment has failed for more than 72 hours, gets 403 plan_required.
Scopes
| Access | Can do |
|---|---|
| Read only | Every GET: servers, events, incidents, bans, allow list. |
| Read and write | Everything above, plus ban and unban addresses, change the allow list, create install tokens. |
A read-only key that tries a write gets 403 insufficient_scope. Every write is recorded in the organization's activity log, on the Team page.
Rate limits
Limits are counted per minute:
| Limit | Requests per minute |
|---|---|
| Reads, per key | 120 |
| Writes, per key | 30 |
| Reads of events and incidents, per key | 30 (within the 120) |
| All the keys of an organization together | 600 |
| Reads of events and incidents, all the keys of an organization together | 60 (within the 600) |
| Failed authentications, per address | 30 |
Every authenticated answer carries the state of the key's limit (on an org_rate_limited answer, of the organization's):
X-RateLimit-Limit: the limit of this kind of request;X-RateLimit-Remaining: the requests left in this minute;X-RateLimit-Reset: when the minute ends, in Unix seconds.
Over a limit you get 429 with a Retry-After header, in seconds: rate_limited for the key, org_rate_limited for the organization. Wait that long, then retry.
Every answer also has the header InfraFence-API-Version, the date of the API's version (2026-11-13).
Errors
Errors are JSON with a stable code and an English message for people. Use the code in your code: the message may change.
{
"error": {
"code": "insufficient_scope",
"message": "This API key is read-only: use a key with the write scope."
}
}| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request |
A parameter or the body is not valid, including a time outside 2000-2099 or an impossible date. The message names the field. |
| 400 | invalid_json |
The body is not a JSON object. |
| 400 | invalid_cursor |
The cursor is not one this API returned. |
| 400 | invalid_range |
since is not before until, or the range is longer than 31 days (events) or 7 days (incidents). |
| 401 | unauthorized |
The API key is missing, unknown or revoked. |
| 403 | plan_required |
The organization is not on a paid plan (Basic, Pro or AutoMode) that is paid for. |
| 403 | insufficient_scope |
The API key is read-only. |
| 403 | plan_limit |
The plan's server limit is reached. |
| 403 | not_api_entry |
The allow list entry was added in the dashboard: remove it there. |
| 404 | not_found |
No such object in this organization, or no such endpoint. |
| 405 | method_not_allowed |
The endpoint does not accept this method. The Allow header lists the ones it does. |
| 409 | already_banned |
The address is already banned on every server asked. |
| 409 | not_active |
The ban has already ended. |
| 409 | already_exists |
The allow list already has this entry. |
| 409 | no_servers |
The organization has no server yet. |
| 409 | allowlist_limit |
The organization has 100 allow list entries in force added through the API. |
| 409 | install_token_limit |
The organization has 50 unused, unexpired install tokens. |
| 413 | payload_too_large |
The body is larger than 16 KB. |
| 422 | ip_not_bannable |
The address must never be banned. The message says why (see Ban an address). |
| 422 | range_too_wide |
A range wider than /16 (IPv4) or /48 (IPv6): the API adds narrower ones only (the dashboard down to /8 and /32). |
| 429 | rate_limited |
Too many requests for this key, or too many failed authentications: wait Retry-After seconds. |
| 429 | org_rate_limited |
Too many requests for the organization (600 a minute across all its keys, 60 of them on events and incidents): wait Retry-After seconds. |
| 500 | internal_error |
Unexpected error: retry later. |
| 503 | unavailable |
Temporarily unavailable, or the query took too long: retry later, or narrow the range or the filters. |
Conventions
- Times are ISO 8601 in UTC, such as
2026-11-13T09:00:00.000Z. In filters you can use any offset (2026-11-13T10:00:00+01:00). Times must be from 2000-01-01 up to, but not including, 2100-01-01. - Ids are numbers. A server's
idis the same as in the dashboard's URLs and in the webhooks (server.id). - Bodies are JSON objects of at most 16 KB, sent with
Content-Type: application/json. Unknown fields are refused withinvalid_request. - Lists are newest first.
Pagination
Lists return one page and a cursor:
{
"data": [ ... ],
"next_cursor": "WyIyMDI2LTExLTEzVDA4OjE1OjAwKzAwOjAwIiw5ODIxXQ"
}limit: rows per page, 1 to 200, default 50 (servers: 1 to 100).cursor: thenext_cursorof the previous page, to read the next one. Keep the same filters.next_cursorisnullon the last page.
The cursor is opaque: pass it back as it is.
curl "https://infrafence.com/api/v1/events?limit=200&cursor=WyIyMDI2LTExLTEzVDA4OjE1OjAwKzAwOjAwIiw5ODIxXQ" \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"Servers
List servers
GET /servers: the organization's servers, newest first. Any key.
Query: limit (1 to 100, default 50), cursor.
curl https://infrafence.com/api/v1/servers \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": [
{
"id": 42,
"name": "web-01",
"hostname": "web-01.example.com",
"ip": "203.0.113.10",
"private_ip": null,
"os": "Ubuntu",
"os_version": "24.04",
"agent_version": "1.0.35",
"status": "online",
"last_seen_at": "2026-11-13T09:14:52.000Z",
"created_at": "2026-10-02T14:03:11.000Z",
"security_score": { "score": 86, "grade": "B" },
"mode": "protect",
"domains": ["example.com", "shop.example.com"]
}
],
"next_cursor": null
}ip: the server's public address as InfraFence sees it;private_ip: the address of its own network interface when it differs (a cloud VM behind NAT, such as Oracle Cloud, AWS, Google Cloud or Azure), otherwisenull.status:online(reported in the last 150 seconds),offline(in the last 10 minutes) ornot_reporting(longer ago, or never), as in the dashboard.security_score: the dashboard's security score, 0 to 100, with its grade;nullbefore the first check.mode: the server's protection mode,protect(Full protection) ormonitor(Learning: detects and reports, blocks nothing). The API reads it only: it is switched on the server's page.domains: the sites the server reports (web server and hosting panel), withwww.folded.
Get a server
GET /servers/{id}: one server, with the same fields. Any key.
curl https://infrafence.com/api/v1/servers/42 \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": {
"id": 42,
"name": "web-01",
"status": "online",
"...": "same fields as in the list"
}
}A server of another organization, or one that does not exist, gets 404 not_found.
Create an install token
POST /install-tokens: a single-use token, valid one hour, and the command that installs the agent with it, as on the dashboard's Add server page. Write scope.
Body:
label(optional, up to 80 characters): your note, shown under Settings › Install tokens.mode(optional): the protection mode the server starts in when it registers,protect(Full protection, the default) ormonitor(Learning: detects and reports, blocks nothing, until you switch the server to Full protection on its page).
curl -X POST https://infrafence.com/api/v1/install-tokens \
-H "Authorization: Bearer $INFRAFENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"label": "customer 1234 - vps-88", "mode": "monitor"}'{
"data": {
"id": 311,
"token": "8c1f...",
"label": "customer 1234 - vps-88",
"mode": "monitor",
"created_at": "2026-11-13T09:20:00.000Z",
"expires_at": "2026-11-13T10:20:00.000Z",
"install_command": "curl -fsSL https://github.com/infrafence/infrafence-agent/releases/latest/download/install.sh | sudo bash -s -- --token 8c1f..."
}
}mode in the answer is the mode the server will start in. An organization can have at most 50 unused, unexpired tokens: one more gets 409 install_token_limit. Use or revoke some first.
With "mode": "monitor" the server starts in Learning: it detects and reports attacks but blocks nothing (no bans, country blocks or web firewall blocks) until someone switches it to Full protection on its page. Leave mode out, or send "protect", for a server that blocks from the start. Creating install tokens needs a key with the write scope (Read and write); a read-only key gets 403 insufficient_scope.
Run install_command as root on the new server, for example from your provisioning script. The server appears in GET /servers once the agent has registered. Read What the installer does before you automate it. Status 201.
Events and incidents
List events
GET /events: the security events of the organization's servers, newest first, as the dashboard lists them. Any key; counts in the limits of 30 event and incident reads a minute per key and 60 per organization.
Query:
server_id: only this server;severity:info,warningorcritical;category:web_attacks,egress_dns,malware,file_integrity,ssh_sessions,host_monitors,infrastructureorother;type: an exact event type, such asssh_brute_force;ip: the source address, exact (IPv4 or IPv6);since,until: the range.sinceis included,untilis not. Default: the last 24 hours. At most 31 days;limit,cursor.
curl "https://infrafence.com/api/v1/events?severity=critical&since=2026-11-12T00:00:00Z" \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": [
{
"id": 98213,
"server_id": 42,
"type": "ssh_brute_force",
"category": "ssh_sessions",
"severity": "critical",
"source_ip": "198.51.100.23",
"source_port": 51544,
"target_port": 22,
"protocol": "tcp",
"details": { "attempts": 41 },
"occurred_at": "2026-11-13T08:15:00.000Z"
}
],
"next_cursor": "WyIyMDI2LTExLTEzVDA4OjE1OjAwKzAwOjAwIiw5ODIxM10"
}details holds everything the agent reported with the event. Its fields depend on the type.
A server_id that is not one of your servers gets 404 not_found.
List incidents
GET /incidents: events grouped as the dashboard groups them: same server, type, severity and source address, at most 8 minutes apart. Status events, such as scan progress, are left out. Newest first, by their latest event. Any key; counts in the limits of 30 event and incident reads a minute per key and 60 per organization.
Query: server_id, severity, category, since, until (default: the last 7 days, at most 7 days), limit, cursor.
curl "https://infrafence.com/api/v1/incidents?server_id=42" \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": [
{
"id": 98102,
"server_id": 42,
"type": "ssh_brute_force",
"title": "SSH brute force",
"category": "ssh_sessions",
"severity": "critical",
"source_ip": "198.51.100.23",
"event_count": 12,
"first_seen_at": "2026-11-13T08:02:41.000Z",
"last_seen_at": "2026-11-13T08:15:00.000Z",
"last_event_id": 98213,
"countries": ["NL"],
"banned": true
}
],
"next_cursor": null
}title: the English label of the type, as the dashboard shows it.countries: ISO 3166 codes of the source, when known.banned: the source address has been banned on that server.
An incident is counted within the range only. Its id is its first event in the range, so it can change from one range to another. last_event_id is stable: use it to open the incident later.
Get an incident
GET /incidents/{id}: the incident an event belongs to, with its latest 50 events, newest first. The id can be the incident's id or the id of any of its events (such as last_event_id). Its events are read within 7 days of that event. Any key; counts in the limits of 30 event and incident reads a minute per key and 60 per organization.
curl https://infrafence.com/api/v1/incidents/98213 \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": {
"id": 98102,
"server_id": 42,
"type": "ssh_brute_force",
"title": "SSH brute force",
"...": "same fields as in the list",
"events": [
{
"id": 98213,
"server_id": 42,
"type": "ssh_brute_force",
"...": "same fields as GET /events"
}
]
}
}Bans
List bans
GET /bans: the bans on the organization's servers, newest first, whoever made them: the agents, AutoMode, the dashboard or the API. Any key.
Query: server_id, ip (exact), state (active, the default: bans in force; expired: ended ones; all), limit, cursor.
curl "https://infrafence.com/api/v1/bans?ip=198.51.100.23" \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": [
{
"id": 3133,
"server_id": 42,
"ip": "198.51.100.23",
"reason": "ssh brute force",
"ban_count": 2,
"expires_at": "2026-11-14T08:15:01.000Z",
"created_at": "2026-11-13T08:15:01.000Z",
"active": true
}
],
"next_cursor": null
}ban_count: how many times the address was banned on this server.expires_at:nullfor a permanent ban.
Ban an address
POST /bans: bans a public IPv4 address on one server or on every server of the organization. It goes through the same queue as the dashboard: the agents apply it within seconds. Write scope.
Body:
ip(required): a public IPv4 address;server_id: the server to ban it on. Omitted: every server of the organization;duration_minutes: 1 to 525600 (one year). Default 1440 (24 hours);reason(up to 200 characters): shown with the ban in the dashboard, afterAPI:.
curl -X POST https://infrafence.com/api/v1/bans \
-H "Authorization: Bearer $INFRAFENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ip": "198.51.100.23", "duration_minutes": 1440, "reason": "ticket 5521"}'{
"data": [
{
"id": 3140,
"server_id": 42,
"ip": "198.51.100.23",
"reason": "API: ticket 5521",
"ban_count": 3,
"expires_at": "2026-11-14T09:30:00.000Z",
"created_at": "2026-11-13T09:30:00.000Z",
"active": true
}
],
"already_banned_server_ids": [57]
}data holds the new bans, one per server. already_banned_server_ids lists the servers where the address was already banned: those bans are left as they were. Status 201.
The same safety rules as the dashboard's ban apply. These addresses are refused with 422 ip_not_bannable, and the message says why:
- addresses on your allow list;
- addresses on InfraFence's list of addresses never to ban (its never-block list and the servers protected by InfraFence);
- addresses someone logged in from over SSH in the last 30 days, or their /24;
- private and reserved addresses;
- IPv6 addresses, which cannot be banned yet.
Other answers: 409 already_banned when the address is already banned on every server asked, 409 no_servers when the organization has no server yet, 404 not_found when server_id is not one of your servers.
Lift a ban
DELETE /bans/{id}: ends the ban now, as the dashboard's Unban. It is lifted on its server, and on every server of the organization when bans are shared between servers. Write scope.
curl -X DELETE https://infrafence.com/api/v1/bans/3140 \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": [
{
"id": 3140,
"server_id": 42,
"ip": "198.51.100.23",
"reason": "API: ticket 5521",
"ban_count": 3,
"expires_at": "2026-11-13T09:41:12.000Z",
"created_at": "2026-11-13T09:30:00.000Z",
"active": false
}
]
}It returns the bans lifted. A ban that has already ended gets 409 not_active.
Allow list
The allow list is the dashboard's whitelist, under Settings › Network: addresses and ranges that are never banned or blocked on any server of the organization.
Through the API you can read every entry, but add and remove only your own: entries added through the API have source: "api", those added in the dashboard source: "dashboard".
List the allow list
GET /allowlist: the entries, newest first. Any key.
Query: limit, cursor.
curl https://infrafence.com/api/v1/allowlist \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": [
{
"id": 77,
"ip": "192.0.2.0/24",
"note": "Office",
"source": "dashboard",
"expires_at": null,
"created_at": "2026-11-01T10:00:00.000Z"
}
],
"next_cursor": null
}source: where the entry was added,apiordashboard.expires_at:nullfor a permanent entry.
Add to the allow list
POST /allowlist: adds an address or a CIDR range. Every server of the organization picks it up within seconds. Write scope.
Body:
ip(required): an IPv4 or IPv6 address, or a CIDR range such as203.0.113.0/24. Through the API, ranges must be at least a /16 (IPv4) or a /48 (IPv6), and IPv4-mapped IPv6 ranges (::ffff:…) at least a /112: wider ones get422 range_too_wide(the dashboard accepts down to /8 and /32);note(up to 200 characters): shown in the dashboard.
curl -X POST https://infrafence.com/api/v1/allowlist \
-H "Authorization: Bearer $INFRAFENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ip": "203.0.113.45", "note": "Customer 1234 office"}'{
"data": {
"id": 81,
"ip": "203.0.113.45",
"note": "Customer 1234 office",
"source": "api",
"expires_at": null,
"created_at": "2026-11-13T09:45:00.000Z"
}
}An entry that is already there gets 409 already_exists. An organization can have at most 100 entries in force added through the API: one more gets 409 allowlist_limit. Status 201.
Remove from the allow list
DELETE /allowlist/{id}: removes an entry added through the API (source: "api") and returns it. An entry added in the dashboard gets 403 not_api_entry: remove it there. Write scope.
curl -X DELETE https://infrafence.com/api/v1/allowlist/81 \
-H "Authorization: Bearer $INFRAFENCE_API_KEY"{
"data": {
"id": 81,
"ip": "203.0.113.45",
"note": "Customer 1234 office",
"source": "api",
"expires_at": null,
"created_at": "2026-11-13T09:45:00.000Z"
}
}OpenAPI
GET /openapi.json: the OpenAPI 3.1 document of this API, with every endpoint, parameter, schema and error code. It is public: no key needed.
curl https://infrafence.com/api/v1/openapi.jsonWebhooks
The API does not push anything. For events as they happen, add a webhook channel under Settings › Alerts: InfraFence then sends JSON, signed with your signing secret, for alerts, servers going offline and online, and bans created and removed. Send test sends a test delivery. The payload, the signature check in Node.js and PHP, and the retries are in Alerts › Webhooks.
The server.id of a webhook is the id of GET /servers/{id}, and the ban ids are the ones of GET /bans.
