Class: WorkOS::Pipes

Inherits:
Object
  • Object
show all
Defined in:
lib/workos/pipes.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Pipes

Returns a new instance of Pipes.



9
10
11
# File 'lib/workos/pipes.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#authorize_data_integration(slug:, user_id:, account_display_name: WorkOS::OMIT, organization_id: nil, connection_owner: nil, return_to: nil, code_challenge: nil, code_challenge_method: nil, config: nil, connection_intent: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAuthorizeUrlResponse

Get authorization URL

Parameters:

  • slug (String) —

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

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.

  • user_id (String) —

    The ID of the user to authorize. When connection_owner is organization, this is the user authorizing on behalf of the organization; they must be an active member of the organization and do not become the owner of the resulting connected account.

  • organization_id (String, nil) (defaults to: nil) —

    An organization ID to scope the authorization to a specific organization. Required when connection_owner is organization.

  • connection_owner (WorkOS::Types::DataIntegrationsGetDataIntegrationAuthorizeUrlRequestConnectionOwner, nil) (defaults to: nil) —

    Who will own the connected account. user (the default) connects the user's own account. organization connects the organization's shared account and requires organization_id.

  • return_to (String, nil) (defaults to: nil) —

    The URL to redirect the user to after authorization. Required with code_challenge, and must then exactly match a redirect URI registered on one of the environment's applications. Loopback URLs match on any port; wildcard redirect URIs are not honored, and a return_to with a query string or fragment never matches.

  • code_challenge (String, nil) (defaults to: nil) —

    A PKCE-style code challenge: the base64url-encoded SHA-256 of a code_verifier your app keeps. When set, the connection isn't saved when the user finishes authorizing. Instead, the user is redirected to return_to with a connect_code and state, and your app must call Finish connection with the connect_code and code_verifier within 90 seconds to save it.

  • code_challenge_method (String, nil) (defaults to: nil) —

    The method used to derive code_challenge. Only S256 is supported, and it is the default. Requires code_challenge.

  • config (Hash{String => String}, nil) (defaults to: nil) —

    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.

  • connection_intent (WorkOS::Types::DataIntegrationsGetDataIntegrationAuthorizeUrlRequestConnectionIntent, nil) (defaults to: nil) —

    Which connection the request targets. Omit it to use the compatibility connection. Send add to create another connection: the first connection for an owner shape fills the compatibility slot, and later connections are standard. Send reauthorize with connected_account_id to reauthorize one exact connection.

  • connected_account_id (String, nil) (defaults to: nil) —

    The exact connected account to reauthorize. Required with connection_intent: reauthorize and not accepted otherwise.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/workos/pipes.rb', line 319

