SafeAI documentation

Integration and API

The read API, alerts in, OpenTelemetry logs, and the fix record.

How another system (the SafeAI platform, a SIEM, a CMDB, a ticketing tool) uses what SafeAI Edge knows. Two ways in, both outbound from Edge's point of view of trust: the other system reads; Edge pushes alerts. Nothing outside Edge can change a device, approve a fix or alter a change record through these interfaces. AI agents you run have their own way in, each with its own key and its own limits (section 5). The one way in that affects results is a planned-changes token: it can post change windows, which decide whether a later change counts as planned. Windows posted with a token are limited to at most 24 hours, starting no earlier than now (a window can't be back-dated over changes already made) and no more than 30 days ahead, and covering at most 50 devices (a site: entry counts as every device at that site); they can't use * (all devices). The ServiceNow import does the same from change requests: only devices whose names appear as whole words in the change, never *, for the change's own planned start and end (not limited to 24 hours, since real changes can run longer). Cancelled changes and changes closed incomplete are skipped, and a window whose change is later cancelled or no longer returned is withdrawn.

1. Read API (pull)

  • Create a token in the console: Planned changes, From other systems, What it may do: Read. It is shown once; Edge keeps only its SHA-256. Revoke it on the same page. A token for posting planned changes can't read, and a read token can't post.
  • Every call: GET https://<edge>/api/v1/<path> with Authorization: Bearer <token>. JSON responses. TLS is Edge's console certificate (install your own with safeaictl tls-install).
