Skip to main content

Events API

🔗 Events API​

POST {API_URL}/af/v1/events evaluates one business event and returns the decision. Call it from your backend, never from the browser: it uses the organization token.

{API_URL} is https://api.guardiankey.io in the GuardianKey cloud, or the address of your on-premises installation.

Before you start​

In the GDN panel you need:

  • a protection group (usually one per application or environment) — its Hash ID goes in every event;
  • an organization token — keep it on the server only.

Authentication​

Authorization: Bearer <organization token>
Content-Type: application/json

A missing, wrong, revoked or expired token always gets the same 401.


Request​

Required fields:

FieldDescription
protection_groupHash ID of the protection group.
event_typeauthentication, authorization, transaction, account, session or custom.
user.idUser id in your application (login, e-mail, internal id), always sent the same way.
client.ipIP of the end user as seen by your application. Behind a proxy or CDN, read it from the header your trusted infrastructure sets.

Recommended fields:

FieldDescription
schema_version"1".
event_nameFree, stable name that refines the type (login, pix_sent, sign_up).
client.user_agentThe browser User-Agent header.
client.accept_languageThe browser Accept-Language header.
action.resultsuccess, failure or unknown. Mark failed operations (wrong password) as failure.
paramsYour business data, e.g. {"channel": "app", "amount": 1530.75} — up to 50 keys. Never send passwords, card numbers, security codes or tokens.

Unknown fields are ignored. The body is limited to 64 KiB.

{
"schema_version": "1",
"protection_group": "<group Hash ID>",
"event_type": "transaction",
"event_name": "pix_sent",
"user": { "id": "[email protected]" },
"client": {
"ip": "203.0.113.25",
"user_agent": "Mozilla/5.0 ...",
"accept_language": "pt-BR,pt;q=0.9"
},
"action": { "result": "success" },
"params": { "channel": "app", "amount": 1530.75 }
}

Response​

200 OK:

{
"event_id": "019a1c2e-7b5d-7c3a-9f10-2b6e4d8a1c55",
"decision": "notify",
"risk": 47,
"decided_by": { "kind": "risk" },
"reasons": ["atypical_country", "atypical_hour"]
}
FieldDescription
event_idUnique id of the event. Log it: it links your logs to the panel.
decisionallow (continue), notify (ask for an extra check or just record) or block (stop the operation).
risk0 to 100. The thresholds are set per protection group.
decided_by.kindrisk, policy (a fixed rule of your team) or session (a compromised session).
reasonsCodes of the signals that raised the risk (user history, location, network, browser, session). May be empty.

Errors​

Errors return {"detail": "<message>"}.

CodeMeaningWhat to do
400Invalid body; detail says which rule failed.Fix the body; do not retry as is.
401Token missing, wrong, disabled or expired.Check the token.
404Protection group not found in this organization.Check the Hash ID.
413Body over 64 KiB.Reduce params.
429Too many requests.Wait Retry-After seconds.
503Temporarily unavailable.Apply your fallback (below).

If the API does not answer​

Use a short timeout (2–3 s) and decide the fallback beforehand:

  • fail-open (the operation continues unevaluated) — common for login and navigation;
  • fail-closed (block or ask for an extra check) — recommended for high-value financial operations.

Good practices​

  • Send the event before completing the operation, so you can still block it.
  • Always send user.id the same way (Maria and maria are different users unless the group is configured otherwise).
  • Record event_id and decision in your logs.