Skip to main content
The disconnect method defines what happens when a connection is disconnected. Use it to revoke access tokens or perform other cleanup with the external service before credentials are erased from storage. This method is triggered when:
  • A connection is explicitly disconnected (via the API or the console UI)
  • A connection is archived
This method is optional. If not implemented, the connection will simply have its credentials erased without notifying the external service.

Implementation

Supported implementation types

JavaScript Implementation

# Connector definition: Revoke the access token when disconnecting
disconnect:
  type: javascript
  code: |
    export default async function disconnect({
      externalApiClient,
      credentials,
    }) {
      await externalApiClient.post('/oauth/revoke', {
        token: credentials.access_token,
      })
    }

Input Parameters

ParameterDescription
connectorParametersParameters configured for the connector in your workspace. Includes client IDs, secrets, and other connector-specific configuration.
connectionInputInput provided by the user in the connection UI when they set up the connection.
credentialsCurrent credentials of the connection that will be erased after this method completes.
externalApiClientAPI client for making requests to the external service (available if makeApiClient is defined on the connector).

Return Value

The return value is ignored. The method is expected to perform side effects only (e.g., revoking tokens).

Error Handling

If the disconnect method throws an error, the disconnection process will still continue — credentials will be erased and the connection will be marked as disconnected. The error will be logged but will not prevent the disconnection. This ensures that connections can always be cleanly disconnected even if the external service is unavailable.

Supported Auth Types

The disconnect method is available for the following authentication types: