View Source WorkOS.AuditLogs (WorkOS SDK for Elixir v0.3.0)
The Audit Logs module provides convenience methods for working with the WorkOS Audit Logs platform. You'll need a valid API key.
Link to this section Summary
Functions
Create an Audit Log Event.
Create an Export of Audit Log Events.
Retrieve an Export of Audit Log Events.
Link to this section Functions
Create an Audit Log Event.
parameters
Parameters
- params (map)
- organization (string) The unique ID of the Organization that the event is associated with.
- event (map) The Audit Log event
examples
Examples
iex> WorkOS.AuditLogs.create_event(%{
...> organization: "org_123",
...> event: %{
...> action: "user.signed_in",
...> occurred_at: "2022-09-08T19:46:03.435Z",
...> version: 1,
...> actor: %{
...> id: "user_TF4C5938",
...> type: "user",
...> name: "Jon Smith",
...> metadata: %{
...> role: "admin"
...> }
...> },
...> targets: [
...> %{
...> id: "user_98432YHF",
...> type: "user",
...> name: "Jon Smith"
...> },
...> %{
...> id: "team_J8YASKA2",
...> type: "team",
...> metadata: %{
...> owner: "user_01GBTCQ2"
...> }
...> }
...> ],
...> context: %{
...> location: "New York, NY",
...> user_agent: "Chrome/104.0.0"
...> },
...> metadata: %{
...> extra: "data"
...> }
...> }
...> })
{:ok, nil}
Create an Export of Audit Log Events.
parameters
Parameters
- params (map)
- organization (string) The unique ID of the Organization that the event is associated with.
- range_start (string) ISO-8601 value for start of the export range.
- range_end (string) ISO-8601 value for end of the export range.
- actions (list of strings) List of actions to filter against.
- actors (list of strings) List of actors to filter against.
- targets (list of strings) List of targets to filter against.
examples
Examples
iex> WorkOS.AuditLogs.create_export(%{ ...> organization: "org_123", ...> range_start: "2022-09-08T19:46:03.435Z", ...> range_end: "2022-09-08T19:46:03.435Z", ...> actions: ["user.signed_in"], ...> actors: ["user_01GBTCQ2"], ...> targets: ["user_01GBTCQ2"] ...> })
ok: %{
"object": "audit_log_export",
"id": "audit_log_export_01GBZK5MP7TD1YCFQHFR22180V",
"state": "ready",
"url": "https://exports.audit-logs.com/audit-log-exports/export.csv",
"created_at": "2022-09-02T17:14:57.094Z",
"updated_at": "2022-09-02T17:14:57.094Z"
}
Retrieve an Export of Audit Log Events.
parameters
Parameters
- id (string) The unique ID of the Audit Log Export.
examples
Examples
iex> WorkOS.AuditLogs.get_export("audit_log_export_01GBZK5MP7TD1YCFQHFR22180V")
ok: %{
"object": "audit_log_export",
"id": "audit_log_export_01GBZK5MP7TD1YCFQHFR22180V",
"state": "ready",
"url": "https://exports.audit-logs.com/audit-log-exports/export.csv",
"created_at": "2022-09-02T17:14:57.094Z",
"updated_at": "2022-09-02T17:14:57.094Z"
}