Skip to content

Security

Audit logs

Appwrite provides audit logs to help detect anomalies and investigate security incidents.

3 min read

Raw

All Appwrite products, like Authentication, Databases, Storage, Functions, and Messaging, provide detailed audit logs. Audit logs are important in detecting and responding to security incidents. Through audit logs, you can detect incidents through anomalous activities, trace the source of security incidents, and understand the scope of users affected so you can respond more quickly and effectively.

Access audit logs

You can access audit logs for different products under the Activity tab where applicable. Logs are available for tables, rows, and individual users.

Project Activity tab with reasons
Project Activity tab with reasons

Format

Audit log entries under the Activity tab have the following structure. Each entry describes an event.

ColumnDescription
EventThe name of the event.
ActorThe user, API key, or other actor that performed the event.
TypeThe kind of actor, such as a user or an API key. Events sent through the MCP server or the CLI are also marked Via MCP or Via CLI.
ResourceThe resource the event changed, such as a table, row, or function.
ReasonWhy the request was made, when the client sent one. See Record a reason.
IP addressThe IP address the request came from.
CountryThe country the request came from, based on its IP address.
TimeThe date and time of the event.

Select an event to open its details, including the full reason, the actor, and the device and location the request came from.

Record a reason

Activity event details with a reason
Activity event details with a reason

Send the X-Appwrite-Reason header with an API request to record why it was made. The reason appears in the Reason column of the Activity tab, next to the event it explains, and in the event's details, so you can review changes made by AI agents, scripts, and teammates later.

HTTP
DELETE /v1/functions/checkout-legacy HTTP/1.1
X-Appwrite-Project: <PROJECT_ID>
X-Appwrite-Key: <API_KEY>
X-Appwrite-Reason: Moved to SSR endpoint /api/checkout in storefront site

A reason is one line of text of up to 256 characters. The header value is percent-decoded, so send it encoded with encodeURIComponent (or your language's equivalent). That covers any language, and a literal % as %25. Plain ASCII text without % can be sent as it is.

A request fails with general_argument_invalid before it runs when its reason is longer, isn't valid UTF-8, or contains control characters such as line breaks, tabs or terminal escapes, or Unicode bidirectional override characters.

From the CLI

Pass --reason to any Appwrite CLI command, or set the APPWRITE_REASON environment variable for a whole shell session or CI job. The CLI encodes the reason and sends it with every request the command makes.

Bash
appwrite push functions --reason "Release 2.4: move checkout to the storefront site"

From a server SDK

Server SDKs don't have a dedicated method for reasons. Add the header to the client with addHeader, and every request the client makes carries it. Use a separate client for each reason, so a reason doesn't stick to unrelated requests.

const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>')
.setKey('<API_KEY>')
.addHeader('X-Appwrite-Reason', encodeURIComponent('Remove test users created during the sign-up load test'));
const users = new sdk.Users(client);
await users.delete({ userId: '<USER_ID>' });

From the MCP server

The Appwrite MCP server asks the AI agent for a reason with every change it makes and records it on the request. Changes an agent makes show up in Activity with the reason the agent gave.

Retention

GDPR data retention rules require any personal data that is collected or processed to be kept only for as long as data are required to achieve the purpose for which the information was collected. For this reason, audit logs are retained for only 7 days for Pro organizations and 1 hour for Free organizations.

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.