WorkOS PHP SDK

Pipes
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
authorizeDataIntegration()  : DataIntegrationAuthorizeUrlResponse
Get authorization URL
createDataIntegration()  : DataIntegration
Create a data integration
createDataIntegrationCredential()  : DataIntegrationCredentialsResponse
Vend credentials for a connected account
createUserConnectedAccount()  : ConnectedAccount
Import a connected account
deleteDataIntegration()  : void
Delete a data integration
deleteUserConnectedAccount()  : void
Delete a connected account
getAccessToken()  : DataIntegrationAccessTokenResponse
Get an access token for a connected account
getDataIntegration()  : DataIntegration
Get a data integration
getUserConnectedAccount()  : ConnectedAccount
Get a connected account
listDataIntegrations()  : PaginatedResponse<string|int, DataIntegration>
List data integrations
listUserDataProviders()  : DataIntegrationsListResponse
List providers for a user
updateDataIntegration()  : DataIntegration
Update a data integration
updateDataIntegrationApiKey()  : ConnectedAccount
Upsert an API key for a connected account
updateDataIntegrationClientCredentials()  : ConnectedAccount
Upsert client credentials for a connected account
updateUserConnectedAccount()  : ConnectedAccount
Update a connected account

Properties

Methods

authorizeDataIntegration()

Get authorization URL

public authorizeDataIntegration(string $slug, string $userId[, string|null $organizationId = null ][, string|null $returnTo = null ][, array<string, string>|null $config = null ][, RequestOptions|null $options = null ]) : DataIntegrationAuthorizeUrlResponse

Generates an OAuth authorization URL to initiate the connection flow for a user. Redirect the user to the returned URL to begin the OAuth flow with the third-party provider.

Parameters
$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$userId : string

The ID of the user to authorize.

$organizationId : string|null = null

An organization ID to scope the authorization to a specific organization.

$returnTo : string|null = null

The URL to redirect the user to after authorization.

$config : array<string, string>|null = null

Connect-time config values for the provider-declared installation-scope fields (e.g. a Zendesk subdomain), keyed by the config field. Only fields the provider declares may be supplied, and required fields must be provided unless already pinned on the integration.

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

createDataIntegration()

Create a data integration

public createDataIntegration(string $provider[, string|null $description = null ][, bool|null $enabled = null ][, array<string|int, string>|null $scopes = null ][, array<string|int, DataIntegrationAuthMethods>|null $authMethods = null ][, array<string, string>|null $config = null ][, DataIntegrationCredentialsInput|null $credentials = null ][, ApiKeyInstallation|null $apiKey = null ][, CustomProviderDefinition|null $customProvider = null ][, RequestOptions|null $options = null ]) : DataIntegration

Creates a data integration for a provider. Set credentials.type to custom to use your own OAuth app credentials or organization to have each organization supply its own. Set auth_methods to ["api_key"] to create an API key integration; you may optionally supply an api_key block to install a first tenant in the same call. Set auth_methods to ["client_credentials"] to create a client-credentials integration; client credentials are installed per-tenant afterwards. For a built-in provider, pass its slug as provider. For a custom provider, pass a new slug plus a custom_provider definition.

Parameters
$provider : string

The provider to create a Data Integration for. For a built-in provider use its slug (e.g. github, slack). For a custom provider, this is the new provider slug and custom_provider must be supplied. A custom provider slug cannot shadow an existing global provider slug.

$description : string|null = null

An optional description of the Data Integration.

$enabled : bool|null = null

Whether the Data Integration is enabled. Defaults to false.

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

The OAuth scopes to request for the Data Integration. Defaults to the provider's configured scopes when omitted.

$authMethods : array<string|int, DataIntegrationAuthMethods>|null = null

How accounts authenticate with the provider. Defaults to ["oauth"]. Use ["api_key"] to declare an API key integration; credentials is then not required and keys are supplied per-tenant (optionally via api_key on this request). Use ["client_credentials"] to declare a client-credentials integration; credentials is likewise not required and client credentials are supplied per-tenant.

