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:
| Field | Description |
|---|---|
protection_group | Hash ID of the protection group. |
event_type | authentication, authorization, transaction, account, session or custom. |
user.id | User id in your application (login, e-mail, internal id), always sent the same way. |
client.ip | IP 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:
| Field | Description |
|---|---|
schema_version | "1". |
event_name | Free, stable name that refines the type (login, pix_sent, sign_up). |
client.user_agent | The browser User-Agent header. |
client.accept_language | The browser Accept-Language header. |
action.result | success, failure or unknown. Mark failed operations (wrong password) as failure. |
params | Your 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"]
}
| Field | Description |
|---|---|
event_id | Unique id of the event. Log it: it links your logs to the panel. |
decision | allow (continue), notify (ask for an extra check or just record) or block (stop the operation). |
risk | 0 to 100. The thresholds are set per protection group. |
decided_by.kind | risk, policy (a fixed rule of your team) or session (a compromised session). |
reasons | Codes of the signals that raised the risk (user history, location, network, browser, session). May be empty. |
Errors
Errors return {"detail": "<message>"}.
| Code | Meaning | What to do |
|---|---|---|
400 | Invalid body; detail says which rule failed. | Fix the body; do not retry as is. |
401 | Token missing, wrong, disabled or expired. | Check the token. |
404 | Protection group not found in this organization. | Check the Hash ID. |
413 | Body over 64 KiB. | Reduce params. |
429 | Too many requests. | Wait Retry-After seconds. |
503 | Temporarily 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.idthe same way (Mariaandmariaare different users unless the group is configured otherwise). - Record
event_idanddecisionin your logs.