WorkOS PHP SDK

AuditLogs
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
createEvent()  : AuditLogEventCreateResponse
Create Event
createExport()  : AuditLogExportJson
Create Export
createSchema()  : AuditLogSchemaJson
Create Schema
getExport()  : AuditLogExportJson
Get Export
getOrganizationAuditLogsRetention()  : AuditLogsRetentionJson
Get Retention
listActions()  : PaginatedResponse<string|int, AuditLogActionJson>
List Actions
listActionSchemas()  : PaginatedResponse<string|int, AuditLogSchemaJson>
List Schemas
updateOrganizationAuditLogsRetention()  : AuditLogsRetentionJson
Set Retention

Properties

Methods

createEvent()

Create Event

public createEvent(string $organizationId, AuditLogEvent $event[, RequestOptions|null $options = null ]) : AuditLogEventCreateResponse

Create an Audit Log Event.

This API supports idempotency which guarantees that performing the same operation multiple times will have the same result as if the operation were performed only once. This is handy in situations where you may need to retry a request due to a failure or prevent accidental duplicate requests from creating more than one resource.

To achieve idempotency, you can add Idempotency-Key request header to a Create Event request with a unique string as the value. Each subsequent request matching this unique string will return the same response. We suggest using v4 UUIDs for idempotency keys to avoid collisions.

Idempotency keys expire after 24 hours. The API will generate a new response if you submit a request with an expired key.

Parameters
$organizationId : string

The unique ID of the Organization.

$event : AuditLogEvent

The audit log event to create.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
AuditLogEventCreateResponse

createExport()

Create Export

public createExport(string $organizationId, string $rangeStart, string $rangeEnd[, array<string|int, string>|null $actions = null ][, array<string|int, string>|null $actors = null ][, array<string|int, string>|null $actorNames = null ][, array<string|int, string>|null $actorIds = null ][, array<string|int, string>|null $targets = null ][, RequestOptions|null $options = null ]) : AuditLogExportJson

Create an Audit Log Export. Exports are scoped to a single organization within a specified date range.

Parameters
$organizationId : string

The unique ID of the Organization.

$rangeStart : string

ISO-8601 value for start of the export range.

$rangeEnd : string

ISO-8601 value for end of the export range.

$actions : array<string|int, string>|null = null

List of actions to filter against.

$actors : array<string|int, string>|null = null

(deprecated) Deprecated. Use actor_names instead.

$actorNames : array<string|int, string>|null = null

List of actor names to filter against.

$actorIds : array<string|int, string>|null = null

List of actor IDs to filter against.

$targets : array<string|int, string>|null = null

List of target types to filter against.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
AuditLogExportJson

createSchema()

Create Schema

public createSchema(string $actionName, array<string|int, AuditLogSchemaTarget$targets[, AuditLogSchemaActor|null $actor = null ][, array<string, mixed>|null $metadata = null ][, RequestOptions|null $options = null ]) : AuditLogSchemaJson

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.

Parameters
$actionName : string

The name of the Audit Log action.

$targets : array<string|int, AuditLogSchemaTarget>

The list of targets for the schema.

$actor : AuditLogSchemaActor|null = null

The metadata schema for the actor.

$metadata : array<string, mixed>|null = null

Optional JSON schema for event metadata.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
AuditLogSchemaJson

getExport()

Get Export

public getExport(string $auditLogExportId[, RequestOptions|null $options = null ]) : AuditLogExportJson

Get an Audit Log Export. The URL will expire after 10 minutes. If the export is needed again at a later time, refetching the export will regenerate the URL.

Parameters
$auditLogExportId : string

The unique ID of the Audit Log Export.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
AuditLogExportJson

listActions()

List Actions

public listActions([string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, EventsOrder $order = EventsOrder::Desc ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, AuditLogActionJson>

Get a list of all Audit Log actions in the current environment.

Parameters
$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : EventsOrder = EventsOrder::Desc

Order the results by the creation time. Defaults to "desc".

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, AuditLogActionJson>

listActionSchemas()

List Schemas

public listActionSchemas(string $actionName[, string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, EventsOrder $order = EventsOrder::Desc ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, AuditLogSchemaJson>

Get a list of all schemas for the Audit Logs action identified by :name.

Parameters
$actionName : string

The name of the Audit Log action.

$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : EventsOrder = EventsOrder::Desc

Order the results by the creation time. Defaults to "desc".

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, AuditLogSchemaJson>

updateOrganizationAuditLogsRetention()

Set Retention

public updateOrganizationAuditLogsRetention(string $id, int $retentionPeriodInDays[, RequestOptions|null $options = null ]) : AuditLogsRetentionJson

Set the event retention period for the given Organization.

Parameters
$id : string

Unique identifier of the Organization.

$retentionPeriodInDays : int

The number of days Audit Log events will be retained. Valid values are 30 and 365.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
AuditLogsRetentionJson

        
On this page

Search results