Connections
Manage environment-level AgentKit connections with scalekit_client.connection
scalekit_client.connection manages the environment-level connections that AgentKit connectors run on. A connection holds the OAuth app credentials, scopes, and redirect URI Scalekit uses when your users authorize a connector, and one connection serves every user in that environment.
Common path: create the connection once → attach OAuth credentials with update_environment_connection → connect end-user accounts with scalekit_client.actions → run tools.
Most teams create connections in the Scalekit Dashboard — see Configure a connection. Use these methods when you provision or manage environments in code, such as seeding a new environment from a setup script or CI job.
These methods cover environment-level app connections (Flags(is_app=True)). Organization-scoped SSO connection APIs stay on the SaaSKit connection reference.
create_environment_connection
Section titled “create_environment_connection”#create_environment_connection
Creates a new environment-level connection. Pass Flags(is_app=True) to register it as an app connection that AgentKit connectors can use.
CreateConnection object with the provider key and connection type.
Optional. Connection flags (is_login, is_app).
Create Connection Response
from scalekit.v1.connections.connections_pb2 import ( CreateConnection, ConnectionType, Flags)
# Register the connection at the environment level. is_app=True marks it as an# app connection, which is what AgentKit connectors resolve against.response = scalekit_client.connection.create_environment_connection( connection=CreateConnection( provider_key='HUBSPOT', type=ConnectionType.OAUTH, ), flags=Flags(is_app=True),)connection = response[0].connectionprint(f"Created: {connection.id}, Key: {connection.key_id}")list_app_connections
Section titled “list_app_connections”#list_app_connections
Lists environment-level app connections. Filter by provider or search by connection name (key ID) or provider.
Results per page (max 30).
Optional. Token for pagination.
Optional. Filter by provider (e.g. HUBSPOT).
Optional. Free-text search on connection name (key ID) or provider (3–100 characters).
List App Connections Response
response = scalekit_client.connection.list_app_connections()
for conn in response[0].connections: print(f"Connection: {conn.id}, Provider: {conn.provider_key}")
# Filter by providerresponse = scalekit_client.connection.list_app_connections( provider='HUBSPOT', page_size=10,)
# Search by connection name or providerresponse = scalekit_client.connection.list_app_connections(query='hubspot')get_environment_connection
Section titled “get_environment_connection”#get_environment_connection
Returns an environment-level connection by its id.
Connection id to retrieve.
Get Connection Response
response = scalekit_client.connection.get_environment_connection('conn_123456')conn = response[0].connectionprint(f"Provider: {conn.provider_key}, Type: {conn.type}, Key: {conn.key_id}")update_environment_connection
Section titled “update_environment_connection”#update_environment_connection
Updates an environment-level connection. Use this after create to attach your own OAuth app credentials so users see your brand on the consent screen.
Connection id to update.
UpdateConnection object with fields to update.
Update Connection Response
import osfrom scalekit.v1.connections.connections_pb2 import ( UpdateConnection, ConnectionType, OAuthConnectionConfig)
# Read credentials from the environment: a hard-coded client secret leaks to# anyone with repository access and lets them impersonate your app with the# provider.response = scalekit_client.connection.update_environment_connection( connection_id='conn_123456', connection=UpdateConnection( provider_key='HUBSPOT', key_id='hubspot-key', type=ConnectionType.OAUTH, oauth_config=OAuthConnectionConfig( client_id={'value': os.environ['HUBSPOT_CLIENT_ID']}, client_secret={'value': os.environ['HUBSPOT_CLIENT_SECRET']}, ), ),)conn = response[0].connectionprint(f"Updated: {conn.id}")Next steps
Section titled “Next steps”- Connected accounts — connect end-user accounts and run tools on their behalf
- Configure a connection — create connections in the Scalekit Dashboard