Search K
Appearance
Appearance
INFERENCE DEFEND
This article is meant for Inference Defend users.
ROLES AND PERMISSIONS
To complete the tasks described in this section, make sure you have the required permissions.
Any change you make to the organization settings, project, provider, or user configuration using our API, SDK, or the CalypsoAI Platform is saved in the audit log as a record you can view.
To get the audit logs, you need to call the cai.client.audit.get() method in your request. The cai.client.audit.get() method accepts multiple optional parameters you can include to refine your results.
In this scenario, we are going to get the audit logs, without including any optional parameters.
To get the audit logs:
Add your token value to the following sample:
from calypsoai import CalypsoAI
# Define the URL and token for CalypsoAI
CALYPSOAI_URL="https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN="ADD-YOUR-TOKEN-HERE"
# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
# Get the audit logs
auditLogs = cai.client.audit.get()
# Print the response
print(auditLogs.model_dump_json(indent=2))Run the script.
Analyze the response.
The following response sample is a simplified version of a successful request, focusing only on the main details relevant to this specific request.
{
"events": [
{
"createdAt": "2025-06-10T15:40:48.907940Z",
"id": "01975a80-538b-70de-be66-98f165aabbc4",
"type": "api-token-created",
"user": {
"id": "919ff136-9cfa-4f8a-b347-c0cde08aca7c",
"name": "Admin User",
"org": "org_4ZADaQrQhPOhXnhJ",
"permissions": [
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:use_custom_scanners"
]
}
}
]
}The response includes the following key parameters:
events: A list of the audit log events.events > type: The name of the event.events > user: Information about the user that triggered the event.{
"events": [
{
"createdAt": "2025-06-10T15:40:48.907940Z",
"data": null,
"id": "01975a80-538b-70de-be66-98f165aabbc4",
"tokenId": "01975a80-538b-700d-afa6-69b1b88f5c2a",
"type": "api-token-created",
"user": {
"admin": null,
"blocked": false,
"createdAt": "2025-06-06T15:50:01.022000Z",
"email": "user-admin@gmail.com",
"id": "919ff136-9cfa-4f8a-b347-c0cde08aca7c",
"lastInvitationSentAt": "2025-06-06T15:50:01.022000Z",
"name": "Admin User",
"org": "org_4ZADaQrQhPOhXnhJ",
"permissions": [
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:use_custom_scanners",
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:projects",
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:providers",
"organization:org_4ZADaQrQhPOhXnhJ:org_owner",
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:use_project",
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:use_cai_scanners",
"project:01975a7d-ba51-70a9-97c1-8158db2a8957:roles",
"organization:org_4ZADaQrQhPOhXnhJ:org_member"
],
"roleIds": [
"019745ef-748a-7087-a889-064bdcf94ce8",
"01975a7d-bad4-706d-b206-bbf079a1f689",
"01975a7d-babc-70e2-9a17-4fbf673d8d78"
],
"roles": [
"basic",
"owner",
"super_admin"
],
"social": false,
"teams": [],
"verified": false
}
}
],
"next": "eyJyb3ciOjEwLCJsaW1pdCI6MTAsInR5cGUiOiJyb3cifQ==",
"prev": null
}DEFAULT RESPONSE
Our sample Python request uses the cursor attribute to return a paginated list of actions, starting from the most recent action. By default, there is a limit of 10 results per page, and only the actions done by the owner of the token are shown.
You can use the next and prev cursor properties to view actions on specific pages.
You may want to refine your search to get the logs for actions that match your specific search requirements.
In this scenario, we are going to get the audit logs for the most recently created API tokens, with a limit of 1000 results shown per page.
To get the audit logs:
Add your token value to the following sample:
from calypsoai import CalypsoAI
from calypsoai.datatypes import AuditEventType
# Define the URL and token for CalypsoAI
CALYPSOAI_URL="https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN="ADD-YOUR-TOKEN-HERE"
# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
# Get the audit logs
auditLogs = cai.client.audit.get(limit=1000, type_=AuditEventType.API_TOKEN_CREATED)
# Print the response
print(auditLogs.model_dump_json(indent=2))Run the script.
Analyze the response.
Our sample Python request produces a paginated list very similar to the sample JSON response in Get the audit logs, showing the actions that match your search criteria.