Skip to the documentation
All documentation pages ↓

Sending events

The event envelope, event types, batches, idempotency and fields that must never be sent.

Two endpoints

  • POST /api/v1/events — one event, as the request body.
  • POST /api/v1/events/batch — between 1 and 100 events, as { "events": [ … ] }. A batch is all or nothing: if one event is refused, none is stored.

Both need a key created with send events, both answer 202 Accepted once the events are stored and queued for detection, and both may need a signature if the key enforces signing. A request body may be at most 2 MB.

The event envelope

Fields of one event. Any other field is refused.
FieldRequiredRules
schema_versionYesExactly "1.0". Stated, not defaulted, so a future version is never misread as this one.
event_idYes1–128 characters, chosen by you, unique within your organisation. The idempotency key — see below.
event_typeYesA canonical type such as LOGIN_FAILED, or your own dotted lowercase name such as auth.login.failed (two to five segments).
occurred_atYesISO 8601 with a timezone offset. Not more than 5 minutes in the future and not more than 48 hours old.
sourceYes1–64 characters naming the sending system, e.g. portal-web.
subjectNoWho or what it is about: type (lowercase, e.g. user) and id (1–255 characters). Hashed per organisation before detection.
payloadNoA JSON object of at most 64 KB.

There is no tenant field. The organisation comes from the key, so a sender cannot write into anybody else's data.

Batch
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
curl -sS -X POST "https://securiteagi.com/api/v1/events/batch" \
  -H "X-API-Key: $NEXGUARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "events": [
    { "schema_version": "1.0", "event_id": "login-8f21", "event_type": "LOGIN_FAILED",
      "occurred_at": "'"$NOW"'", "source": "portal-web",
      "subject": { "type": "user", "id": "user-42" },
      "payload": { "ip": "203.0.113.7", "user_agent": "Mozilla/5.0" } },
    { "schema_version": "1.0", "event_id": "login-8f22", "event_type": "LOGIN_SUCCESS",
      "occurred_at": "'"$NOW"'", "source": "portal-web",
      "subject": { "type": "user", "id": "user-42" },
      "payload": { "ip": "203.0.113.7", "session_id": "s-77" } }
  ] }'

Event types

Send a canonical type directly, or your own dotted name if it is one of the aliases NexGuard maps — for example auth.login.succeeded, user.signin.ok and login.success all become LOGIN_SUCCESS.

A type that matches neither is accepted at the door (the response is still 202) and then quarantined rather than guessed: it is kept, and detection does not see it. Using the canonical names avoids that entirely.

Canonical event types
FamilyTypes
AuthenticationLOGIN_ATTEMPT, LOGIN_SUCCESS, LOGIN_FAILED, LOGOUT, MFA_CHALLENGE, MFA_SUCCESS, MFA_FAILED, PASSWORD_RESET_REQUEST, PASSWORD_CHANGED, SESSION_CREATED, SESSION_REVOKED
AccountACCOUNT_CREATED, ACCOUNT_UPDATED, ACCOUNT_FLAGGED, EMAIL_CHANGED, PHONE_CHANGED, DEVICE_ADDED
Identity verificationKYC_STARTED, KYC_SUBMITTED, KYC_APPROVED, KYC_FAILED, KYC_RETRY
APIAPI_REQUEST, API_AUTH_FAILED, API_RATE_LIMITED, API_ACCESS_DENIED, API_ERROR
TransactionsTRANSACTION_CREATED, TRANSACTION_FAILED, TRANSACTION_COMPLETED, WITHDRAWAL_REQUESTED, WITHDRAWAL_REVIEWED
SecurityWAF_EVENT, SERVER_SECURITY_EVENT, SUSPICIOUS_REQUEST, CUSTOMER_MANUAL_FLAG

Payload keys detection reads

The payload is free-form, but these keys are recognised and turned into fields detection can compare across events:

  • IP address: ip, ip_address, client_ip, source_ip, remote_addr
  • Device: device_id, device_fingerprint, fingerprint, deviceId (hashed)
  • Session: session_id, sessionId, session, sid (hashed)
  • Email: email, email_address, user_email (hashed; only the domain is kept readable)
  • Phone: phone, phone_number, msisdn (hashed; only the country prefix is kept)
  • User agent: user_agent, userAgent, ua

Hashes are salted per organisation: the same address in two organisations produces two unrelated values.

Fields that must never be sent

Passwords, secrets, tokens, card data, bank and national identifiers and identity-document images have no place in security telemetry. Any payload key containing one of these, in any letter case and at any depth, is treated as forbidden:

password, passwd, secret, token, card_number, cardnumber, pan, cvv, cvc, iban, ssn, passport_image, selfie, national_id, private_key

  • The Python SDK refuses to send them: it raises ForbiddenField before anything leaves your server.
  • The API does not refuse them: the event is accepted and the raw event is kept as you sent it, as the record of what you reported. The forbidden keys are removed before detection or anything downstream reads the event, and the console reports them by name as dropped fields so you can stop sending them.

Idempotency and retries

Sending is idempotent on event_id within your organisation. Re-sending an event that was already stored stores nothing and raises nothing a second time; the response marks it:

Response to a repeat
{ "accepted": 0, "duplicates": 1, "rejected": 0,
  "events": [ { "event_id": "login-8f21", "duplicate": true, "stored_id": null } ] }

That makes the dangerous case safe: a request that succeeded but whose response you never received. Send it again. Derive event_id from the event itself (your own record id, or a hash of its contents), never a fresh random value per attempt — a new id on a retry is a new event.

Sending is limited per key, by default to 6,000 events a minute: a 100-event batch costs 100. See Errors, limits and retries.

Why an event is refused

  • 422 Request validation failed — the envelope broke a rule above (an unknown field, a missing timezone, a payload over 64 KB, more than 100 events).
  • 422 occurred_at is in the future or occurred_at is too old — checked for every event in a batch before any is stored. The console keeps a record of the refusal.
  • 403 — the key was not issued for sending events.
  • 401 — no key, an unusable key, or a refused signature.
  • 413 — the request body is over 2 MB.

We use only the cookies needed to sign you in securely and to remember your language and display choices. No analytics, advertising or third-party cookies.

Cookie policy