Security
intermediateAudit logs, session management, and session revocation endpoints for account security.
Audit log
/v1/security/audit-logRetrieve the audit log for your account or organization. Shows all security-relevant actions.
org_idstringFilter by organization. If omitted, shows personal account actions.
actionstringFilter by action type (e.g., login, key_created, member_removed).
fromstringISO 8601 start date for the log range.
tostringISO 8601 end date for the log range.
pageintegerDefault: 1Page number.
per_pageintegerDefault: 50Items per page (max 100).
{
"data": [
{
"id": "audit_abc123",
"action": "login",
"actor": {
"id": "usr_abc123",
"email": "[email protected]",
"type": "user"
},
"details": {
"method": "password",
"mfa_used": true,
"ip": "203.0.113.42",
"user_agent": "Mozilla/5.0..."
},
"timestamp": "2026-01-20T14:30:00Z",
"success": true
},
{
"id": "audit_def456",
"action": "key_created",
"actor": {
"id": "usr_abc123",
"email": "[email protected]",
"type": "user"
},
"details": {
"key_id": "key_new789",
"key_name": "Staging Environment",
"scopes": [
"memory:read",
"memory:write"
]
},
"timestamp": "2026-01-20T14:35:00Z",
"success": true
},
{
"id": "audit_ghi789",
"action": "login_failed",
"actor": {
"id": null,
"email": "[email protected]",
"type": "unknown"
},
"details": {
"reason": "invalid_password",
"ip": "198.51.100.23",
"attempts": 3
},
"timestamp": "2026-01-20T13:00:00Z",
"success": false
}
],
"pagination": {
"page": 1,
"per_page": 50,
"total": 234,
"total_pages": 5
}
}import os
from engramma_cloud import EngrammaClient
client = EngrammaClient(api_key=os.environ["ENGRAMMA_API_KEY"])
# Get recent security events
audit = client.security.audit_log(
org_id="org_abc123",
from_date="2026-01-20"
)
for entry in audit:
status = "OK" if entry.success else "FAILED"
print(f"[{status}] {entry.action} by {entry.actor.email} at {entry.timestamp}")Audit action types
| Action | Description |
|---|---|
login | Successful login |
login_failed | Failed login attempt |
logout | User logged out |
mfa_enabled | MFA was enabled |
mfa_disabled | MFA was disabled |
password_changed | Password was changed |
password_reset | Password was reset via email |
key_created | API key created |
key_revoked | API key revoked |
key_rotated | API key rotated |
member_invited | Member invitation sent |
member_joined | Member accepted invitation |
member_removed | Member removed from org |
role_changed | Member role changed |
plan_changed | Subscription plan changed |
data_exported | GDPR data export requested |
erasure_requested | GDPR erasure requested |
List sessions
/v1/security/sessionsList all active sessions for your account.
{
"sessions": [
{
"id": "sess_abc123",
"current": true,
"ip": "203.0.113.42",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
"location": "Paris, France",
"created_at": "2026-01-20T14:30:00Z",
"last_active_at": "2026-01-20T15:45:00Z"
},
{
"id": "sess_def456",
"current": false,
"ip": "198.51.100.23",
"user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0)",
"location": "London, UK",
"created_at": "2026-01-18T09:00:00Z",
"last_active_at": "2026-01-19T22:00:00Z"
}
]
}sessions = client.security.sessions()
for s in sessions:
current = " (current)" if s.current else ""
print(f"{s.location} — {s.user_agent[:40]}...{current}")
print(f" Last active: {s.last_active_at}")Revoke session
/v1/security/sessions/{session_id}Revoke a specific session. The session's tokens are immediately invalidated.
session_idstringrequiredSession ID to revoke (path parameter).
{
"revoked": true,
"session_id": "sess_def456",
"revoked_at": "2026-01-20T15:00:00Z"
}# Revoke a suspicious session
client.security.revoke_session(session_id="sess_def456")
print("Session revoked")If you notice an unfamiliar session, revoke it immediately and change your password. Enable MFA if not already active.
Security recommendations
-
Enable MFA — Protects against password compromise. See Authentication endpoints.
-
Review sessions regularly — Revoke any session you don't recognize.
-
Monitor the audit log — Watch for failed login attempts or unexpected key creations.
-
Rotate API keys — See API Keys reference for rotation with grace period.
-
Use scoped keys — Give each key only the permissions it needs.
Next steps
- Authentication — MFA setup and management
- Organizations — API key management
- API Key Best Practices — Security-focused key management