$config : array<string, string>|null = null

Provider-specific config values (e.g. a Snowflake account), keyed by the config field. Only fields the built-in provider declares are accepted.

$credentials : DataIntegrationCredentialsInput|null = null

The OAuth credentials to configure for the Data Integration. Required for OAuth integrations; omit when auth_methods is ["api_key"].

$apiKey : ApiKeyInstallation|null = null

An optional API key to install for the first tenant on an api_key integration. Omit to declare a keyless integration; tenants can be added later via the per-installation API key path.

$customProvider : CustomProviderDefinition|null = null

The OAuth definition for a custom provider. Supply this to define a custom provider; omit it to create an integration for a built-in provider.

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

createDataIntegrationCredential()

Vend credentials for a connected account

public createDataIntegrationCredential(string $slug, string $userId[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : DataIntegrationCredentialsResponse

Returns credentials for a user's connected account. Branches on the installation's auth_method: OAuth installations return an access token (refreshed if needed); API-key installations return the stored secret.

Parameters
$slug : string

The identifier of the integration.

$userId : string

A User identifier.

$organizationId : string|null = null

An Organization identifier. Optional parameter to scope the connection to a specific organization.

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

createUserConnectedAccount()

Import a connected account

public createUserConnectedAccount(string $userId, string $slug[, string|null $accessToken = null ][, string|null $refreshToken = null ][, DateTimeImmutable|null $expiresAt = null ][, array<string|int, string>|null $scopes = null ][, PipeConnectedAccountState|null $state = null ][, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : ConnectedAccount

Imports a connected account for a user by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow.

Parameters
$userId : string

A User identifier.

$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$accessToken : string|null = null

The OAuth access token for the connected account.

$refreshToken : string|null = null

The OAuth refresh token for the connected account.

$expiresAt : DateTimeImmutable|null = null

The ISO-8601 timestamp when the access token expires. Required when access_token is provided for tokens that expire.

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

The OAuth scopes granted for this connection.

$state : PipeConnectedAccountState|null = null

Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.

$organizationId : string|null = null

An Organization identifier. Optional parameter if the connection is scoped to an organization.

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

deleteDataIntegration()

Delete a data integration

public deleteDataIntegration(string $slug[, RequestOptions|null $options = null ]) : void

Deletes a data integration and all of its connected installations. For a custom provider, also deletes the custom provider definition.

Parameters
$slug : string

The slug identifier of the data integration.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

deleteUserConnectedAccount()

Delete a connected account

public deleteUserConnectedAccount(string $userId, string $slug[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : void

Disconnects WorkOS's account for the user, including removing any stored access and refresh tokens. The user will need to reauthorize if they want to reconnect. This does not revoke access on the provider side.

Parameters
$userId : string

A User identifier.

$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$organizationId : string|null = null

An Organization identifier. Optional parameter if the connection is scoped to an organization.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

getAccessToken()

Get an access token for a connected account

public getAccessToken(string $provider, string $userId[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : DataIntegrationAccessTokenResponse

Fetches a valid OAuth access token for a user's connected account. WorkOS automatically handles token refresh, ensuring you always receive a valid, non-expired token.

Parameters
$provider : string

The identifier of the integration.

$userId : string

A User identifier.

$organizationId : string|null = null

An Organization identifier. Optional parameter to scope the connection to a specific organization.

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

getUserConnectedAccount()

Get a connected account

public getUserConnectedAccount(string $userId, string $slug[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : ConnectedAccount

Retrieves a user's connected account for a specific provider.

Parameters
$userId : string

A User identifier.

$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$organizationId : string|null = null

An Organization identifier. Optional parameter if the connection is scoped to an organization.

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

listDataIntegrations()

List data integrations

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

Lists the environment's data integrations configured with custom or organization credentials, including custom providers and API key integrations.

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. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

$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. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

$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. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records). Defaults to "desc".

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

listUserDataProviders()

List providers for a user

public listUserDataProviders(string $userId[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : DataIntegrationsListResponse

Retrieves a list of available providers and the user's connection status for each. Returns all providers configured for your environment, along with the user's connected account information where applicable.

Parameters
$userId : string

A User identifier to list providers and connected accounts for.

$organizationId : string|null = null

An Organization identifier. Optional parameter to filter connections for a specific organization.

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

updateDataIntegration()

Update a data integration

public updateDataIntegration(string $slug[, string|null $description = null ][, bool|null $enabled = null ][, array<string|int, string>|null $scopes = null ][, DataIntegrationCredentialsInput|null $credentials = null ][, ApiKeyInstallation|null $apiKey = null ][, UpdateCustomProviderDefinition|null $customProvider = null ][, RequestOptions|null $options = null ]) : DataIntegration

Updates the description, enabled state, or custom credentials of a data integration. For custom providers, custom_provider updates the OAuth definition.

Parameters
$slug : string

The slug identifier of the data integration.

$description : string|null = null

An optional description of the Data Integration.

$enabled : bool|null = null

Whether the Data Integration is enabled.

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

The OAuth scopes to request for the Data Integration. Pass null to reset to the provider's configured scopes.

$credentials : DataIntegrationCredentialsInput|null = null

New OAuth credentials for the Data Integration. When provided, rotates the stored client secret. Mutually exclusive with api_key.

$apiKey : ApiKeyInstallation|null = null

An API key to install or rotate for a tenant on an api_key integration. Upserts the tenant installation identified by user_id (and optional organization_id).

$customProvider : UpdateCustomProviderDefinition|null = null

Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations.

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

updateDataIntegrationApiKey()

Upsert an API key for a connected account

public updateDataIntegrationApiKey(string $slug, string $userId, string $secret[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : ConnectedAccount

Creates or updates an API-key-based installation for the specified integration and user. If an installation already exists, the stored API key is rotated to the new value.

Parameters
$slug : string

The identifier of the integration.

$userId : string

A User identifier.

$secret : string

The API key secret to store for this integration.

$organizationId : string|null = null

An Organization identifier. Optional parameter to scope the connection to a specific organization.

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

updateDataIntegrationClientCredentials()

Upsert client credentials for a connected account

public updateDataIntegrationClientCredentials(string $slug, string $userId, string $clientId, string $clientSecret[, string|null $organizationId = null ][, array<string, string>|null $config = null ][, RequestOptions|null $options = null ]) : ConnectedAccount

Creates or updates a client-credentials-based installation for the specified integration and user. If an installation already exists, the stored client credentials are rotated to the new values.

Parameters
$slug : string

The identifier of the integration.

$userId : string

A User identifier.

$clientId : string

The OAuth client ID to store for this integration.

$clientSecret : string

The OAuth client secret to store for this integration.

$organizationId : string|null = null

An Organization identifier. Optional parameter to scope the connection to a specific organization.

$config : array<string, string>|null = null

Provider-specific configuration values collected for this installation, keyed by the provider's config field descriptors.

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

updateUserConnectedAccount()

Update a connected account

public updateUserConnectedAccount(string $userId, string $slug[, string|null $accessToken = null ][, string|null $refreshToken = null ][, DateTimeImmutable|null $expiresAt = null ][, array<string|int, string>|null $scopes = null ][, PipeConnectedAccountState|null $state = null ][, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : ConnectedAccount

Updates a user's connected account tokens, scopes, or state for a specific provider.

Parameters
$userId : string

A User identifier.

$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$accessToken : string|null = null

The OAuth access token for the connected account.

$refreshToken : string|null = null

The OAuth refresh token for the connected account.

$expiresAt : DateTimeImmutable|null = null

The ISO-8601 timestamp when the access token expires. Required when access_token is provided for tokens that expire.

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

The OAuth scopes granted for this connection.

$state : PipeConnectedAccountState|null = null

Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.

$organizationId : string|null = null

An Organization identifier. Optional parameter if the connection is scoped to an organization.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
ConnectedAccount
On this page

Search results