def authorize_data_integration(
  slug:,
  user_id:,
  account_display_name: WorkOS::OMIT,
  organization_id: nil,
  connection_owner: nil,
  return_to: nil,
  code_challenge: nil,
  code_challenge_method: nil,
  config: nil,
  connection_intent: nil,
  connected_account_id: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connection_owner" => connection_owner,
    "return_to" => return_to,
    "code_challenge" => code_challenge,
    "code_challenge_method" => code_challenge_method,
    "config" => config,
    "connection_intent" => connection_intent,
    "connected_account_id" => 
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/authorize",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationAuthorizeUrlResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration(provider:, ownership: nil, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, auth_methods: nil, config: nil, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration

Create a data integration

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.

  • ownership (WorkOS::Types::CreateDataIntegrationOwnership, nil) (defaults to: nil) —

    Who owns the Data Integration. user (the default) creates the integration users connect their own accounts to; organization creates the root organizations connect to. Ownership is fixed at creation, and one integration of each ownership may exist per provider. Independent of credentials.type.

  • description (String, nil) (defaults to: WorkOS::OMIT) —

    An optional description of the Data Integration.

  • enabled (Boolean, nil) (defaults to: nil) —

    Whether the Data Integration is enabled. Defaults to false.

  • scopes (Array<String>, nil) (defaults to: WorkOS::OMIT) —

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

  • auth_methods (Array<WorkOS::Types::CreateDataIntegrationAuthMethods>, nil) (defaults to: nil) —

    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 (Hash{String => String}, nil) (defaults to: nil) —

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

  • credentials (WorkOS::DataIntegrationCredentialsInput, nil) (defaults to: nil) —

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

  • api_key (WorkOS::ApiKeyInstallation, nil) (defaults to: nil) —

    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.

  • custom_provider (WorkOS::CustomProviderDefinition, nil) (defaults to: nil) —

    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.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/workos/pipes.rb', line 74

def create_data_integration(
  provider:,
  ownership: nil,
  description: WorkOS::OMIT,
  enabled: nil,
  scopes: WorkOS::OMIT,
  auth_methods: nil,
  config: nil,
  credentials: nil,
  api_key: nil,
  custom_provider: nil,
  request_options: {}
)
  body = {
    "provider" => provider,
    "ownership" => ownership,
    "enabled" => enabled,
    "auth_methods" => auth_methods,
    "config" => config,
    "credentials" => credentials,
    "api_key" => api_key,
    "custom_provider" => custom_provider
  }.compact
  body["description"] = description unless description.equal?(WorkOS::OMIT)
  body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration_api_key(slug:, user_id:, secret:, connection_intent:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, organization_id: nil, connection_owner: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Create another API key connected account

Parameters:

  • slug (String) —

    The identifier of the integration.

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested provider account identifier, never inferred from a label or credential. Omit to preserve an existing identifier; null clears it.

  • user_id (String) —

    A User identifier.

  • organization_id (String, nil) (defaults to: nil) —

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connection_owner (WorkOS::Types::DataIntegrationsCreateApiKeyConnectionRequestConnectionOwner, nil) (defaults to: nil) —

    Whose connection to create or rotate. user (the default) addresses the connection owned by user_id. organization addresses the connection shared by every member of organization_id; user_id then identifies the member performing the request and must be an active member of the organization.

  • secret (String) —

    The API key secret to store for this integration.

  • connection_intent (String) —

    Must be add: this endpoint only creates another connection. The first connection for an owner shape fills the compatibility slot; later connections are standard.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/workos/pipes.rb', line 227

def create_data_integration_api_key(
  slug:,
  user_id:,
  secret:,
  connection_intent:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  organization_id: nil,
  connection_owner: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connection_owner" => connection_owner,
    "secret" => secret,
    "connection_intent" => connection_intent
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/api-key",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration_client_credential(slug:, user_id:, client_id:, client_secret:, connection_intent:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, organization_id: nil, connection_owner: nil, config: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Create another client credentials connected account

Parameters:

  • slug (String) —

    The identifier of the integration.

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested provider account identifier, never inferred from a label or credential. Omit to preserve an existing identifier; null clears it.

  • user_id (String) —

    A User identifier.

  • organization_id (String, nil) (defaults to: nil) —

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connection_owner (WorkOS::Types::DataIntegrationsCreateClientCredentialsConnectionRequestConnectionOwner, nil) (defaults to: nil) —

    Whose connection to create or rotate. user (the default) addresses the connection owned by user_id. organization addresses the connection shared by every member of organization_id; user_id then identifies the member performing the request and must be an active member of the organization.

  • client_id (String) —

    The OAuth client ID to store for this integration.

  • client_secret (String) —

    The OAuth client secret to store for this integration.

  • config (Hash{String => String}, nil) (defaults to: nil) —

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

  • connection_intent (String) —

    Must be add: this endpoint only creates another connection. The first connection for an owner shape fills the compatibility slot; later connections are standard.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/workos/pipes.rb', line 370

def create_data_integration_client_credential(
  slug:,
  user_id:,
  client_id:,
  client_secret:,
  connection_intent:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  organization_id: nil,
  connection_owner: nil,
  config: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connection_owner" => connection_owner,
    "client_id" => client_id,
    "client_secret" => client_secret,
    "config" => config,
    "connection_intent" => connection_intent
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/client-credentials",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_data_integration_credential(slug:, user_id:, organization_id: nil, connected_account_id: nil, connection_owner: nil, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationCredentialsResponse

Vend credentials for a connected account

Parameters:

  • slug (String) —

    The identifier of the integration.

  • user_id (String) —

    A User identifier. When connection_owner is organization, this is the user the credentials are vended on behalf of; they must be an active member of the organization.

  • organization_id (String, nil) (defaults to: nil) —

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select a specific connection when the user has several for this provider.

  • connection_owner (WorkOS::Types::DataIntegrationsVendCredentialsRequestConnectionOwner, nil) (defaults to: nil) —

    Which connection to vend from. user (the default) vends the user's own connection and requires user_id. organization vends the organization's shared connection and requires organization_id.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. If no connected_account_id is supplied and several connections match, the request returns account_selection_required. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/workos/pipes.rb', line 467

def create_data_integration_credential(
  slug:,
  user_id:,
  organization_id: nil,
  connected_account_id: nil,
  connection_owner: nil,
  supports_multiple_connections: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connected_account_id" => ,
    "connection_owner" => connection_owner,
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/credentials",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationCredentialsResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_organization_connected_account(organization_id:, slug:, user_id:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, connection_intent: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Import an organization connected account

Parameters:

  • organization_id (String) —

    An Organization identifier.

  • slug (String) —

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

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique connection label; null clears it. Not an account identifier.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested account identifier; null clears it.

  • access_token (String, nil) (defaults to: nil) —

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil) —

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil) —

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

  • scopes (Array<String>, nil) (defaults to: nil) —

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::CreateOrganizationConnectedAccountState, nil) (defaults to: nil) —

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

  • user_id (String) —

    The User identifier of the organization member on whose behalf the connected account is being imported or updated. The user must be an active member of the organization.

  • connection_intent (String, nil) (defaults to: nil) —

    Set to add to create another connected account. Omit this field for permanent compatibility behavior.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# File 'lib/workos/pipes.rb', line 652

def (
  organization_id:,
  slug:,
  user_id:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  connection_intent: nil,
  request_options: {}
)
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state,
    "user_id" => user_id,
    "connection_intent" => connection_intent
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create_user_connected_account(user_id:, slug:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, connection_intent: nil, organization_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Import a connected account

Parameters:

  • user_id (String) —

    A User identifier.

  • slug (String) —

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

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique connection label; null clears it. Not an account identifier.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested account identifier; null clears it.

  • access_token (String, nil) (defaults to: nil) —

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil) —

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil) —

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

  • scopes (Array<String>, nil) (defaults to: nil) —

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::CreateConnectedAccountState, nil) (defaults to: nil) —

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

  • connection_intent (String, nil) (defaults to: nil) —

    Set to add to create another connected account. Omit this field for permanent compatibility behavior.

  • organization_id (String, nil) (defaults to: nil) —

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

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/workos/pipes.rb', line 849