Path Returns
devices {"devices": [{name, vendor, preview, site, address, read_ok, last_read, findings: {high, medium, low}}]} (preview: the platform isn't yet proven at a customer; Compatibility matrix says where it was tested) — every device, server, cloud account and agent computer
findings {"findings": [{id, device, severity, title, why, suggest, lines}]} — current problems from Edge's fixed checks. device may name several devices (cross-device checks, joined by " & "). lines are the evidence lines, exactly as stored (redacted).
changes?since=<ISO time> {"changes": [...]} — the change list (newest first, at most 1000): id, device, site, detected_at, found_by, status (unplanned / planned / planned_with_problem / routine), state, severity, summary, ticket, lines
changes/<id> the full change record, plus integrity: "ok" or what doesn't match its fingerprint, and authorization: {status (verified / matched / not_verified / routine), text, basis, content (matches / consistent / differs / not_compared), content_note, approval, review: {outcome (authorized / not_authorized / investigating), by, at, reference, note}}. made says when the change was made as far as SafeAI can know: {at, basis} from a device log, or {from, to, basis} for a change found by the scheduled check. The list's status values are unchanged for compatibility: unplanned means "authorization not verified", never "unauthorized"
agents {"agents": [{id, device, hostname, os, arch, version, enrolled, last_seen, revoked, last_ip}]}
fixes {"fixes": [fix record]} (below)
controls every control result: {areas, controls, results: [{control, device, status (pass / fail / no_data / excepted), evidence, note, since, checked, exception}], summary, zones: {zones, rules, status}} (status: per zone rule, each device joining both zones with verdict blocked / allowed / unknown, note, lines)
coverage {assets: [{id, ips, macs, names, seen_by, where, kinds, status (covered / probable / not_covered / set_aside), covered_by, how, reason}], sources: {device: {status, note, seen, covered, set_aside, not_covered}}, summary, rules, unread} — computers SafeAI sees and whether it reads them
controls/frameworks/<soc2 / iso27001 / pci / nistcsf / cis> {framework, requirements: [{id, title, controls, results: {pass, fail, no_data, excepted}}], unmapped, disclaimer} — SafeAI's suggested mapping of its controls to that framework, with current results; not an auditor's ruling. controls itself lists each control's frameworks and every result's source: {address, via, read_at}
incidents, incidents/<id> the incident list; one incident with its timeline (items: {kind, at, from, device, id, summary, why, score}, blind_spots), hypotheses ({id, kind, device, params, text, source, status (proven / disproven / unknown), evidence: [{at, kind, verdict, line, note, command, run, sha256}]}), summary (known, ruled_out, unknown, next), resolution and log_integrity
measure?since=&until= {period, changes, incidents, assurance_now, not_measured_here}: counts from SafeAI's own records only; null means nothing to count
inventory {records: [{id, name, kind, state (inspected / stale / inaccessible / discovered / set_aside / disabled), last_verified, inspected: {at, via, lines, understood}, inaccessible: {reason, text, detail, since, fails}, discovered: {first, last, by, where}, facts: [{what, value, basis (observed / configured / inferred), source, at, how}], gaps: [{what, why}]}], summary, blind_spots: [{source, why}], max_read_age_h} — everything SafeAI knows about and how it knows it. basis says whether SafeAI read a fact itself, was told it (the inventory), or worked it out; an inferred fact is never evidence by itself
health Edge's own health: {status: ok / warn / fail, version, checks: [...]}

Identifiers are stable: a device's name, a change's id (CHG-...), a fix's id (FIX- + 12 hex), a finding's id (for example vty-telnet, linux.ssh-root-login, ai.mcp-secret) together with its lines.

2. Alerts (push)

Settings, Alerts: a webhook channel posts JSON {source: "safeai-observe", event, title, body, severity, link, url, data} for the events you choose: unplanned_change (a change SafeAI found no approval for; the event name is kept for compatibility, the title reads "Change with no matching approval on "), planned_change_problem, health, fix (a fix finished, failed or was rolled back; data carries fix, device, result), control (a proven or accepted control result started failing, or a proven one can no longer be proven; data.results lists {control, device, from}). A syslog channel sends the same to a SIEM. An alert account (bearer token) is tied to the first destination it is used with.

An OpenTelemetry Collector channel (otlp) sends the same events as OTLP/HTTP JSON log records to a collector's OTLP receiver (https://collector:4318, SafeAI adds /v1/logs): resource service.name=safeai, service.version, safeai.organization; record body "title + body"; attributes safeai.event, safeai.title, safeai.link and each scalar field of data as safeai.<field>; severity from the event. The collector can pass them to any back end it supports (Splunk, Datadog, Elastic, Kafka, an observability or AIOps platform such as Selector).

2b. Logs in from an OpenTelemetry Collector

SafeAI accepts OTLP/HTTP logs at POST https://<SafeAI>:8443/otlp/v1/logs (protobuf or JSON, gzip or not) with a bearer token of scope logs (Settings, API tokens). The token is checked before the body is read; requests are at most 5 MB (32 MB unpacked) and 20,000 records. A record is about a device SafeAI reads when its net.peer.ip, client.address or source.address attribute is the device's address, or its hostname / host.name is the device's name; such records go through the syslog path (a configuration change makes SafeAI read the device now; logins are activity). Other records are counted per sender and the last few kept with secrets replaced (Health shows them); SafeAI is not a log store.

Collector configuration (devices send syslog to the collector; the collector forwards to SafeAI):

receivers:
  syslog:
    udp: {listen_address: 0.0.0.0:514, add_attributes: true}   # add_attributes records each device's address (net.peer.ip)
    protocol: rfc3164
    on_error: send_quiet          # lines without an RFC 3164 header (Cisco IOS often) are still forwarded, without an error logged per line
  otlp:
    protocols:
      http: {endpoint: 0.0.0.0:4318}                             # SafeAI's events in (an "otlp" alert channel)
exporters:
  otlphttp/safeai:
    endpoint: https://safeai.example.com:8443/otlp
    headers: {Authorization: "Bearer ${env:SAFEAI_LOGS_TOKEN}"}
    # tls: {ca_file: /etc/otel/safeai-ca.pem}                  # SafeAI's certificate, if it isn't from a public CA
service:
  pipelines:
    logs/devices: {receivers: [syslog], exporters: [otlphttp/safeai]}
    logs/safeai:  {receivers: [otlp],   exporters: [your back end]}

Tested with OpenTelemetry Collector contrib 0.120.1 (protobuf with gzip, the exporter's default, and encoding: json). On the lab server it runs as a service with Cisco IOS sending to it; IOS lines like <189>15983: HQ-R: *Nov 6 16:15:09.196: %LINK-... have no RFC 3164 timestamp, so the receiver can't parse their header: the default on_error: send still forwards them (SafeAI reads the device from net.peer.ip) but logs an error for each one.

3. The fix record (evidence of a governed change)

Each approved fix is one record. The fields a governance system needs:

Field Meaning
id, device, vendor which fix, on what
finding {id, title, severity, lines, why} — the problem it addresses, with the evidence lines
plan {fix, title, target, steps, risk, rollback} plus either commands (network device, sent with its write account) or action + params (agent) — fixed code computed it from the evidence; no AI
plan_hash SHA-256 over {v, device, finding {id, lines}, plan} (sorted-key compact JSON). The approval is bound to it (approved_hash); the agent task carries it.
proposed_by, approved_by, approved_at the two people (with two-person approval they differ)
window {start, end, planned_id} — the change window, also recorded as a planned change (source: fix)
state proposed → approved → running (network) or sent → applied (agent) → verified, or rolling_back → rolled_back, or failed / rejected / expired
history every step: {at, by, what, note} (by is a person, SafeAI, or agent:<id>)
integrity "ok" when the stored plan still matches plan_hash

verified means a new read no longer shows the finding: for a network device, Edge's own read after the change (not the command's return code); for a computer with the agent, the agent's next full report from its fixed collection scripts (not the agent's "done"). rolled_back means the read still showed it, or the device refused a command, and the rollback ran.

