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', }, });
require "workos" WorkOS.configure do |config| config.api_key = "sk_example_123456789" end WorkOS.client.audit_logs.create_schema( action_name: "user.logged_in", targets: [ { type: "invoice", metadata: { type: "object", properties: { cost: { type: "number" } } } } ] )
from workos import WorkOSClient client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") client.audit_logs.create_schema( action_name="user.logged_in", targets=[ { "type": "invoice", "metadata": {"type": "object", "properties": {"cost": {"type": "number"}}}, } ], )
package main import ( "context" "github.com/workos/workos-go/v9" ) func main() { client := workos.NewClient("sk_example_123456789") _, err := client.AuditLogs().CreateSchema(context.Background(), "user.logged_in", &workos.AuditLogsCreateSchemaParams{ Targets: []any{ map[string]any{ "type": "invoice", "metadata": map[string]any{ "type": "object", "properties": map[string]any{"cost": map[string]any{"type": "number"}}, }, }, }, }) if err != nil { panic(err) } }
<?php use WorkOS\WorkOS; $workos = new WorkOS( apiKey: "sk_example_123456789", clientId: "client_123456789", ); $workos->auditLogs()->createSchema( actionName: "user.logged_in", targets: [ [ "type" => "invoice", "metadata" => [ "type" => "object", "properties" => ["cost" => ["type" => "number"]], ], ], ], );
import com.workos.WorkOS; import com.workos.auditlogs.AuditLogsApi.CreateSchemaOptions; WorkOS workos = new WorkOS("sk_example_123456789"); CreateSchemaOptions options = CreateSchemaOptions.builder() .targets(List.of(Map.of("type", "invoice", "metadata", Map.of("type", "object", "properties", Map.of("cost", Map.of("type", "number")))))) .build(); workos.auditLogs.createSchema("user.logged_in", options);
using WorkOS; var client = new WorkOSClient(new WorkOSOptions { ApiKey = "sk_example_123456789", ClientId = "client_123456789", }); await client.AuditLogs.CreateSchemaAsync("user.logged_in", new AuditLogsCreateSchemaOptions { Targets = new[] { new Dictionary<string, object> { { "type", "invoice" }, { "metadata", new Dictionary<string, object> { { "type", "object" }, { "properties", new Dictionary<string, object> { { "cost", new Dictionary<string, object> { { "type", "number" }, } }, } }, } }, }, }, });
use workos::Client; use workos::audit_logs::CreateSchemaParams; #[tokio::main] async fn main() -> Result<(), workos::Error> { let client = Client::builder() .api_key("sk_example_123456789") .client_id("client_123456789") .build(); let _result = client .audit_logs() .create_schema( "user.logged_in", CreateSchemaParams { targets: vec![ serde_json::json!({ "type": "invoice", "metadata": serde_json::json!({ "type": "object", "properties": serde_json::json!({ "cost": serde_json::json!({ "type": "number" }) }), }), }), ], ..Default::default() } ) .await?; Ok(()) }
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" |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.audit_logs.list_action_schemas(action_name: "user.logged_in") |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.audit_logs.list_action_schemas(action_name="user.logged_in") |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.AuditLogs().ListActionSchemas(context.Background(), "user.logged_in") | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos->auditLogs()->listActionSchemas(actionName: "user.logged_in"); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.auditLogs.listActionSchemas("user.logged_in"); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.AuditLogs.ListActionSchemasAsync("user.logged_in"); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .audit_logs() | |
| .list_action_schemas("user.logged_in") | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "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" |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.audit_logs.list_actions |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.audit_logs.list_actions() |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.AuditLogs().ListActions(context.Background()) | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos->auditLogs()->listActions(); |
| import com.workos.WorkOS; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| workos.auditLogs.listActions(); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.AuditLogs.ListActionsAsync(); |
| use workos::Client; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .audit_logs() | |
| .list_actions() | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "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