WorkOS PHP SDK

ApiKeys
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
createApiKeyExpire()  : ApiKey
Expire an API key
createOrganizationApiKey()  : OrganizationApiKeyWithValue
Create an API key for an organization
createValidation()  : ApiKeyValidationResponse
Validate API key
deleteApiKey()  : void
Delete an API key
listOrganizationApiKeys()  : PaginatedResponse<string|int, OrganizationApiKey>
List API keys for an organization

Properties

Methods

createApiKeyExpire()

Expire an API key

public createApiKeyExpire(string $id[, DateTimeImmutable|null $expiresAt = null ][, RequestOptions|null $options = null ]) : ApiKey

Expire an API key immediately, schedule a future expiration, or clear a scheduled future expiration.

Parameters
$id : string

The unique ID of the API key.

$expiresAt : DateTimeImmutable|null = null

When the API key should expire. If omitted or in the past, the key expires immediately. Use null to clear a scheduled future expiration.

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

createOrganizationApiKey()

Create an API key for an organization

public createOrganizationApiKey(string $organizationId, string $name[, array<string|int, string>|null $permissions = null ][, DateTimeImmutable|null $expiresAt = null ][, RequestOptions|null $options = null ]) : OrganizationApiKeyWithValue

Create a new API key for an organization.

Parameters
$organizationId : string

Unique identifier of the Organization.

$name : string

The name for the API key.

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

The permission slugs to assign to the API key.

$expiresAt : DateTimeImmutable|null = null

The timestamp when the API key should expire. Must be a future timestamp. If omitted, the key does not expire.

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

deleteApiKey()

Delete an API key

public deleteApiKey(string $id[, RequestOptions|null $options = null ]) : void

Permanently deletes an API key. This action cannot be undone. Once deleted, any requests using this API key will fail authentication.

Parameters
$id : string

The unique ID of the API key.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

listOrganizationApiKeys()

List API keys for an organization

public listOrganizationApiKeys(string $organizationId[, string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, PaginationOrder $order = PaginationOrder::Desc ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, OrganizationApiKey>

Get a list of all API keys for an organization.

Parameters
$organizationId : string

Unique identifier of the Organization.

$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 : PaginationOrder = PaginationOrder::Desc

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

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, OrganizationApiKey>
On this page

Search results