Creates a new Audit Log schema used to validate the payload of incoming Audit Log Events. If the action does not exist, it will also be created.
curl --request POST \ --url https://api.workos.com/audit_logs/actions/user.viewed_invoice/schemas \ --header "Authorization: Bearer sk_example_123456789" \ --header "Content-Type: application/json" \ -d @- <<BODY { "actor": { "metadata": { "type": "object", "properties": { "role": { "type": "string" } } } }, "targets": [ { "type": "invoice", "metadata": { "type": "object", "properties": { "status": { "type": "string" } } } } ], "metadata": { "type": "object", "properties": { "transactionId": { "type": "string" } } } } BODY
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const schema = await workos.auditLogs.createSchema({ action: 'user.viewed_invoice', actor: { metadata: { role: 'string', }, }, targets: [ { type: 'user', metadata: { status: 'string', }, }, ], metadata: { invoice_id: 'string', }, });
POST/audit_logs /actions /:actionName /schemasParameters Returns Get a list of all schemas for the Audit Logs action identified by :name.
curl "https://api.workos.com/audit_logs/actions/user.logged_in/schemas" \ --header "Authorization: Bearer sk_example_123456789"
{ "object": "list", "data": [ { "object": "audit_log_schema", "version": 1, "actor": { "metadata": { "type": "object", "properties": { "role": { "type": "string" } } } }, "targets": [ { "type": "invoice", "metadata": { "type": "object", "properties": { "cost": { "type": "number" } } } } ], "metadata": { "type": "object", "properties": { "transactionId": { "type": "string" } } }, "created_at": "2026-01-15T12:00:00.000Z" } ], "list_metadata": { "before": "als_01HXYZ123456789ABCDEFGHIJ", "after": "als_01HXYZ987654321KJIHGFEDCBA" } }
| curl "https://api.workos.com/audit_logs/actions/user.logged_in/schemas" \ | |
| --header "Authorization: Bearer sk_example_123456789" |
| { | |
| "object": "list", | |
| "data": [ | |
| { | |
| "object": "audit_log_schema", | |
| "version": 1, | |
| "actor": { | |
| "metadata": { | |
| "type": "object", | |
| "properties": { | |
| "role": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| }, | |
| "targets": [ | |
| { | |
| "type": "invoice", | |
| "metadata": { | |
| "type": "object", | |
| "properties": { | |
| "cost": { | |
| "type": "number" | |
| } | |
| } | |
| } | |
| } | |
| ], | |
| "metadata": { | |
| "type": "object", | |
| "properties": { | |
| "transactionId": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "created_at": "2026-01-15T12:00:00.000Z" | |
| } | |
| ], | |
| "list_metadata": { | |
| "before": "als_01HXYZ123456789ABCDEFGHIJ", | |
| "after": "als_01HXYZ987654321KJIHGFEDCBA" | |
| } | |
| } |
GET/audit_logs /actions /:actionName /schemasParameters Returns objectGet a list of all Audit Log actions in the current environment.
curl "https://api.workos.com/audit_logs/actions" \ --header "Authorization: Bearer sk_example_123456789"
{ "object": "list", "data": [ { "object": "audit_log_action", "name": "user.viewed_invoice", "schema": { "object": "audit_log_schema", "version": 1, "actor": { "metadata": { "type": "object", "properties": { "role": { "type": "string" } } } }, "targets": [ { "type": "invoice", "metadata": { "type": "object", "properties": { "cost": { "type": "number" } } } } ], "metadata": { "type": "object", "properties": { "transactionId": { "type": "string" } } }, "created_at": "2026-01-15T12:00:00.000Z" }, "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" } ], "list_metadata": { "before": "ala_01HXYZ123456789ABCDEFGHIJ", "after": "ala_01HXYZ987654321KJIHGFEDCBA" } }
| curl "https://api.workos.com/audit_logs/actions" \ | |
| --header "Authorization: Bearer sk_example_123456789" |
| { | |
| "object": "list", | |
| "data": [ | |
| { | |
| "object": "audit_log_action", | |
| "name": "user.viewed_invoice", | |
| "schema": { | |
| "object": "audit_log_schema", | |
| "version": 1, | |
| "actor": { | |
| "metadata": { | |
| "type": "object", | |
| "properties": { | |
| "role": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| }, | |
| "targets": [ | |
| { | |
| "type": "invoice", | |
| "metadata": { | |
| "type": "object", | |
| "properties": { | |
| "cost": { | |
| "type": "number" | |
| } | |
| } | |
| } | |
| } | |
| ], | |
| "metadata": { | |
| "type": "object", | |
| "properties": { | |
| "transactionId": { | |
| "type": "string" | |
| } | |
| } | |
| }, | |
| "created_at": "2026-01-15T12:00:00.000Z" | |
| }, | |
| "created_at": "2026-01-15T12:00:00.000Z", | |
| "updated_at": "2026-01-15T12:00:00.000Z" | |
| } | |
| ], | |
| "list_metadata": { | |
| "before": "ala_01HXYZ123456789ABCDEFGHIJ", | |
| "after": "ala_01HXYZ987654321KJIHGFEDCBA" | |
| } | |
| } |
GET/audit_logs /actionsParameters Returns object