Integration guides
Patterns for sending sign-in events from your stack, reading incidents into your tools and exporting security events to your SIEM.
Patterns, not plugins: each uses only the public endpoints. Adapt the names to your stack. Every sender here runs on your server, holds the key in a secret store, and sends asynchronously so NexGuard is never in the path of a person signing in.
From your identity system
Most identity systems can call a hook or publish an event stream for sign-ins, one-time-code steps and password resets. Relay those through a small backend service of yours to POST /api/v1/events/batch; do not call NexGuard from the identity system's browser pages.
# Your identity system's own event names, mapped once, in one place.
TYPE_FOR = {
"login_ok": "LOGIN_SUCCESS",
"login_error": "LOGIN_FAILED",
"otp_sent": "MFA_CHALLENGE",
"otp_ok": "MFA_SUCCESS",
"otp_error": "MFA_FAILED",
"reset_requested": "PASSWORD_RESET_REQUEST",
"logout": "LOGOUT",
}
def to_event(raw: dict) -> Event | None:
event_type = TYPE_FOR.get(raw["type"])
if event_type is None:
return None # not security telemetry
return Event(
event_id=f"idp-{raw['id']}", # the identity system's own id: stable on retry
event_type=event_type,
source="identity",
subject_id=raw["user_id"], # your stable user id, not an email
occurred_at=parse_time(raw["time"]), # timezone-aware
payload={"ip": raw.get("ip"), "user_agent": raw.get("user_agent"),
"session_id": raw.get("session_id")},
)- Use the identity system's own event id in
event_id, so a redelivered hook is a duplicate, not a second sign-in. - Use your stable internal user id as the subject, not an email address. Put email or phone in the payload only if detection should compare them; they are hashed before detection sees them.
- Never forward the raw hook body: identity events often carry tokens and secrets, which are forbidden.
From your web application or API backend
Emit at the point where your code already knows the outcome — the sign-in handler, the registration handler, the payment or withdrawal handler — after it has answered the person.
# After the sign-in decision has been made and answered, never before it.
def on_sign_in(request, user, succeeded: bool) -> None:
outbox.put(Event( # a bounded queue a worker drains
event_id=f"signin-{request.id}",
event_type=EventType.LOGIN_SUCCESS if succeeded else EventType.LOGIN_FAILED,
source="web",
subject_id=str(user.id) if user else None, # unknown username: no subject
payload={"ip": request.client_ip, "user_agent": request.user_agent,
"device_id": request.cookies.get("device")},
))
# The worker:
def drain(outbox) -> None:
batch = outbox.take(up_to=100)
if batch:
client.send_batch(batch) # retry with backoff on 429/503- Good first events:
LOGIN_SUCCESS,LOGIN_FAILED,ACCOUNT_CREATED,PASSWORD_RESET_REQUEST,EMAIL_CHANGED,DEVICE_ADDED. - From an API gateway:
API_AUTH_FAILED,API_RATE_LIMITED,API_ACCESS_DENIED. - Include
ip,user_agentand adevice_idorsession_idwhere you have them: they are what lets detection relate events to each other. - Batch up to 100 events per request. Sending is limited in events, not requests, so batching saves round trips rather than allowance.
Reading incidents into your own tools
To open a ticket or post to a chat channel, run a poller on your server with a key carrying incidents:read, or receive a notification webhook for high-severity incidents and use the poller as the backstop. For a SIEM, use SIEM export instead.
// Runs every minute on your server. Turns NexGuard incidents into tickets.
const BASE = "https://securiteagi.com";
const headers = { "X-API-Key": process.env.NEXGUARD_API_KEY };
async function syncIncidents(store, tickets) {
const since = await store.get("last_activity_at"); // ISO string, or null on first run
let newest = since;
let cursor = null;
pages: do {
const url = new URL(`${BASE}/api/v1/public/incidents`);
url.searchParams.set("limit", "50");
if (cursor) url.searchParams.set("cursor", cursor);
const response = await fetch(url, { headers });
if (!response.ok) return; // keep "since"; try again next minute
const { incidents, page } = await response.json();
for (const incident of incidents) {
// Most recent activity first: stop at what the last pass already saw.
if (since && incident.last_activity_at <= since) break pages;
if (!newest || incident.last_activity_at > newest) newest = incident.last_activity_at;
await tickets.upsert(incident.incident_id, { // keyed by id: idempotent
title: incident.title,
severity: incident.severity, // a word: carry it, not a colour
status: incident.status,
});
}
cursor = page.next_cursor;
} while (cursor);
await store.set("last_activity_at", newest);
}GET /api/v1/public/incidentsis ordered by most recent activity, so a poller can stop as soon as it reaches activity it has already seen. Store the newestlast_activity_atafter a successful pass.- Key your tickets by
incident_idand upsert, so a reopened or updated incident updates its ticket instead of opening another. - Fetch
GET /api/v1/public/incidents/{incident_id}for the timeline of findings when the ticket needs the detail. - Once a minute is well inside the default read limit of 120 requests a minute, even with a page or two of detail calls.
Into your SIEM
NexGuard can push its security events — alerts, incidents and response actions, and optionally your own staff's access audit — to the SIEM your SOC already watches. An administrator sets this up in the console under Integrations → SIEM export; nothing has to run on your side except the SIEM itself. If you would rather collect than receive, the same events can be pulled (see pulling instead).
| Transport | Formats | Endpoint and credential |
|---|---|---|
| Syslog over TLS (recommended) | CEF, LEEF, RFC 5424 syslog, JSON | host:port (6514 by default). Optional private CA certificate, and a client certificate and key for mutual TLS. |
| Syslog over TCP or UDP | CEF, LEEF, RFC 5424 syslog, JSON | host:port. Unencrypted: refused unless an administrator explicitly allows it for that destination. |
| Splunk HTTP Event Collector | JSON, CEF, LEEF | The HEC base URL; /services/collector/event is added if omitted. HEC token; optional index, sourcetype and source. |
| Elasticsearch bulk API | JSON | The cluster URL and an index. An API key, or a username and password. |
| Microsoft Sentinel (Logs Ingestion API) | JSON | The data collection endpoint's ingestion URL; the Entra tenant id, application (client) id and client secret; the data collection rule's immutable id and stream name. |
| HTTPS JSON, signed | JSON | Any https URL your collector owns. Every request is signed with an HMAC secret shown once when the destination is saved — the same scheme as webhooks. |
A signed HTTPS request carries X-NexGuard-Timestamp, X-NexGuard-Nonce and X-NexGuard-Signature, and an Idempotency-Key that is the same when the same batch is retried. Its body is { "schema_version": 1, "events": [ … ] }.
JSON is the OCSF Detection Finding shape. Credentials are write-only: they are stored sealed and never shown again, to you or to us; the console shows only the last four characters.
The same event in each format
Exactly what the formatter writes for one alert. Every format carries the event's id, so your SIEM can recognise a repeat:
- CEF —
externalId - LEEF —
externalId - RFC 5424 syslog — the structured-data parameter
eventId - JSON —
metadata.uid
CEF:0|NexGuard|NexGuard|1.0|alert.opened|Alert opened|8|rt=1793439000000 start=1793439000000 externalId=6f1c2a52-3b7e-4d0a-9a51-1e2f3c4d5e6f cat=alert act=alert.opened outcome=open cs1Label=tenantId cs1=0b7d6c1e-8f4a-4f3e-9c2d-7a6b5c4d3e2f cs2Label=incidentId cs2=1d2c3b4a-5f6e-4d7c-8b9a-0f1e2d3c4b5a cs3Label=subjectId cs3=alert:9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d cs4Label=ruleId cs4=impossible_travel cs5Label=entityHashes cs5=3f0caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa cs6Label=schemaVersion cs6=1 msg=Sign-in from two countries within an hourLEEF:2.0|NexGuard|NexGuard|1.0|alert.opened|^|devTime=2026-10-31T09:30:00.000Z^devTimeFormat=yyyy-MM-dd'T'HH:mm:ss.SSSX^cat=alert^sev=8^externalId=6f1c2a52-3b7e-4d0a-9a51-1e2f3c4d5e6f^eventType=alert.opened^outcome=open^tenantId=0b7d6c1e-8f4a-4f3e-9c2d-7a6b5c4d3e2f^incidentId=1d2c3b4a-5f6e-4d7c-8b9a-0f1e2d3c4b5a^subjectId=alert:9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d^ruleId=impossible_travel^entityHashes=3f0caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^msg=Sign-in from two countries within an hour^schemaVersion=1<131>1 2026-10-31T09:30:00.000Z - nexguard - alert.opened [nexguard@32473 eventId="6f1c2a52-3b7e-4d0a-9a51-1e2f3c4d5e6f" eventType="alert.opened" category="alert" severity="high" tenantId="0b7d6c1e-8f4a-4f3e-9c2d-7a6b5c4d3e2f" incidentId="1d2c3b4a-5f6e-4d7c-8b9a-0f1e2d3c4b5a" subjectKind="alert" subjectId="9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d" ruleId="impossible_travel" outcome="open" entityHash="3f0caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" schemaVersion="1"] <BOM>Alert opened: Sign-in from two countries within an hour<BOM> stands for the UTF-8 byte order mark (bytes EF BB BF) that RFC 5424 places before a UTF-8 message. It is invisible, so it is written out here; on the wire it is the three bytes.
{"activity_id":1,"activity_name":"Create","category_name":"Findings","category_uid":2,"class_name":"Detection Finding","class_uid":2004,"finding_info":{"title":"Sign-in from two countries within an hour","types":["impossible_travel"],"uid":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"},"message":"Alert opened","metadata":{"correlation_uid":"1d2c3b4a-5f6e-4d7c-8b9a-0f1e2d3c4b5a","event_code":"alert.opened","log_name":"alert","logged_time":1793439000000,"product":{"name":"NexGuard","vendor_name":"NexGuard","version":"1.0"},"tenant_uid":"0b7d6c1e-8f4a-4f3e-9c2d-7a6b5c4d3e2f","uid":"6f1c2a52-3b7e-4d0a-9a51-1e2f3c4d5e6f","version":"1.3.0"},"observables":[{"name":"entity_hash","type":"Other","type_id":99,"value":"3f0caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],"severity":"High","severity_id":4,"status":"open","time":1793439000000,"time_dt":"2026-10-31T09:30:00.000Z","type_uid":200401,"unmapped":{"nexguard":{"entity_kind":"account","rule_id":"impossible_travel","schema_version":1,"status":"open","subject_kind":"alert","title":"Sign-in from two countries within an hour"}}}{
"activity_id": 1,
"activity_name": "Create",
"category_name": "Findings",
"category_uid": 2,
"class_name": "Detection Finding",
"class_uid": 2004,
"finding_info": {
"title": "Sign-in from two countries within an hour",
"types": [
"impossible_travel"
],
"uid": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"
},
"message": "Alert opened",
"metadata": {
"correlation_uid": "1d2c3b4a-5f6e-4d7c-8b9a-0f1e2d3c4b5a",
"event_code": "alert.opened",
"log_name": "alert",
"logged_time": 1793439000000,
"product": {
"name": "NexGuard",
"vendor_name": "NexGuard",
"version": "1.0"
},
"tenant_uid": "0b7d6c1e-8f4a-4f3e-9c2d-7a6b5c4d3e2f",
"uid": "6f1c2a52-3b7e-4d0a-9a51-1e2f3c4d5e6f",
"version": "1.3.0"
},
"observables": [
{
"name": "entity_hash",
"type": "Other",
"type_id": 99,
"value": "3f0caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
],
"severity": "High",
"severity_id": 4,
"status": "open",
"time": 1793439000000,
"time_dt": "2026-10-31T09:30:00.000Z",
"type_uid": 200401,
"unmapped": {
"nexguard": {
"entity_kind": "account",
"rule_id": "impossible_travel",
"schema_version": 1,
"status": "open",
"subject_kind": "alert",
"title": "Sign-in from two countries within an hour"
}
}
}Delivery: at least once
- At least once, not exactly once. An event can arrive twice — after a timeout whose request did in fact land, for instance. De-duplicate on the event id above.
- Retried with backoff. A destination that cannot be reached, or answers 408, 425, 429, 500, 502, 503 or 504, is tried again later, up to twelve attempts. Any other refusal (a wrong token, an index that does not exist) is a configuration problem: retrying cannot fix it, so the event goes straight to the dead letter and the reason is shown on the destination.
- A visible dead letter. Events still undelivered after repeated attempts are set aside, counted on the destination, and listed in the console. Fixing the destination queues them again automatically; an administrator can also requeue them by hand.
- Health in words. Each destination is delivering, never delivered, failing (with the reason) or switched off, with the backlog and the age of the oldest waiting event. A destination nothing has reached is never shown as healthy.
- Test before you rely on it. Send a test event delivers one recognisable event of type
test.connectionand shows what the destination answered.
Where NexGuard will connect
Destinations must resolve to public addresses. Private, loopback and link-local addresses are refused — the hosted service will not be pointed into somebody's internal network — unless the operator of your deployment has allowed a specific private network, as an on-premises installation inside your own estate would. Allow the hosted service's outbound addresses through your firewall, and prefer syslog over TLS or HTTPS: plain TCP and UDP syslog carry your security events in the clear.
Pulling instead
A key with the security_events:read scope reads the same events from GET /api/v1/public/security-events: alerts, incidents and response actions (the access audit is not in this feed). Filter with category (alert, incident or response) and page with limit and cursor.
curl -sS "https://securiteagi.com/api/v1/public/security-events?limit=100" \
-H "X-API-Key: $NEXGUARD_API_KEY"{
"events": [
{
"event_id": "6f1c2a52-3b7e-4d0a-9a51-1e2f3c4d5e6f",
"schema_version": 1,
"category": "alert",
"event_type": "alert.opened",
"severity": "high",
"occurred_at": "2026-10-31T09:30:00Z",
"recorded_at": "2026-10-31T09:30:00Z",
"subject_kind": "alert",
"subject_id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
"incident_id": "1d2c3b4a-5f6e-4d7c-8b9a-0f1e2d3c4b5a",
"entity_hashes": ["3f0c…"],
"attributes": { "…": "…" }
}
],
"page": { "next_cursor": "…", "has_more": false }
}// Runs every minute on your collector. Oldest first: store the cursor, ask again.
const BASE = "https://securiteagi.com";
const headers = { "X-API-Key": process.env.NEXGUARD_API_KEY };
async function collect(store, siem) {
let cursor = await store.get("security_events_cursor"); // null on first run
for (;;) {
const url = new URL(`${BASE}/api/v1/public/security-events`);
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("cursor", cursor);
const response = await fetch(url, { headers });
if (!response.ok) return; // keep the cursor; try again next minute
const { events, page } = await response.json();
for (const event of events) {
await siem.upsert(event.event_id, event); // keyed by event_id: a repeat is a no-op
}
cursor = page.next_cursor; // returned even when nothing is newer
await store.set("security_events_cursor", cursor);
if (!page.has_more) return;
}
}- Oldest first, unlike the other lists: this one is tailed. Events appear about ten seconds after they are recorded, so that oldest-first really means it.
next_cursoris returned even when there is nothing newer, pointing at the last event, so a collector keeps polling from where it is rather than starting over.- Each event is the model every push format is mapped from, so a pulled event and a pushed one share the same
event_id.
Reporting and dashboards
A daily job with security_score:read can record GET /api/v1/public/security-score. Keep movement_reasons beside the number — the number alone says nothing about what to do — and record "scored": false as "not yet scored", never as zero.
Before you go live
GET /api/v1/public/identityanswers with the scopes you expect, and nothing more.- The Python SDK's doctor passes from the host that will send.
- Events appear in Live activity in the console, and the integration health panel on Developers & API reports no refusals or dropped fields.
- Your sender survives NexGuard being unreachable: requests time out, the queue is bounded, and sign-in keeps working.