4. What Edge does not accept from outside

No API approves or runs a fix, approves a change request, changes settings, adds devices or credentials, or edits records. Those stay in the Edge console, under its sign-in, roles and audit log. A platform that wants to request a fix opens a ticket for a person; the person proposes and approves it in Edge. This keeps one place where a person approves the exact plan. The one thing that can be filed from outside is a change request from an AI agent you registered and allowed to ask (section 5): it is a request, people approve it in the console, and a person makes the change.

5. AI agents (an agent's own key)

For AI agents and automations you run. An administrator registers each one in the console (Approvals → AI agents) and gets its key (saa_…), shown once. The key reaches only this section's two interfaces, and only the devices named for that agent; a read token (section 1) is not an agent key and an agent key opens nothing else. Administrator guide, "AI agents", has the rules.

Every call carries Authorization: Bearer <the agent's key>. Both interfaces give the same answers through the same filter, share one allowance of calls a minute (60 unless changed), and write every call, answered or refused, to the same tamper-evident record. Requests are at most 64 KB.

5a. Plain HTTPS

https://<edge>/api/agent/v1/<path>, JSON answers.

Call Returns
GET whoami {id, name, kind, purpose, owner, limits: {all, clients, sites, devices}, may_request, devices: [names], key_expires, calls_per_min}
GET devices {"devices": [{name, vendor, site, address, read_ok, last_read}]} — the agent's devices only
GET findings {"findings": [{id, device, severity, title, why, suggest}]} on those devices
GET changes?since=<ISO time> {"changes": [...]} recorded on those devices, newest first, at most 500
GET changes/<id> one change with its lines and integrity; 404 for a change on a device outside the agent's limits, the same as for one that does not exist
GET incidents {"incidents": [...]} whose devices are all inside its limits
GET requests {"requests": [{id, title, device, state, label, start, end, requested_at, approvals_needed, approvals, prediction, prediction_summary}]} — the change requests this agent filed
POST requests files a change request; 201 with the request as above. Only an agent allowed to ask.
POST /api/agent/v1/requests
Authorization: Bearer saa_...
{"title": "OSPF timers on the Boston transit link", "device": "BR1-R",
 "lines": ["interface GigabitEthernet0/1", " ip ospf hello-interval 10"],
 "reason": "ticket 4411", "start": "2026-11-20T02:00:00Z", "minutes": 30}

201
{"id": "CR-1795011859313", "title": "OSPF timers on the Boston transit link", "device": "BR1-R", "state": "waiting",
 "label": "Waiting for approval", "approvals_needed": 1, "approvals": 0, "prediction": "breaks",
 "prediction_summary": ["..."], "start": "2026-11-20T02:00:00Z", "end": "2026-11-20T02:30:00Z", "requested_at": "..."}

title, device and lines are required. start is between now and 30 days from now (an hour from now if left out); minutes is 15, 30, 60, 120, 240 or 480 (60 if left out). The request is then an ordinary change request: SafeAI has attached its prediction, people approve it (never the agent's owner, who counts as the one asking), a person makes the change in the approved window, and SafeAI records and checks it. The agent changes nothing and cannot approve.

Errors are {"error": "<why>"}:

Status When
401 No key, a key SafeAI does not know, or an agent that is suspended, retired, expired, without a valid owner, or refused because AI agents are turned off. The message says which.
403 The agent may read only, or the device is outside what it may reach
400 A request SafeAI can't accept (the message says what is wrong)
404 Not something an agent can ask, or a record that is not among its devices
429 More calls than its allowance in a minute; Retry-After: 30

5b. MCP (Model Context Protocol)

POST https://<edge>/api/agent/mcp, one JSON-RPC 2.0 message per request, answered with one JSON object (never a stream).

  • Revision 2026-07-28: no handshake and no session. Each request carries MCP-Protocol-Version: 2026-07-28, Mcp-Method, and for tools/call Mcp-Name, and in params._meta the keys io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities. A header that is missing or differs from the body is refused (400, error -32020); a version SafeAI does not support is refused with the ones it does (400, -32022). Methods: server/discover, tools/list, tools/call. Any other method is 404 with -32601.
  • Revisions 2025-11-25, 2025-06-18 and 2025-03-26, for clients not yet updated: initialize is answered and no session id is issued; notifications are accepted with 202; then tools/list, tools/call and ping.
  • Tools only. No resources, prompts, sampling, elicitation, subscriptions or tasks; SafeAI never sends a request to the agent. GET and DELETE are 405. A batch (a JSON array) is refused. An Origin header, if sent, must be SafeAI's own address (403 otherwise).
Tool Arguments Same as
whoami none GET whoami
devices none GET devices
findings none GET findings
changes since (ISO time, optional) GET changes
change id GET changes/<id>
incidents none GET incidents
requests none GET requests
ask_for_change title, device, lines; optional reason, start, minutes POST requests. Listed only for an agent allowed to ask, and refused if another agent calls it.

A tool's answer is the same JSON as the plain call, as structuredContent and again as text (text only for revision 2025-03-26). A refusal the agent can act on (a device outside its limits, a request SafeAI won't accept) comes back as a tool result with isError: true and the same message the plain call gives. An unknown tool is JSON-RPC error -32602. A bad key is HTTP 401, and too many calls 429, as above.

A client configuration, in the form many agent tools take (the exact form depends on the tool):

{"mcpServers": {"safeai": {"type": "http", "url": "https://<edge>/api/agent/mcp",
                            "headers": {"Authorization": "Bearer <the agent's key>"}}}}

Checked with the official MCP client library for Python (mcp 2.3.0 in its automatic and legacy modes, and mcp 1.30.0) against a test server: listing the tools, calling them, a refused call and a filed request. Not yet checked with a customer's agent. If SafeAI uses a certificate your organisation issued, the agent's machine must trust it.

These pages are the documentation that ships inside SafeAI 2.9.85.1, the version you download. Something unclear or wrong? Tell us.