scalekit.actions is the primary interface for AgentKit. It handles connected account management, tool execution, and proxied API calls. scalekit.tools exposes raw tool schemas for building custom adapters.
npm install @scalekit-sdk/node
import { ScalekitClient } from ' @scalekit-sdk/node ' ;
const scalekit = new ScalekitClient ({
clientId : process . env . SCALEKIT_CLIENT_ID ! ,
clientSecret : process . env . SCALEKIT_CLIENT_SECRET ! ,
envUrl : process . env . SCALEKIT_ENV_URL ! ,
Generates a time-limited OAuth magic link to authorize a user’s connection.
Input schema
connectionName string optional Connector slug (e.g. gmail)
identifier string optional User's identifier (e.g. email)
connectedAccountId string optional Direct connected account ID (ca_...)
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
state string optional Opaque value passed through to the redirect URL
userVerifyUrl string optional Your app's redirect URL for user verification
Response schema GetMagicLinkForConnectedAccountResponse
link string OAuth magic link URL. Redirect the user here to start the authorization flow.
const { link } = await scalekit . actions . getAuthorizationLink ({
identifier : ' user@example.com ' ,
userVerifyUrl : ' https://your-app.com/verify ' ,
// Redirect the user to link
Verifies the user after OAuth callback. Call this from your redirect URL handler.
Input schema
authRequestId string required Token from the redirect URL query params
identifier string required Current user's identifier
Response schema VerifyConnectedAccountUserResponse
postUserVerifyRedirectUrl string URL to redirect the user to after successful verification
await scalekit . actions . verifyConnectedAccountUser ({
authRequestId : req . query . auth_request_id as string ,
identifier : ' user@example.com ' ,
Fetches an existing connected account or creates one if none exists. Use this as the default when setting up a user.
Input schema
connectionName string required Connector slug
identifier string required User's identifier
authorizationDetails object optional OAuth token or static auth details
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
apiConfig Record<string, unknown> optional Connector-specific options (for example scopes or static auth fields)
Response schema CreateConnectedAccountResponse
connectedAccount.id string Account ID (ca_...)
connectedAccount.identifier string User's identifier
connectedAccount.provider string Provider slug
connectedAccount.status string ACTIVE, INACTIVE, or PENDING
connectedAccount.authorizationType string OAuth, API_KEY, etc.
connectedAccount.tokenExpiresAt string ISO 8601 OAuth token expiry
const { connectedAccount } = await scalekit . actions . getOrCreateConnectedAccount ({
identifier : ' user@example.com ' ,
console . log ( connectedAccount . id ) ;
Fetches auth details for a connected account. Returns sensitive credentials. Protect access to this method.
Requires connectedAccountId or connectionName + identifier.
Input schema
connectionName string optional Connector slug. Use with identifier when you do not pass connectedAccountId.
identifier string optional End-user or workspace identifier. Use with connectionName.
connectedAccountId string optional Connected account ID (ca_...) when resolving by ID instead of name + identifier
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
Response schema GetConnectedAccountByIdentifierResponse
connectedAccount.id string Account ID (ca_...)
connectedAccount.identifier string User's identifier
connectedAccount.provider string Provider slug
connectedAccount.status string ACTIVE, INACTIVE, or PENDING
connectedAccount.authorizationType string OAuth, API_KEY, etc.
connectedAccount.authorizationDetails object Credential payload (access token, API key, etc.)
connectedAccount.tokenExpiresAt string ISO 8601 OAuth token expiry
connectedAccount.lastUsedAt string Last time this account was used
connectedAccount.updatedAt string Last update timestamp
Input schema
connectionName string optional Filter by connector
identifier string optional Filter by user identifier
provider string optional Filter by provider
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
pageSize number optional Maximum accounts per page (server default if omitted)
pageToken string optional Opaque cursor from a previous list response
query string optional Free-text search
Response schema ListConnectedAccountsResponse
connectedAccounts array List of ConnectedAccountForList objects (excludes authorizationDetails)
totalSize number Total number of matching accounts
nextPageToken string Token for the next page, if any
prevPageToken string Token for the previous page, if any
Creates a connected account with explicit auth details.
Input schema
connectionName string required Connector slug. Must match a connection configured in your environment.
identifier string required Stable ID for this end user or workspace (email, user_id, or custom string)
authorizationDetails object required OAuth token payload, API key, or other credentials for this connector
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
apiConfig Record<string, unknown> optional Connector-specific options (for example scopes or static auth fields)
Returns CreateConnectedAccountResponse. Same shape as getOrCreateConnectedAccount.
Requires connectedAccountId or connectionName + identifier.
Input schema
connectionName string optional Connector slug. Use with identifier when you do not pass connectedAccountId.
identifier string optional End-user or workspace identifier. Use with connectionName.
connectedAccountId string optional Connected account ID (ca_...) when updating by ID instead of name + identifier
authorizationDetails object optional Replace or merge stored credentials (OAuth tokens, API keys, etc.)
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
apiConfig object optional Connector-specific configuration to persist on the account
Returns UpdateConnectedAccountResponse.
Deletes a connected account and revokes its credentials. Requires connectedAccountId or connectionName + identifier.
Input schema
connectionName string optional Connector slug. Use with identifier when you do not pass connectedAccountId.
identifier string optional End-user or workspace identifier. Use with connectionName.
connectedAccountId string optional Connected account ID (ca_...) when deleting by ID instead of name + identifier
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
Returns DeleteConnectedAccountResponse.
Executes a named tool via Scalekit.
Input schema
toolName string required Tool name (e.g. gmail_fetch_emails)
toolInput Record<string, unknown> required Parameters the tool expects
identifier string optional User's identifier
connectedAccountId string optional Direct connected account ID
connector string optional Connector slug
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
Response schema ExecuteToolResponse
data object Tool's structured output
executionId string Unique ID for this execution
const result = await scalekit . actions . executeTool ({
toolName : ' gmail_fetch_emails ' ,
toolInput : { maxResults : 5 , label : ' UNREAD ' } ,
identifier : ' user@example.com ' ,
const emails = result . data ;
Makes a REST API call on behalf of a connected account. Scalekit injects the user’s OAuth token automatically.
Input schema
connectionName string required Connector slug
identifier string required User's identifier
path string required API path (e.g. /gmail/v1/users/me/messages)
method string optional HTTP method. Default: GET
queryParams Record<string, unknown> optional URL query parameters appended to path
body unknown optional JSON-serializable body for POST, PUT, PATCH, or similar methods
formData Record<string, unknown> optional Multipart form fields when the upstream API expects form data instead of JSON
headers Record<string, string> optional Extra HTTP headers merged with Scalekit-injected auth headers
timeoutMs number optional Default: 30000
Returns AxiosResponse. Use .data, .status, and standard Axios response attributes.
const response = await scalekit . actions . request ({
identifier : ' user@example.com ' ,
path : ' /gmail/v1/users/me/messages ' ,
queryParams : { maxResults : 5 , q : ' is:unread ' } ,
const messages = response . data . messages ;
scalekit.tools gives access to raw tool schemas. Use this when building a custom framework adapter or passing schemas directly to an LLM API (e.g. Anthropic, OpenAI).
Lists all tools available in your workspace.
Input schema
filter Filter optional Filter by provider, identifier, or tool name
pageSize number optional Maximum tools per page (server default if omitted)
pageToken string optional Opaque cursor from a previous list response
Response schema ListToolsResponse
tools array List of tool schemas (name, description, input schema)
nextPageToken string Token for the next page, if any
Lists tools scoped to a specific user. Use this to fetch per-user tool schemas to pass to an LLM API.
Input schema
identifier string required User's connected account identifier
filter ScopedToolFilter optional Filter by providers, tool names, or connection names
pageSize number optional Maximum tools per page (server default if omitted)
pageToken string optional Opaque cursor from a previous list response
Response schema ListScopedToolsResponse
tools array List of tool schemas
tools[].name string Tool name
tools[].description string Tool description
tools[].inputSchema object JSON Schema for tool inputs. Pass directly to LLM API.
nextPageToken string Token for the next page, if any
const { tools } = await scalekit . tools . listScopedTools ( ' user@example.com ' , {
filter : { connectionNames : [ ' gmail ' ] } ,
// Pass tools to your LLM's tool call API
Lists tools available for a given identifier. These tools can be activated but may not yet be scoped to the user.
Input schema
identifier string required User's connected account identifier
pageSize number optional Maximum tools per page (server default if omitted)
pageToken string optional Opaque cursor from a previous list response
Response schema ListAvailableToolsResponse
tools array List of available tool schemas
nextPageToken string Token for the next page, if any
Low-level tool execution. Prefer scalekit.actions.executeTool for most use cases.
Input schema
toolName string required Registered tool name to execute
identifier string optional End-user or workspace identifier used to resolve the connected account
params Record<string, unknown> optional Tool arguments matching the tool input schema
connectedAccountId string optional Connected account ID (ca_...) when you already know it
connector string optional Connector slug when the tool name exists on more than one connector
organizationId string optional Organization tenant ID when your app scopes auth and accounts by org
userId string optional Your application user ID when you map Scalekit accounts to internal users
Returns ExecuteToolResponse. Same shape as scalekit.actions.executeTool.
ScalekitNotFoundException ,
} from ' @scalekit-sdk/node ' ;
const account = await scalekit . actions . getConnectedAccount ({
identifier : ' user@example.com ' ,
if ( err instanceof ScalekitNotFoundException ) {
// Account does not exist: create it or redirect to auth
} else if ( err instanceof ScalekitServerException ) {
// Network or server error
Exception When raised ScalekitNotFoundExceptionResource not found ScalekitUnauthorizedExceptionInvalid credentials ScalekitForbiddenExceptionInsufficient permissions ScalekitServerExceptionBase class for all server errors