Python SDK
Installation
Section titled “Installation”pip install authpipeRequires Python 3.10+. Uses httpx for HTTP and pydantic for types.
Configuration
Section titled “Configuration”Sync client
Section titled “Sync client”from authpipe import Authpipe
client = Authpipe( api_key="sk_...", base_url="https://api.authpipe.dev", # optional api_version="2026-04-07", # optional cache=True, # optional (default True) cache_ttl_seconds=300, # optional (default 300))Async client
Section titled “Async client”from authpipe import AsyncAuthpipe
client = AsyncAuthpipe(api_key="sk_...")Both clients support context managers:
# Syncwith Authpipe(api_key="sk_...") as client: result = client.get_credential(provider="slack", tenant_id="org_acme")
# Asyncasync with AsyncAuthpipe(api_key="sk_...") as client: result = await client.get_credential(provider="slack", tenant_id="org_acme")| Option | Type | Default | Description |
|---|---|---|---|
api_key | str | — | Secret or publishable API key (required) |
base_url | str | https://api.authpipe.dev | API base URL |
api_version | str | None | None | API version header |
cache | bool | True | Enable credential caching |
cache_ttl_seconds | int | 300 | Cache TTL in seconds |
Credentials
Section titled “Credentials”get_credential
Section titled “get_credential”All parameters are keyword-only.
result = client.get_credential( provider="slack", tenant_id="org_acme", user_id="user_jane", # optional installation_id="inst_123", # optional credential_for="any", # optional: "any", "installation", "user")
result.credential # str — access token or API keyresult.credential_type # str — "oauth_token", "api_key", etc.result.source # str — "connection" or "installation"result.expires_at # datetime | Noneresult.scopes # list[str] | NoneAsync:
result = await client.get_credential(provider="slack", tenant_id="org_acme")store_credential
Section titled “store_credential”result = client.store_credential( provider="sendgrid", tenant_id="org_acme", credential_type="api_key", # "api_key" or "webhook_secret" credential="SG.xxxx", user_id="user_jane", # optional installation_id="inst_123", # optional)
result.connection_id # strresult.status # strOAuth Sessions
Section titled “OAuth Sessions”create_auth_session
Section titled “create_auth_session”session = client.create_auth_session( provider="google", tenant_id="org_acme", redirect_url="https://yourapp.com/callback", user_id="user_jane", # optional scopes=["drive.readonly"], # optional installation_id="inst_123", # optional template_variables={"shop": "acme-store"}, # optional)
session.session_id # strsession.authorization_url # str — redirect the user herecreate_install_session
Section titled “create_install_session”session = client.create_install_session( provider="slack", tenant_id="org_acme", redirect_url="https://yourapp.com/installed", user_id="user_admin", # optional permissions=["channels:read", "chat:write"], # optional)Connections
Section titled “Connections”get_connection
Section titled “get_connection”conn = client.get_connection(connection_id="conn_abc123")delete_connection
Section titled “delete_connection”client.delete_connection(connection_id="conn_abc123")refresh_connection
Section titled “refresh_connection”result = client.refresh_connection(connection_id="conn_abc123")result.refreshed # boolresult.expires_at # datetime | Nonesearch_connections
Section titled “search_connections”from authpipe.types import SearchRequest, SortDirective
resp = client.search_connections(SearchRequest( filter={"tenant_id": {"eq": "org_acme"}, "status": {"eq": "active"}}, sort=[SortDirective(field="connected_at", direction="desc")], cursor="cursor_token", limit=25,))
resp.data # list[Connection]resp.has_more # boolresp.next_cursor # str | Noneresp.limit # intInstallations
Section titled “Installations”get_installation
Section titled “get_installation”inst = client.get_installation(installation_id="inst_abc123")delete_installation
Section titled “delete_installation”client.delete_installation(installation_id="inst_abc123")search_installations
Section titled “search_installations”resp = client.search_installations(SearchRequest( filter={"tenant_id": {"eq": "org_acme"}},))Provider Configs
Section titled “Provider Configs”create_provider_config
Section titled “create_provider_config”config = client.create_provider_config( provider_id="slack", client_id="your-client-id", client_secret="your-client-secret", oauth_redirect_url="https://api.authpipe.dev/oauth/callback", attachment="user", enabled=True, scopes=["channels:read"],)get_provider_config
Section titled “get_provider_config”config = client.get_provider_config(config_id="pcfg_abc123")update_provider_config
Section titled “update_provider_config”config = client.update_provider_config( config_id="pcfg_abc123", client_secret="new-secret", scopes=["channels:read", "chat:write"], bot_scopes=["chat:write"], signing_key="signing-secret", enabled=True,)delete_provider_config
Section titled “delete_provider_config”client.delete_provider_config(config_id="pcfg_abc123")search_provider_configs
Section titled “search_provider_configs”resp = client.search_provider_configs(SearchRequest( filter={"provider_id": {"eq": "slack"}},))Providers (Catalog)
Section titled “Providers (Catalog)”get_provider
Section titled “get_provider”provider = client.get_provider(provider_id="slack")search_providers
Section titled “search_providers”resp = client.search_providers(SearchRequest( query="email", filter={"category": {"eq": "communication"}}, limit=10,))Custom Providers
Section titled “Custom Providers”create_custom_provider
Section titled “create_custom_provider”provider = client.create_custom_provider( id="my-internal-api", name="My Internal API", auth_api_key={"key_field": "x-api-key"},)get_custom_provider
Section titled “get_custom_provider”provider = client.get_custom_provider(custom_provider_id="my-internal-api")update_custom_provider
Section titled “update_custom_provider”provider = client.update_custom_provider( custom_provider_id="my-internal-api", name="Updated Name",)delete_custom_provider
Section titled “delete_custom_provider”client.delete_custom_provider(custom_provider_id="my-internal-api")Events
Section titled “Events”search_events
Section titled “search_events”resp = client.search_events(SearchRequest( filter={"event_type": {"eq": "connection.created"}}, sort=[SortDirective(field="created_at", direction="desc")], limit=50,))API Keys
Section titled “API Keys”list_api_keys
Section titled “list_api_keys”keys = client.list_api_keys() # list[APIKey]create_api_key
Section titled “create_api_key”result = client.create_api_key(name="Production", role="secret")result.id # strresult.key # str (only returned once)revoke_api_key
Section titled “revoke_api_key”client.revoke_api_key(api_key_id="key_abc123")Webhook Config
Section titled “Webhook Config”get_webhook_config
Section titled “get_webhook_config”config = client.get_webhook_config()config.webhook_url # strconfig.has_secret_1 # boolconfig.has_secret_2 # boolset_webhook_config
Section titled “set_webhook_config”result = client.set_webhook_config(webhook_url="https://yourapp.com/webhooks")result.webhook_url # strresult.secret # str (save this)rotate_webhook_secret
Section titled “rotate_webhook_secret”result = client.rotate_webhook_secret()result.secret # new secretdelete_webhook_config
Section titled “delete_webhook_config”client.delete_webhook_config()Workspaces
Section titled “Workspaces”get_workspace
Section titled “get_workspace”ws = client.get_workspace(workspace_id="ws_abc123")update_workspace
Section titled “update_workspace”ws = client.update_workspace(workspace_id="ws_abc123", name="New Name")Error handling
Section titled “Error handling”The SDK raises AuthpipeAPIError for HTTP errors:
from authpipe.errors import AuthpipeAPIError
try: result = client.get_credential(provider="slack", tenant_id="org_acme")except AuthpipeAPIError as e: print(e.status_code) # HTTP status print(e.code) # Error code print(e.message) # Human-readable messageAutomatic retry on 429 and 5xx with exponential backoff (up to 3 attempts).
Pydantic types
Section titled “Pydantic types”All response types are Pydantic BaseModel subclasses:
from authpipe.types import ( GetCredentialResult, StoreCredentialResult, CreateAuthSessionResult, Connection, Installation, ProviderConfig, Provider, SearchRequest, SearchResponse, SortDirective,)