def (
  user_id:,
  slug:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  connection_intent: nil,
  organization_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id
  }.compact
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state,
    "connection_intent" => connection_intent
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#delete_data_integration(slug:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete a data integration

Parameters:

  • slug (String) —

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)



203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/workos/pipes.rb', line 203

def delete_data_integration(
  slug:,
  request_options: {}
)
  @client.request(
    method: :delete,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    request_options: request_options
  )
  nil
end

#delete_data_integration_organization(slug:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete an organization-owned data integration

Parameters:

  • slug (String) —

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)



558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/workos/pipes.rb', line 558

def delete_data_integration_organization(
  slug:,
  request_options: {}
)
  @client.request(
    method: :delete,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
    auth: true,
    request_options: request_options
  )
  nil
end

#delete_organization_connected_account(organization_id:, slug:, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ void

This method returns an undefined value.

Delete an organization connected account

Parameters:

  • organization_id (String) —

    An Organization identifier.

  • slug (String) —

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

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select the connection to delete.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)



756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/workos/pipes.rb', line 756

def (
  organization_id:,
  slug:,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  @client.request(
    method: :delete,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  nil
end

#delete_user_connected_account(user_id:, slug:, organization_id: nil, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ void

This method returns an undefined value.

Delete a connected account

Parameters:

  • user_id (String) —

    A User identifier.

  • slug (String) —

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

  • organization_id (String, nil) (defaults to: nil) —

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

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select the connection to delete.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)



957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
# File 'lib/workos/pipes.rb', line 957

def (
  user_id:,
  slug:,
  organization_id: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  @client.request(
    method: :delete,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  nil
end

#finish_connection(connect_code:, code_verifier:, state: nil, request_options: {}) ⇒ WorkOS::DataIntegrationFinishConnectionResponse

Finish connection

Parameters:

  • connect_code (String) —

    The connect_code WorkOS added to return_to when the user finished authorizing. It can be used once and expires 90 seconds after the redirect.

  • code_verifier (String) —

    The code verifier code_challenge was derived from: 43 to 128 characters from A-Z, a-z, 0-9, -, ., _ and ~. A wrong verifier uses up the connect_code, and the user has to connect again.

  • state (String, nil) (defaults to: nil) —

    The state WorkOS added to return_to alongside connect_code. Optional; it is only used to correlate the request in logs.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/workos/pipes.rb', line 117

def finish_connection(
  connect_code:,
  code_verifier:,
  state: nil,
  request_options: {}
)
  body = {
    "connect_code" => connect_code,
    "code_verifier" => code_verifier,
    "state" => state
  }.compact
  response = @client.request(
    method: :post,
    path: "/data-integrations/finish",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationFinishConnectionResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_access_token(provider:, user_id:, organization_id: WorkOS::OMIT, connected_account_id: nil, connection_owner: nil, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationAccessTokenResponse

Get an access token for a connected account

Parameters:

  • provider (String) —

    The identifier of the integration.

  • user_id (String) —

    A User identifier. When connection_owner is organization, this is the user the credentials are vended on behalf of; they must be an active member of the organization.

  • organization_id (String, nil) (defaults to: WorkOS::OMIT) —

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select a specific connection when the user has several for this provider.

  • connection_owner (WorkOS::Types::DataIntegrationsGetUserTokenRequestConnectionOwner, nil) (defaults to: nil) —

    Which connection to vend from. user (the default) vends the user's own connection and requires user_id. organization vends the organization's shared connection and requires organization_id.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. If no connected_account_id is supplied and several connections match, the request returns account_selection_required. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/workos/pipes.rb', line 580

def get_access_token(
  provider:,
  user_id:,
  organization_id: WorkOS::OMIT,
  connected_account_id: nil,
  connection_owner: nil,
  supports_multiple_connections: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "connected_account_id" => ,
    "connection_owner" => connection_owner,
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  body["organization_id"] = organization_id unless organization_id.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :post,
    path: "/data-integrations/#{WorkOS::Util.encode_path(provider)}/token",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationAccessTokenResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_data_integration(slug:, request_options: {}) ⇒ WorkOS::DataIntegration

Get a data integration

Parameters:

  • slug (String) —

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/workos/pipes.rb', line 144

def get_data_integration(
  slug:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_organization_connected_account(organization_id:, slug:, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Get an organization connected account

Parameters:

  • organization_id (String) —

    An Organization identifier.

  • slug (String) —

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

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select a specific connection when the organization has several for this provider.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/workos/pipes.rb', line 615

def (
  organization_id:,
  slug:,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  response = @client.request(
    method: :get,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get_user_connected_account(user_id:, slug:, organization_id: nil, supports_multiple_connections: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Get a connected account

Parameters:

  • user_id (String) —

    A User identifier.

  • slug (String) —

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

  • organization_id (String, nil) (defaults to: nil) —

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

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select a specific connection when the user has several for this provider.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
# File 'lib/workos/pipes.rb', line 810

def (
  user_id:,
  slug:,
  organization_id: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => 
  }.compact
  response = @client.request(
    method: :get,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_data_integration_organization(slug:, request_options: {}) ⇒ WorkOS::DataIntegration

Get an organization-owned data integration

Parameters:

  • slug (String) —

    The slug identifier of the data integration.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/workos/pipes.rb', line 499

def list_data_integration_organization(
  slug:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
    auth: true,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_data_integrations(before: nil, after: nil, limit: 10, order: "desc", ownership: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::DataIntegration>

List data integrations

Parameters:

  • before (String, nil) (defaults to: nil) —

    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, nil) (defaults to: nil) —

    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 (Integer, nil) (defaults to: 10) —

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

  • order (WorkOS::Types::PaginationOrder, nil) (defaults to: "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).

  • ownership (WorkOS::Types::PipesOwnership, nil) (defaults to: nil) —

    Only return Data Integrations with this ownership: user for the integrations users connect their own accounts to, or organization for the roots organizations connect to. Omit to return both.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/workos/pipes.rb', line 21

def list_data_integrations(
  before: nil,
  after: nil,
  limit: 10,
  order: "desc",
  ownership: nil,
  request_options: {}
)
  params = {
    "before" => before,
    "after" => after,
    "limit" => limit,
    "order" => order,
    "ownership" => ownership
  }.compact
  response = @client.request(
    method: :get,
    path: "/data-integrations",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list_data_integrations(
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      ownership: ownership,
      request_options: request_options
    )
  }
  WorkOS::Types::ListStruct.from_response(
    response,
    model: WorkOS::DataIntegration,
    filters: {before: before, limit: limit, order: order, ownership: ownership},
    fetch_next: fetch_next
  )
end

#list_organization_data_providers(organization_id:, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse

List providers for an organization

Parameters:

  • organization_id (String) —

    An Organization identifier to list providers and connected accounts for.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
# File 'lib/workos/pipes.rb', line 782

def list_organization_data_providers(
  organization_id:,
  supports_multiple_connections: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  response = @client.request(
    method: :get,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/data_providers",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationsListResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list_user_data_providers(user_id:, organization_id: nil, supports_multiple_connections: nil, request_options: {}) ⇒ WorkOS::DataIntegrationsListResponse

List providers for a user

Parameters:

  • user_id (String) —

    A User identifier to list providers and connected accounts for.

  • organization_id (String, nil) (defaults to: nil) —

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

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Set to true to use the plural connection contract. When omitted or false, only the compatibility connection is considered.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
# File 'lib/workos/pipes.rb', line 986

def list_user_data_providers(
  user_id:,
  organization_id: nil,
  supports_multiple_connections: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections
  }.compact
  response = @client.request(
    method: :get,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/data_providers",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = WorkOS::DataIntegrationsListResponse.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration(slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration

Update a data integration

Parameters:

  • slug (String) —

    The slug identifier of the data integration.

  • description (String, nil) (defaults to: WorkOS::OMIT) —

    An optional description of the Data Integration.

  • enabled (Boolean, nil) (defaults to: nil) —

    Whether the Data Integration is enabled.

  • scopes (Array<String>, nil) (defaults to: WorkOS::OMIT) —

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

  • credentials (WorkOS::DataIntegrationCredentialsInput, nil) (defaults to: nil) —

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

  • api_key (WorkOS::ApiKeyInstallation, nil) (defaults to: nil) —

    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).

  • custom_provider (WorkOS::UpdateCustomProviderDefinition, nil) (defaults to: nil) —

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

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/workos/pipes.rb', line 169

def update_data_integration(
  slug:,
  description: WorkOS::OMIT,
  enabled: nil,
  scopes: WorkOS::OMIT,
  credentials: nil,
  api_key: nil,
  custom_provider: nil,
  request_options: {}
)
  body = {
    "enabled" => enabled,
    "credentials" => credentials,
    "api_key" => api_key,
    "custom_provider" => custom_provider
  }.compact
  body["description"] = description unless description.equal?(WorkOS::OMIT)
  body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration_api_key(slug:, user_id:, secret:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, organization_id: nil, connection_owner: nil, connection_intent: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Upsert an API key for a connected account

Parameters:

  • slug (String) —

    The identifier of the integration.

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested provider account identifier, never inferred from a label or credential. Omit to preserve an existing identifier; null clears it.

  • user_id (String) —

    A User identifier.

  • organization_id (String, nil) (defaults to: nil) —

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connection_owner (WorkOS::Types::DataIntegrationsUpsertApiKeyRequestConnectionOwner, nil) (defaults to: nil) —

    Whose connection to create or rotate. user (the default) addresses the connection owned by user_id. organization addresses the connection shared by every member of organization_id; user_id then identifies the member performing the request and must be an active member of the organization.

  • secret (String) —

    The API key secret to store for this integration.

  • connection_intent (String, nil) (defaults to: nil) —

    Send reauthorize with connected_account_id to reauthorize one exact connection. Omit it to use the compatibility connection; creating another connection lives on the POST route.

  • connected_account_id (String, nil) (defaults to: nil) —

    The exact connected account to reauthorize. Required with connection_intent: reauthorize; it may also be sent on its own to reauthorize that connection.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/workos/pipes.rb', line 271

def update_data_integration_api_key(
  slug:,
  user_id:,
  secret:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  organization_id: nil,
  connection_owner: nil,
  connection_intent: nil,
  connected_account_id: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connection_owner" => connection_owner,
    "secret" => secret,
    "connection_intent" => connection_intent,
    "connected_account_id" => 
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/api-key",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration_client_credentials(slug:, user_id:, client_id:, client_secret:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, organization_id: nil, connection_owner: nil, config: nil, connection_intent: nil, connected_account_id: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Upsert client credentials for a connected account

Parameters:

  • slug (String) —

    The identifier of the integration.

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested provider account identifier, never inferred from a label or credential. Omit to preserve an existing identifier; null clears it.

  • user_id (String) —

    A User identifier.

  • organization_id (String, nil) (defaults to: nil) —

    An Organization identifier. Optional parameter to scope the connection to a specific organization. Required when connection_owner is organization.

  • connection_owner (WorkOS::Types::DataIntegrationsUpsertClientCredentialsRequestConnectionOwner, nil) (defaults to: nil) —

    Whose connection to create or rotate. user (the default) addresses the connection owned by user_id. organization addresses the connection shared by every member of organization_id; user_id then identifies the member performing the request and must be an active member of the organization.

  • client_id (String) —

    The OAuth client ID to store for this integration.

  • client_secret (String) —

    The OAuth client secret to store for this integration.

  • config (Hash{String => String}, nil) (defaults to: nil) —

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

  • connection_intent (String, nil) (defaults to: nil) —

    Send reauthorize with connected_account_id to reauthorize one exact connection. Omit it to use the compatibility connection; creating another connection lives on the POST route.

  • connected_account_id (String, nil) (defaults to: nil) —

    The exact connected account to reauthorize. Required with connection_intent: reauthorize; it may also be sent on its own to reauthorize that connection.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/workos/pipes.rb', line 420

def update_data_integration_client_credentials(
  slug:,
  user_id:,
  client_id:,
  client_secret:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  organization_id: nil,
  connection_owner: nil,
  config: nil,
  connection_intent: nil,
  connected_account_id: nil,
  request_options: {}
)
  body = {
    "user_id" => user_id,
    "organization_id" => organization_id,
    "connection_owner" => connection_owner,
    "client_id" => client_id,
    "client_secret" => client_secret,
    "config" => config,
    "connection_intent" => connection_intent,
    "connected_account_id" => 
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/client-credentials",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_data_integration_organization(slug:, description: WorkOS::OMIT, enabled: nil, scopes: WorkOS::OMIT, credentials: nil, api_key: nil, custom_provider: nil, request_options: {}) ⇒ WorkOS::DataIntegration

Update an organization-owned data integration

Parameters:

  • slug (String) —

    The slug identifier of the data integration.

  • description (String, nil) (defaults to: WorkOS::OMIT) —

    An optional description of the Data Integration.

  • enabled (Boolean, nil) (defaults to: nil) —

    Whether the Data Integration is enabled.

  • scopes (Array<String>, nil) (defaults to: WorkOS::OMIT) —

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

  • credentials (WorkOS::DataIntegrationCredentialsInput, nil) (defaults to: nil) —

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

  • api_key (WorkOS::ApiKeyInstallation, nil) (defaults to: nil) —

    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).

  • custom_provider (WorkOS::UpdateCustomProviderDefinition, nil) (defaults to: nil) —

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

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/workos/pipes.rb', line 524

def update_data_integration_organization(
  slug:,
  description: WorkOS::OMIT,
  enabled: nil,
  scopes: WorkOS::OMIT,
  credentials: nil,
  api_key: nil,
  custom_provider: nil,
  request_options: {}
)
  body = {
    "enabled" => enabled,
    "credentials" => credentials,
    "api_key" => api_key,
    "custom_provider" => custom_provider
  }.compact
  body["description"] = description unless description.equal?(WorkOS::OMIT)
  body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = WorkOS::DataIntegration.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_organization_connected_account(organization_id:, slug:, user_id:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, supports_multiple_connections: nil, connected_account_id: nil, connection_intent: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Update an organization connected account

Parameters:

  • organization_id (String) —

    An Organization identifier.

  • slug (String) —

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

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique connection label; null clears it. Not an account identifier.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested account identifier; null clears it.

  • access_token (String, nil) (defaults to: nil) —

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil) —

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil) —

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

  • scopes (Array<String>, nil) (defaults to: nil) —

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::OrganizationConnectedAccountState, nil) (defaults to: nil) —

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

  • user_id (String) —

    The User identifier of the organization member on whose behalf the connected account is being imported or updated. The user must be an active member of the organization.

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Accepted for compatibility; does not change update targeting. Omit intent and selector to update the compatibility connection, or supply connected_account_id to update an exact connection.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select the connection to update.

  • connection_intent (String, nil) (defaults to: nil) —

    Set to reauthorize with connected_account_id to update one exact connection. The intent may be omitted when supplying an ID. Omit both for permanent compatibility behavior.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# File 'lib/workos/pipes.rb', line 705

def (
  organization_id:,
  slug:,
  user_id:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  connection_intent: nil,
  request_options: {}
)
  params = {
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => ,
    "connection_intent" => connection_intent
  }.compact
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state,
    "user_id" => user_id
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#update_user_connected_account(user_id:, slug:, account_display_name: WorkOS::OMIT, account_identifier: WorkOS::OMIT, access_token: nil, refresh_token: nil, expires_at: nil, scopes: nil, state: nil, organization_id: nil, supports_multiple_connections: nil, connected_account_id: nil, connection_intent: nil, request_options: {}) ⇒ WorkOS::ConnectedAccount

Update a connected account

Parameters:

  • user_id (String) —

    A User identifier.

  • slug (String) —

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

  • account_display_name (String, nil) (defaults to: WorkOS::OMIT) —

    A mutable, non-unique connection label; null clears it. Not an account identifier.

  • account_identifier (String, nil) (defaults to: WorkOS::OMIT) —

    A developer-attested account identifier; null clears it.

  • access_token (String, nil) (defaults to: nil) —

    The OAuth access token for the connected account.

  • refresh_token (String, nil) (defaults to: nil) —

    The OAuth refresh token for the connected account.

  • expires_at (String, nil) (defaults to: nil) —

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

  • scopes (Array<String>, nil) (defaults to: nil) —

    The OAuth scopes granted for this connection.

  • state (WorkOS::Types::ConnectedAccountInputState, nil) (defaults to: nil) —

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

  • organization_id (String, nil) (defaults to: nil) —

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

  • supports_multiple_connections (Boolean, nil) (defaults to: nil) —

    Accepted for compatibility; does not change update targeting. Omit intent and selector to update the compatibility connection, or supply connected_account_id to update an exact connection.

  • connected_account_id (String, nil) (defaults to: nil) —

    A connected account identifier. Use this to select the connection to update.

  • connection_intent (String, nil) (defaults to: nil) —

    Set to reauthorize with connected_account_id to update one exact connection. The intent may be omitted when supplying an ID. Omit both for permanent compatibility behavior.

  • request_options (Hash) (defaults to: {}) —

    (see WorkOS::Types::RequestOptions)

Returns:



905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
# File 'lib/workos/pipes.rb', line 905

def (
  user_id:,
  slug:,
  account_display_name: WorkOS::OMIT,
  account_identifier: WorkOS::OMIT,
  access_token: nil,
  refresh_token: nil,
  expires_at: nil,
  scopes: nil,
  state: nil,
  organization_id: nil,
  supports_multiple_connections: nil,
  connected_account_id: nil,
  connection_intent: nil,
  request_options: {}
)
  params = {
    "organization_id" => organization_id,
    "supports_multiple_connections" => supports_multiple_connections,
    "connected_account_id" => ,
    "connection_intent" => connection_intent
  }.compact
  body = {
    "access_token" => access_token,
    "refresh_token" => refresh_token,
    "expires_at" => expires_at,
    "scopes" => scopes,
    "state" => state
  }.compact
  body["account_display_name"] =  unless .equal?(WorkOS::OMIT)
  body["account_identifier"] =  unless .equal?(WorkOS::OMIT)
  response = @client.request(
    method: :put,
    path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = WorkOS::ConnectedAccount.new(response.body)
  result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end