Skip to content
SegmentStream/ Docs

Loading documentation…

↑ ↓ to navigate  ↵ to open  Esc to close
Website Console
Section menu
SDKsPython

Connections SDK

segmentstream-connections

Getting started

Declare managed providers and custom API connections in Python.

Install
pip install segmentstream-connections

Public exports

AirwallexConnection

Airwallex API access with a client ID and API key. Declare a stable key, deploy, then paste the client ID and an API key from the Airwallex web app > Settings > Developer > API keys; prefer a scoped API key with Read permissions only. The backend logs in at ``/api/v1/authentication/login`` with the two values on the ``x-client-id`` and ``x-api-key`` headers, renews the 30-minute token before it expires and sends it as ``Authorization: Bearer <token>``; neither the values nor the token reach pipeline code. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.airwallex.com/api/v1/``, such as ``balances/current``. Airwallex's sandbox needs a `ClientCredentialsConnection` declaring its own hosts; see docs/connections.md.

class AirwallexConnection(_ClientCredentialsPreset):
    name: str = 'Airwallex'
    provider: str = 'airwallex'
    token_url: str = AIRWALLEX_LOGIN_URL
    client_id: SecretReference = Field(default_factory=lambda: Secret(label='Client ID', description='From the Airwallex web app > Settings > Developer > API keys.'))
    client_secret: SecretReference = Field(default_factory=lambda: Secret(label='API key', description='From the Airwallex web app > Settings > Developer > API keys; a scoped API key with Read permissions only is safest.'))
    client_authentication: Literal['client_secret_basic', 'client_secret_post', 'client_secret_headers'] = 'client_secret_headers'
    client_id_header: str | None = 'x-client-id'
    client_secret_header: str | None = 'x-api-key'
    apis: dict[str, str] = Field(default_factory=lambda: {'api': AIRWALLEX_API})
ApiKeyConnection

HTTP access authenticated by static values, such as API keys or tokens. Each entry in `headers` or `query` maps the name the provider expects to a `Secret(...)` configured after deployment, or to `secret_ref(...)` for a shared workspace secret. A value that is not secret, such as an account id, is a `Value(...)`: it is configured the same way, and responses may contain it. The value is sent unchanged; wrap a header's secret in `Bearer(...)` to send ``Bearer <value>``, or in `Scheme("Token", ...)` for another scheme. For providers that read the value from the URL path, `path` maps one segment prefix to its secret: ``path={"bot": Secret()}`` sends ``<api>/bot<value>/<request path>``. The field key is the name in lowercase with hyphens and dots replaced by underscores, for example `Client-Id` -> `client_id`. Set `public=True` for an API with no authentication. Public connections must have no header, query or path credentials and are ready immediately after deployment. A value of `apis` may be an `McpApi` instead of a URL: a remote MCP server reached with the same credentials, limited to the tools it declares. For a provider that signs each request, such as Binance Pay, `signing` declares the headers and query parameters the backend computes for every request; see `segmentstream_connections.signing`. `verification` declares values the provider gives for checking what it sends, such as a webhook signing secret (``whsec_…``) or a registration verify token, named in lowercase with underscores: ``verification={"webhook_signing_secret": Secret(label="Webhook signing secret")}``, or ``uses("api_secret")`` for a secret the connection already holds. Members set them on the connection like its other values, and a webhook that names the connection checks its deliveries against one with ``input``. Only the platform's checks read them: requests never carry them and workspace code never receives them. A connection whose verification values are unset still makes requests. A provider that only sends, such as one whose webhooks have no API behind them, declares verification values alone: no headers, no ``apis``. Such a connection cannot be called, and it is configured once its values are set.

class ApiKeyConnection(HttpApis):
    type: ClassVar[Literal['api_key']] = 'api_key'
    key: str
    name: str
    provider: str
    public: bool = Field(default=False, strict=True)
    read_only: bool = Field(default=False, strict=True)
    headers: Mapping[str, SecretReference | Bearer | Scheme] = Field(default_factory=dict)
    query: Mapping[str, SecretReference] = Field(default_factory=dict)
    path: Mapping[str, SecretReference] = Field(default_factory=dict)
    apis: dict[str, str]
    default_api: str | None = None
    signing: Signing | None = None
    verification: Mapping[str, VerificationValue] = Field(default_factory=dict)
    validate_key(cls, value: str)
    validate_name(cls, value: str)
    validate_provider(cls, value: str)
    validate_headers(cls, value: Mapping[str, SecretReference | Bearer | Scheme])
    validate_query(cls, value: Mapping[str, SecretReference])
    validate_path(cls, value: Mapping[str, SecretReference])
    validate_verification(cls, value: Mapping[str, VerificationValue])
    validate_apis(cls, value: dict[str, str])
    validate_connection(self)
    credentials(self)
ApifyConnection

Apify platform API access with a personal API token. Declare a stable key, deploy, then paste the token from Apify Console > Settings > API & Integrations into the connection. The backend sends it as Apify's ``token`` query parameter; the token never reaches pipeline code or URLs outside the backend. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.apify.com/v2/``, such as ``/actors/{actor}/runs``.

class ApifyConnection(_ApiKeyPreset):
    name: str = 'Apify'
    provider: str = 'apify'
    query: Mapping[str, SecretReference] = Field(default_factory=lambda: {'token': Secret(label='API token', description='From Apify Console > Settings > API & Integrations.')})
    apis: dict[str, str] = Field(default_factory=lambda: {'v2': APIFY_API})
ApolloConnection

Apollo.io API access with an API key. Declare a stable key, deploy, then paste an API key from Apollo > Settings > Integrations > API into the connection. The backend sends it on Apollo's ``x-api-key`` header. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.apollo.io/api/v1/``, such as ``/organizations/enrich``.

class ApolloConnection(_ApiKeyPreset):
    name: str = 'Apollo'
    provider: str = 'apollo'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'x-api-key': Secret(label='API key', description='From Apollo > Settings > Integrations > API.')})
    apis: dict[str, str] = Field(default_factory=lambda: {'v1': APOLLO_API})
Bearer

A header value the backend sends as ``Bearer <value>``. Wrap the `Secret(...)` or `secret_ref(...)` of an `Authorization` header so users configure only the token, for example ``{"Authorization": Bearer(Secret())}``.

class Bearer(BaseModel):
    scheme: ClassVar[str] = 'Bearer'
    secret: SecretReference
    __init__(self, secret: SecretReference, /)
BigQueryConnection

GA4 export query access through a backend-bound service account.

class BigQueryConnection(BaseModel):
    type: ClassVar[Literal['bigquery']] = 'bigquery'
    provider: ClassVar[Literal['bigquery']] = 'bigquery'
    authentication: ClassVar[Literal['service_account_impersonation']] = 'service_account_impersonation'
    key: str
    name: str = 'BigQuery'
    validate_key(cls, value: str)
    validate_name(cls, value: str)
BinancePayConnection

Binance Pay merchant API access with an API key and its secret key. Declare a stable key, deploy, then paste the API key and secret key from the Binance Merchant Admin Portal > Developers > Settings > API keys into the connection. The backend sends the API key as ``BinancePay-Certificate-SN`` and signs each request: the ``BinancePay-Timestamp`` in milliseconds, a 32-character ``BinancePay-Nonce`` and the ``BinancePay-Signature``, the uppercase hex HMAC-SHA512 of the timestamp, nonce and body, each followed by a newline. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://bpay.binanceapi.com/``, such as ``/binancepay/openapi/v3/order``, and send JSON bodies. Binance Pay reports an order's status by calling the order's ``webhookUrl`` with an RSA signature, which webhook triggers do not check: pass the URL of an ontology webhook trigger that names this connection, and query the order through the connection before acting on a delivery.

class BinancePayConnection(_ApiKeyPreset):
    name: str = 'Binance Pay'
    provider: str = 'binance-pay'
    headers: Mapping[str, SecretReference | Bearer | Scheme] = Field(default_factory=lambda: {'BinancePay-Certificate-SN': Secret(label='API key', description='The Binance Pay merchant API key.')})
    apis: dict[str, str] = Field(default_factory=lambda: {'api': BINANCE_PAY_API})
    signing: Signing | None = Field(default_factory=_binance_pay_signing)
BtcPayConnection

BTCPay Server Greenfield API access to one server with an API key. Declare a stable key and the server's public HTTPS address, such as ``https://pay.example.com``. Deploy, then paste an API key created on that server under Account > API keys into the connection; grant it only the store permissions the workspace uses, such as creating and viewing invoices. The backend sends it as ``Authorization: token <key>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``<server>/api/v1/``, such as ``/stores/{store_id}/invoices``.

class BtcPayConnection(ApiKeyConnection):
    name: str = 'BTCPay Server'
    provider: str = 'btcpay'
    server: str
    headers: Mapping[str, SecretReference | Bearer | Scheme] = Field(default_factory=lambda: {'Authorization': Scheme('token', Secret(label='API key', description="From the BTCPay Server's Account > API keys."))})
    derive_server_api(cls, data: Any)
ClientCredentialsConnection

HTTP access with a client ID and secret and no user authorization. Configure the client ID and secret after deployment. The backend exchanges them at `token_url` for short-lived access tokens, renews them before they expire, and sends them as ``Authorization: Bearer <token>``. Neither the values nor the tokens reach pipeline code. By default the exchange is an OAuth 2.0 client-credentials grant that sends the values with HTTP Basic authentication, or in the form body with ``client_authentication="client_secret_post"``. Omit `scopes` to receive the scopes granted to the client. ``client_authentication="client_secret_headers"`` serves token endpoints that take the two values as request headers instead: the backend posts no body, sends the client ID on `client_id_header` and the secret on `client_secret_header`, and reads the token from the response's ``token`` (or ``access_token``) and its expiry from ``expires_at``, an ISO 8601 time (or ``expires_in`` seconds). Such an endpoint is sent no scopes. `token_header` names the header an API takes the token on instead, sent as the bare token, such as Shopify's ``X-Shopify-Access-Token``; the token is then sent on no other header. A value of `apis` may be an `McpApi`: a remote MCP server reached with the same tokens.

class ClientCredentialsConnection(HttpApis):
    type: ClassVar[Literal['client_credentials']] = 'client_credentials'
    key: str
    name: str
    provider: str
    read_only: bool = Field(default=False, strict=True)
    token_url: str
    client_id: SecretReference = Field(default_factory=lambda: Secret(label='Client ID'))
    client_secret: SecretReference = Field(default_factory=lambda: Secret(label='Client secret'))
    scopes: tuple[str, ...] = ()
    client_authentication: Literal['client_secret_basic', 'client_secret_post', 'client_secret_headers'] = 'client_secret_basic'
    client_id_header: str | None = None
    client_secret_header: str | None = None
    token_header: str | None = None
    apis: dict[str, str]
    default_api: str | None = None
    verification: Mapping[str, VerificationValue] = Field(default_factory=dict)
    validate_verification(cls, value: Mapping[str, VerificationValue])
    validate_verification_fields(self)
    validate_token_request_headers(self)
    validate_token_header(cls, value: str | None)
    bind_owned_secrets(self)
    validate_key(cls, value: str)
    validate_name(cls, value: str)
    validate_provider(cls, value: str)
    validate_token_url(cls, value: str)
    validate_scopes(cls, value: object)
    validate_apis(cls, value: dict[str, str])
CloudflareConnection

Cloudflare's API, through Cloudflare's consent page or an API token. Declare a stable key, deploy, then authorize in either way Cloudflare offers: through SegmentStream's Cloudflare OAuth client, on Cloudflare's consent page, where the member chooses the accounts it may reach; or with an API token you supply, a user API token created under My Profile > API Tokens, or an account API token created under Manage Account > Account API Tokens, with the ID of its account (``segmentstream connection authorize KEY --token-file - --account ACCOUNT-ID``). The backend refreshes consent tokens; a supplied token is used until it expires or is revoked in Cloudflare. The consent flow grants the permissions ``scopes`` names, the permissions of API tokens in Cloudflare's names, such as ``dns.read`` or ``workers-scripts.write``: by default ``offline_access``, which keeps the authorization renewing, and the member's details, their accounts and zones, read-only. Name every permission the workspace needs, at most 64, keeping ``offline_access``. Cloudflare grants no billing permission through its consent page, so an account's billing history and invoices need an API token with Billing Read. The client reaches ``https://api.cloudflare.com/client/v4/``, reads and writes: accounts, zones, DNS records, Workers, R2, Access and the rest of Cloudflare's API that an API token may call, with the query parameters and body fields its API reference names, and an account's invoice and receipt PDFs (``/accounts/{account_id}/billing/history``, then ``/accounts/{account_id}/billing/receipts/{id}/pdf?doctype=invoice``). Operations that would hand out a raw credential, pay, or delete the account are never admitted, and credentials in responses, such as Access applications' client secrets, are removed. Set ``read_only=True`` to refuse every write. Set ``application="own"`` to authorize through your own Cloudflare OAuth client instead, created with the client secret sent in the Authorization header (``client_secret_basic``), the redirect URI shown on the connection and the scopes the declaration names: enter its client ID and secret on the connection. Only the consent flow reads them; a token you supply needs neither.

class CloudflareConnection(_ManagedConnection):
    provider: ClassVar[str] = 'cloudflare'
    available_scopes: ClassVar[tuple[str, ...]] = CLOUDFLARE_OAUTH_SCOPES
    default_scopes_selection: ClassVar[tuple[str, ...] | None] = CLOUDFLARE_DEFAULT_SCOPES
    own_application_supported: ClassVar[bool] = True
    name: str = 'Cloudflare'
CoinGateConnection

CoinGate API access with an API auth token. Declare a stable key, deploy, then paste the auth token of an API app created in the CoinGate account into the connection. The backend sends it as ``Authorization: Token <token>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.coingate.com/v2/``, such as ``/orders``. ``sandbox=True`` reaches ``https://api-sandbox.coingate.com/v2/`` instead, which takes only sandbox tokens. CoinGate reports an order's status by calling the order's ``callback_url``: pass the URL of an ontology webhook trigger that names this connection, and read the order back before acting on a delivery, since CoinGate signs nothing.

class CoinGateConnection(_SandboxPreset):
    PRODUCTION_API: ClassVar[str] = 'https://api.coingate.com/v2/'
    SANDBOX_API: ClassVar[str] = 'https://api-sandbox.coingate.com/v2/'
    API_NAME: ClassVar[str] = 'v2'
    name: str = 'CoinGate'
    provider: str = 'coingate'
    headers: Mapping[str, SecretReference | Bearer | Scheme] = Field(default_factory=lambda: {'Authorization': Scheme('Token', Secret(label='API token', description='The auth token of a CoinGate API app.'))})
CoinbaseBusinessConnection

Coinbase Business API access with a CDP API key. Create an API key on the Coinbase Developer Platform with the ECDSA signature algorithm and the scopes the workspace uses, such as View for checkouts and invoices. Declare a stable key, deploy, then paste the key's name (``organizations/{org_id}/apiKeys/{key_id}``) and its private key in PEM into the connection. The backend sends each request with a new ES256 token as ``Authorization: Bearer <token>``, valid for two minutes and bound to the request's method, host and path. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.coinbase.com/``. Read a payment back through the connection before acting on a webhook delivery about it.

class CoinbaseBusinessConnection(_ApiKeyPreset):
    name: str = 'Coinbase Business'
    provider: str = 'coinbase-business'
    apis: dict[str, str] = Field(default_factory=lambda: {'api': COINBASE_API})
    signing: Signing | None = Field(default_factory=_coinbase_signing)
DeelConnection

Deel API access with an Organization API token. Declare a stable key, deploy, then configure the token in the connection. A Deel organization admin creates an Organization token in Developer Center (More > Developer > Access Tokens). Recommended read-only scopes are accounting:read, invoice-adjustments:read and contracts:read. See https://developer.deel.com/api/stable/authentication.md. The backend sends it as ``Authorization: Bearer <token>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.letsdeel.com/rest/``. Check connectivity with GET ``/invoices?limit=1``; this needs only accounting:read.

class DeelConnection(_ApiKeyPreset):
    name: str = 'Deel'
    provider: str = 'deel'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='Organization API token', description='A Deel organization admin creates an Organization token in Developer Center (More > Developer > Access Tokens). Recommended read-only scopes: accounting:read, invoice-adjustments:read and contracts:read.'))})
    apis: dict[str, str] = Field(default_factory=lambda: {'rest': DEEL_API})
EvaluationConnection

Typed evaluations of state against questions, answered with probabilities. Requests use Vercel AI Gateway's evaluation API without a model: SegmentStream chooses the model, so declaring the connection needs no configuration or authorization.

class EvaluationConnection(BaseModel):
    type: ClassVar[Literal['evaluation']] = 'evaluation'
    key: str
    name: str = 'Evaluation'
    validate_key(cls, value: str)
    validate_name(cls, value: str)
GmailConnection

Gmail access to one Google account's mailbox, through your own Google OAuth client. Google admits Gmail's restricted scopes only on internal or verified applications, so the declaration always uses ``application="own"``: after deployment, enter the client ID and secret of a Web application OAuth client and add the redirect URI shown on the connection to it. The client reaches the Gmail API on ``users/me``: messages, threads, attachments, history, labels, drafts, sending and settings. Permanent deletion is not admitted; trash messages instead. By default it requests every scope below, except full mail access; pin ``scopes`` to the ones you use. Access tokens are refreshed by the backend. With ``owner="user"`` each user of the workspace app connects their own mailbox. Such a connection cannot request ``gmail.settings.sharing`` and its default leaves it out: it cannot set up forwarding, delegates, filters, send-as identities, IMAP or POP access, a vacation responder or client-side encryption, which would outlive the user's consent.

class GmailConnection(_ManagedConnection):
    provider: ClassVar[str] = 'gmail'
    available_scopes: ClassVar[tuple[str, ...]] = ('https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/gmail.labels', 'https://www.googleapis.com/auth/gmail.send', 'https://www.googleapis.com/auth/gmail.compose', 'https://www.googleapis.com/auth/gmail.insert', 'https://www.googleapis.com/auth/gmail.modify', 'https://www.googleapis.com/auth/gmail.settings.basic', 'https://www.googleapis.com/auth/gmail.settings.sharing')
    owned_scopes: ClassVar[tuple[str, ...] | None] = tuple((scope for scope in available_scopes if scope != 'https://www.googleapis.com/auth/gmail.settings.sharing'))
    own_application_supported: ClassVar[bool] = True
    segmentstream_application_supported: ClassVar[bool] = False
    name: str = 'Gmail'
    application: Literal['segmentstream', 'own'] = 'own'
GoogleAdsConnection

Google Ads account discovery and GAQL reporting, managed by SegmentStream. Declare a stable key, deploy, then authorize through the UI or CLI. Use ``get_connection(key).get_http_client()`` during execution. OAuth credentials, developer-token injection and refresh are owned by the backend.

class GoogleAdsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'google_ads'
    available_scopes: ClassVar[tuple[str, ...]] = ('https://www.googleapis.com/auth/adwords',)
    name: str = 'Google Ads'
GoogleAnalyticsConnection

Google Analytics 4 reports and property discovery, managed by SegmentStream. One declaration authorizes one Google account, with read access to the GA4 accounts and properties it can open. The default ``data`` API runs reports by property ID: POST ``/properties/{id}:runReport``, ``:runPivotReport``, their batch forms, ``:runRealtimeReport`` and ``:checkCompatibility``, and GET ``/properties/{id}/metadata``. ``api="admin"`` lists account summaries, accounts and properties, and reads a property's data streams, custom dimensions and metrics, key events and Google Ads links. Access tokens are refreshed by the backend. Set ``application="own"`` to authorize through your own Google OAuth client.

class GoogleAnalyticsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'google_analytics'
    available_scopes: ClassVar[tuple[str, ...]] = ('https://www.googleapis.com/auth/analytics.readonly',)
    own_application_supported: ClassVar[bool] = True
    name: str = 'Google Analytics'
GoogleSheetsConnection

Google Sheets read access, managed by SegmentStream. One declaration authorizes one Google account. The client reads spreadsheet metadata and cell values of spreadsheets that account can open, by spreadsheet ID. Pass A1 ranges as the ``ranges`` query parameter. Access tokens are refreshed by the backend. Set ``application="own"`` to authorize through your own Google OAuth client.

class GoogleSheetsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'google_sheets'
    available_scopes: ClassVar[tuple[str, ...]] = ('https://www.googleapis.com/auth/spreadsheets.readonly',)
    own_application_supported: ClassVar[bool] = True
    name: str = 'Google Sheets'
HubSpotConnection

HubSpot CRM read access, managed by SegmentStream. One declaration authorizes one HubSpot account. The client reads contacts, companies and deals with their properties, pipelines, owners and associations. Short-lived access tokens are refreshed by the backend. Set ``application="own"`` to authorize through your own HubSpot app, which must request the same scopes.

class HubSpotConnection(_ManagedConnection):
    provider: ClassVar[str] = 'hubspot'
    available_scopes: ClassVar[tuple[str, ...]] = ('crm.objects.contacts.read', 'crm.export')
    own_application_supported: ClassVar[bool] = True
    name: str = 'HubSpot'
JurnalConnection

Mekari Jurnal's public accounting API with an application's HMAC credentials. Declare a stable key, deploy, then configure Client ID and Client Secret from the Jurnal application in https://developers.mekari.com/. The application must select the Jurnal company and scopes the workspace uses. The backend signs the date and the exact request target with HMAC-SHA256 and sends the SHA-256 Digest of the request body (including an empty body). See https://developers.mekari.com/docs/kb/hmac-authentication. Use paths relative to ``https://api.mekari.com/public/jurnal/api/v1/``, such as ``/products?page=1&page_size=1``, on the ``accounting`` API. Configuring credentials does not test them with Mekari; check access with a read request. ``read_only=True`` prevents writes even when the application's scopes permit them.

class JurnalConnection(_ApiKeyPreset):
    name: str = 'Mekari Jurnal'
    provider: str = 'mekari-jurnal'
    apis: dict[str, str] = Field(default_factory=lambda: {'accounting': JURNAL_API})
    signing: Signing = Field(default_factory=_jurnal_signing)
LinkedInAdsConnection

LinkedIn Ads discovery, reporting and conversions, managed by SegmentStream. Set ``application="own"`` to authorize through your own LinkedIn application with the Advertising and Conversions API products. Pin ``scopes=("r_ads", "r_ads_reporting")`` for reporting access without conversion permissions.

class LinkedInAdsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'linkedin_ads'
    available_scopes: ClassVar[tuple[str, ...]] = ('r_ads', 'r_ads_reporting', 'rw_conversions')
    own_application_supported: ClassVar[bool] = True
    name: str = 'LinkedIn Ads'
LinkedInCommunityConnection

LinkedIn member and page analytics, and page posts, through the Community Management API. One declaration authorizes one LinkedIn member. The client reads the member's profile, post and follower analytics, and the pages the member administers with their posts and statistics. LinkedIn requires the Community Management API to be the only product of its application, so it uses a different application from ``LinkedInAdsConnection``. By default it requests ``r_basicprofile``, ``r_member_postAnalytics``, ``r_organization_social``, ``r_organization_social_feed`` and ``rw_organization_admin``, and requests stay read-only. Add ``w_organization_social`` to ``scopes`` to also create and delete posts of the pages the member administers and upload their images and videos through the ``uploads`` API; it is never requested by default. LinkedIn refuses an authorization requesting a permission the application lacks, so set ``scopes`` to exactly the permissions it has. ``read_only=True`` refuses every write whichever scopes are granted.

class LinkedInCommunityConnection(_ManagedConnection):
    provider: ClassVar[str] = 'linkedin_community'
    own_application_supported: ClassVar[bool] = True
    name: str = 'LinkedIn Community'
    scopes: tuple[LinkedInCommunityScope, ...] = ()
    available_scopes: ClassVar[tuple[str, ...]] = ('r_basicprofile', 'r_member_postAnalytics', 'r_organization_social', 'r_organization_social_feed', 'rw_organization_admin')
    own_available_scopes: ClassVar[tuple[str, ...] | None] = ('r_basicprofile', 'r_member_postAnalytics', 'r_member_profileAnalytics', 'r_organization_social', 'r_organization_social_feed', 'rw_organization_admin')
    optional_scopes: ClassVar[tuple[str, ...]] = ('w_organization_social',)
MailchimpConnection

Mailchimp's Marketing API, through Mailchimp's consent page or an API key. Declare a stable key, deploy, then authorize in either way Mailchimp offers: through SegmentStream's Mailchimp app, on Mailchimp's consent page, where the member signs in to the account the connection reaches; or with an API key you supply, created under Profile > Extras > API keys (``segmentstream connection authorize KEY --token-file -``). Neither expires: the authorization lasts until the member revokes the app or deletes the key. The client reaches ``https://api.mailchimp.com/3.0/``, reads and writes: audiences and their members with status, merge fields, interests, tags and marketing permissions, segments, campaigns and their reports, automations, e-commerce stores, webhooks and the rest of the Marketing API, with the query parameters and body fields its API reference names. ``POST /batches``, which carries other operations in its body, is not admitted. Mailchimp's consent flow has no scopes: the connection can do what the member's Mailchimp user may. Set ``read_only=True`` to refuse every write. Mailchimp allows 10 simultaneous connections per user and answers ``429`` above it; the proxy does not retry. A webhook that names this connection checks Mailchimp's signatures against ``webhook_signing_secret``: create the audience's webhook with signing on, in Mailchimp's audience settings, and paste the secret it shows once. Reading the API never needs it. Set ``application="own"`` to authorize through your own Mailchimp app instead, registered under Profile > Extras > Registered apps with the redirect URI shown on the connection: enter its client ID and secret on the connection. Only the consent flow reads them; an API key you supply needs neither.

class MailchimpConnection(_ManagedConnection):
    provider: ClassVar[str] = 'mailchimp'
    own_application_supported: ClassVar[bool] = True
    name: str = 'Mailchimp'
    verification: Mapping[str, SecretReference] = Field(default_factory=lambda: {'webhook_signing_secret': Secret(label='Webhook signing secret', description='Shown once when you create an audience webhook with signing on in Mailchimp. Only a webhook that names this connection reads it.')})
    validate_verification_values(cls, value: Mapping[str, SecretReference])
McpApi

A connection API that is a remote MCP server (Streamable HTTP), with its allowed tools. Use it as a value of a connection's `apis`: ``apis={"mcp": McpApi(url, tools={...})}``. The URL is validated like any API's and stays in `connection.apis`; the declaration is in `connection.mcp`. Name each tool as the server does. SegmentStream calls only these tools, with their fixed values, and a read-only connection only its read tools.

class McpApi(BaseModel):
    url: str
    tools: dict[str, McpTool]
    __init__(self, url: str, /, *, tools: Mapping[str, McpTool])
    validate_url(cls, value: str)
    validate_tools(cls, value: object)
McpTool

One tool of an MCP server that the workspace allows, with the arguments it fixes. Declare it with `McpTool.read(...)` for a tool that only reads, or `McpTool.write(...)` for any other. Keyword arguments are fixed values: SegmentStream refuses a call of the tool whose arguments do not carry exactly these values, and the ontology removes them from the input the model sees. ``McpTool.write(method="create", owner="o", repo="r")`` can only create, in one repository.

class McpTool(BaseModel):
    access: Literal['read', 'write']
    fixed: dict[str, FixedValue] = {}
    read(cls, **fixed: str | bool | int)
    write(cls, **fixed: str | bool | int)
    validate_fixed(cls, value: object)
MercuryConnection

Mercury API access with an API token. Declare a stable key, deploy, then configure the token in the connection. From Mercury > All Settings > Tokens; create a Read Only API token. The backend sends it as ``Authorization: Bearer <token>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.mercury.com/api/v1/``.

class MercuryConnection(_ApiKeyPreset):
    name: str = 'Mercury'
    provider: str = 'mercury'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='API token', description='From Mercury > All Settings > Tokens; create a Read Only API token.'))})
    apis: dict[str, str] = Field(default_factory=lambda: {'v1': MERCURY_API})
MetaAdsConnection

Meta Marketing API account discovery and reporting, managed by SegmentStream. Declare a stable key, deploy, then authorize through the UI or CLI. Use ``get_connection(key).get_http_client()`` during execution. Provider tokens and application-secret proofs remain in the backend. Set ``application="own"`` to authorize through your own Meta app: enter its App ID and App secret on the connection and add the redirect URI shown there to the app's Facebook Login settings. The backend proves your app's secret on every request.

class MetaAdsConnection(_ManagedConnection):
    own_application_supported: ClassVar[bool] = True
    provider: ClassVar[str] = 'meta_ads'
    available_scopes: ClassVar[tuple[str, ...]] = ('ads_read',)
    name: str = 'Meta Ads'
MicrosoftAdsConnection

Microsoft Advertising account discovery and reporting, managed by SegmentStream.

class MicrosoftAdsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'microsoft_ads'
    available_scopes: ClassVar[tuple[str, ...]] = ('https://ads.microsoft.com/msads.manage',)
    name: str = 'Microsoft Advertising'
MicrosoftTeamsBotConnection

Microsoft Teams access as a bot: the agent's own account in Teams, not a member's. Declare a stable key and the Microsoft Entra tenant the bot is registered in: its tenant ID, or a domain verified in it such as ``contoso.onmicrosoft.com``. Register the bot in that tenant as an Azure Bot with a single-tenant Entra application, deploy, then enter the application's ID and a client secret's value. The backend exchanges them at the tenant's token endpoint for Bot Framework tokens, renews them before they expire, and sends them as ``Authorization: Bearer <token>``; neither the values nor the tokens reach workspace code. Requests reach the Bot Connector service of Microsoft's commercial cloud at ``https://smba.trafficmanager.net/``; each path starts where an activity's ``serviceUrl`` ends, such as ``emea/v3/conversations/{conversation}/activities``. A bot registered as multi-tenant before Microsoft stopped creating them names the tenant ``botframework.com``. To act in Teams as a member instead, declare a `MicrosoftTeamsConnection`.

class MicrosoftTeamsBotConnection(ClientCredentialsConnection):
    name: str = 'Microsoft Teams bot'
    provider: str = 'microsoft-teams-bot'
    tenant: str
    client_authentication: Literal['client_secret_basic', 'client_secret_post', 'client_secret_headers'] = 'client_secret_post'
    default_api: str | None = 'connector'
    derive_tenant_endpoint(cls, data: Any)
MicrosoftTeamsConnection

Microsoft Teams through Microsoft Graph, on the signed-in member's behalf. Declare a stable key, deploy, then authorize: the member signs in with their work or school Microsoft account on Microsoft's consent page, through SegmentStream's Microsoft Entra application. Reading channel messages and team members needs a tenant administrator's consent, which Microsoft asks for on that page; pin ``scopes`` to fewer permissions where an administrator will not grant them. Access tokens are refreshed by the backend. The client reaches ``https://graph.microsoft.com/v1.0/``: the member's profile (``/me``) and other users' basic profiles, joined teams with their channels and members, channel messages with replies, hosted images and reactions, the member's chats with their members, messages and reactions, and files in a channel's folder (``filesFolder``), read through the item's ``@microsoft.graph.downloadUrl`` and uploaded by name or through an upload session. Nothing is deleted, and no team, channel or chat is created or changed. Each request needs the permission named for it in Microsoft Graph's reference among the connection's ``scopes``. Channel and chat IDs such as ``19:abc@thread.tacv2`` go into paths unencoded; upload file names are limited to letters, digits, ``.``, ``_`` and ``-``. Set ``application="own"`` to authorize through your own Entra application instead: register it for accounts in any organizational directory (multi-tenant), add the redirect URI shown on the connection as a Web redirect URI and the delegated Microsoft Graph permissions you request, then enter its application (client) ID and a client secret value on the connection.

class MicrosoftTeamsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'microsoft_teams'
    available_scopes: ClassVar[tuple[str, ...]] = ('User.Read', 'User.ReadBasic.All', 'Team.ReadBasic.All', 'Channel.ReadBasic.All', 'TeamMember.Read.All', 'ChannelMessage.Read.All', 'ChannelMessage.Send', 'Chat.ReadWrite', 'Files.ReadWrite.All')
    own_application_supported: ClassVar[bool] = True
    name: str = 'Microsoft Teams'
NowPaymentsConnection

NOWPayments API access with an API key. Declare a stable key, deploy, then paste an API key from NOWPayments > Payment settings > API keys into the connection. The backend sends it on the ``x-api-key`` header. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.nowpayments.io/v1/``, such as ``/payment``. ``sandbox=True`` reaches ``https://api-sandbox.nowpayments.io/v1/`` instead, which takes only sandbox keys. NOWPayments reports a payment's status by calling the URL passed as its ``ipn_callback_url``: pass the URL of an ontology webhook trigger that names this connection. NOWPayments signs each call with HMAC-SHA512 over the body's JSON with its keys sorted; a webhook that names this connection checks the signature against ``ipn_secret``, which members paste from NOWPayments > Settings > Payments > Instant payment notifications. Reading the payment back before acting on a delivery remains good practice.

class NowPaymentsConnection(_SandboxPreset):
    PRODUCTION_API: ClassVar[str] = 'https://api.nowpayments.io/v1/'
    SANDBOX_API: ClassVar[str] = 'https://api-sandbox.nowpayments.io/v1/'
    API_NAME: ClassVar[str] = 'v1'
    name: str = 'NOWPayments'
    provider: str = 'nowpayments'
    headers: Mapping[str, SecretReference | Bearer | Scheme] = Field(default_factory=lambda: {'x-api-key': Secret(label='API key', description='From NOWPayments > Payment settings > API keys.')})
    verification: Mapping[str, SecretReference] = Field(default_factory=lambda: {'ipn_secret': Secret(label='IPN secret key', description='From NOWPayments > Settings > Payments > Instant payment notifications. Only a webhook that names this connection reads it.')})
OAuth2Connection

A declarative OAuth 2.0 authorization-code connection. Scope transport defaults to spaces; comma mode also normalizes token response scopes. The resource authorization scheme defaults to Bearer and is independent of the token endpoint's token_type. `access_token_type` names the token_type the token endpoint reports for its bearer access tokens, such as Slack's ``bot``; any other reported type is still refused. These options do not configure managed providers. A value of `apis` may be an `McpApi`: a remote MCP server reached with the same tokens. A provider that offers more ways to obtain the application's token admits them too, and the member chooses one when authorizing. `token_authorization=True` admits an access token of the application that the member supplies, stored as supplied. `client_credentials=True` admits the application's OAuth client credentials grant at `token_url`, with no consent; its tokens are renewed by repeating the grant. Neither yields a refresh token, so both need ``require_refresh_token=False``. `token_header` names a header the API takes the bare token on instead of ``Authorization``. `owner="user"` makes the connection owned: each user of the workspace app connects their own account, and code running as that user uses that user's credential. An owned connection admits consent and supplied tokens, never `client_credentials`. It has no operation allowlist: your code may call any path of its APIs with each user's credential.

class OAuth2Connection(HttpApis):
    type: Literal['oauth2'] = 'oauth2'
    key: str
    name: str
    provider: str
    read_only: bool = Field(default=False, strict=True)
    authorization_url: str
    token_url: str
    client_id: SecretReference
    client_secret: SecretReference
    scopes: tuple[str, ...]
    scope_separator: Literal[' ', ','] = ' '
    resource_authorization_scheme: str = 'Bearer'
    access_token_type: str = 'Bearer'
    authorization_parameters: tuple[OAuth2Parameter, ...] = Field(default=())
    token_parameters: tuple[OAuth2Parameter, ...] = Field(default=())
    client_authentication: Literal['client_secret_basic', 'client_secret_post'] = 'client_secret_post'
    pkce: bool = True
    require_refresh_token: bool = True
    token_authorization: bool = Field(default=False, strict=True)
    client_credentials: bool = Field(default=False, strict=True)
    owner: Literal['user'] | None = None
    token_header: str | None = None
    apis: dict[str, str] = Field(default_factory=dict)
    default_api: str | None = None
    verification: Mapping[str, Any] = Field(default_factory=dict)
    validate_verification(cls, value: Mapping[str, Any])
    validate_resource_authorization_scheme(cls, value: str)
    validate_token_header(cls, value: str | None)
    validate_authorization_methods(self)
    validate_access_token_type(cls, value: str)
    validate_apis(cls, value: dict[str, str])
    validate_default_api(self)
    bind_owned_secrets(cls, value: object)
    validate_key(cls, value: str)
    validate_name(cls, value: str)
    validate_provider(cls, value: str)
    validate_endpoint(cls, value: str)
    validate_scopes(cls, value: object)
    normalize_parameters(cls, value: object)
    validate_connection(self)
OAuth2TokenSet

Normalized credential result returned by OAuth token operations.

class OAuth2TokenSet(BaseModel):
    access_token: str = Field(repr=False)
    refresh_token: str | None = Field(default=None, repr=False)
    token_type: str = 'Bearer'
    expires_in: int | None = None
    scopes: tuple[str, ...] = ()
    validate_access_token(cls, value: str)
    validate_token_type(cls, value: str)
    validate_token_scopes(cls, value: tuple[str, ...])
    validate_expires_in(cls, value: int | None)
    validate_refresh_token(cls, value: str | None)
    validate_token_material_size(self)
RedditAdsConnection

Reddit Ads account discovery and reporting, managed by SegmentStream. Declare a stable key, deploy, then authorize on Reddit's consent page. The preset requests a permanent ``adsread`` grant; access tokens are refreshed by the backend. The client reaches the Reddit Ads API v3 at ``https://ads-api.reddit.com/api/v3/``: the member's businesses and their ad accounts, an account's campaigns, ad groups and ads, and ``POST /ad_accounts/{id}/reports``. Lists page with ``page.size`` and ``page.token``. Nothing is created or changed. Set ``application="own"`` to authorize through a Reddit developer application of your own, created under Developer Applications in your Reddit Ads business with the redirect URI shown on the connection, then enter its client ID and secret.

class RedditAdsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'reddit_ads'
    available_scopes: ClassVar[tuple[str, ...]] = ('adsread',)
    own_application_supported: ClassVar[bool] = True
    name: str = 'Reddit Ads'
ResendConnection

Resend email API access with an API key. Declare a stable key, deploy, then paste an API key from Resend > API Keys into the connection. The backend sends it as ``Authorization: Bearer <key>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.resend.com/``, such as ``/emails``. Resend signs its webhooks with Svix. A webhook that names this connection checks them against ``webhook_signing_secret``, which members paste from the endpoint's page in Resend.

class ResendConnection(_ApiKeyPreset):
    name: str = 'Resend'
    provider: str = 'resend'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='API key', description='From Resend > API Keys; starts with re_.'))})
    apis: dict[str, str] = Field(default_factory=lambda: {'api': RESEND_API})
    verification: Mapping[str, SecretReference] = Field(default_factory=lambda: {'webhook_signing_secret': Secret(label='Webhook signing secret', description='From Resend > Webhooks > your endpoint; starts with whsec_. Only a webhook that names this connection reads it.')})
Scheme

A header value the backend sends as ``<scheme> <value>``. Wrap the `Secret(...)` or `secret_ref(...)` of a header whose provider expects an authentication scheme other than Bearer, for example ``{"Authorization": Scheme("Token", Secret())}`` sends ``Authorization: Token <value>``. Users configure only the value; a value pasted with the scheme keeps a single scheme.

class Scheme(BaseModel):
    scheme: str
    secret: SecretReference
    __init__(self, scheme: str, secret: SecretReference, /)
    validate_scheme(cls, value: str)
Secret

A write-only input owned by the containing connection and field.

class Secret(SecretReference):
    type: Literal['secret', 'owned_secret'] = 'owned_secret'
    name: str = ''
SecretReference

A symbolic reference resolved only by the connections backend.

class SecretReference(BaseModel):
    type: Literal['secret', 'owned_secret'] = 'secret'
    name: str
    label: str | None = Field(default=None, min_length=1, max_length=80)
    description: str | None = Field(default=None, max_length=500)
    serialize_reference(self, handler: SerializerFunctionWrapHandler)
    validate_name(cls, value: str)
ShopifyConnection

Shopify Admin API access to one store, through an app of yours. Declare a stable key, the store's handle (the subdomain of its permanent address ``<handle>.myshopify.com``) and the Admin API scopes the connection needs, such as ``("read_orders", "read_products")``; the app must hold them. Deploy, enter the app's client ID and secret, then authorize in one of the ways Shopify offers: - Shopify's consent flow, for an app installed on the store with Shopify's authorization: add the redirect URI the connection shows to the app first. Its offline tokens expire and are refreshed by the backend. - The client credentials grant, for an app of the store's own Shopify organization: no consent; the backend renews its 24-hour tokens by repeating the grant. - An Admin API access token you supply, such as a custom app's that was created in the store's admin; such an app names its client values API key and API secret key. Requests carry the token on ``X-Shopify-Access-Token``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://<handle>.myshopify.com/admin/api/``, starting with the API version, such as ``2026-10/graphql.json``.

class ShopifyConnection(OAuth2Connection):
    name: str = 'Shopify'
    provider: str = 'shopify'
    shop: str
    scope_separator: Literal[' ', ','] = ','
    client_authentication: Literal['client_secret_basic', 'client_secret_post'] = 'client_secret_post'
    pkce: bool = False
    token_parameters: tuple[OAuth2Parameter, ...] = Field(default_factory=lambda: (OAuth2Parameter(name='expiring', value='1'),))
    require_refresh_token: bool = False
    token_authorization: bool = Field(default=True, strict=True)
    client_credentials: bool = Field(default=True, strict=True)
    token_header: str | None = 'X-Shopify-Access-Token'
    default_api: str | None = 'admin'
    derive_store_endpoints(cls, data: Any)
SlackConnection

Slack Web API access as the bot of your own Slack app. Create the app in the Slack workspace it serves at api.slack.com/apps, add the redirect URI the connection shows under OAuth & Permissions, and give the app the bot scopes the declaration requests. Declare a stable key, deploy, enter the client ID and client secret from the app's Basic Information page, then authorize: that installs the app in its Slack workspace, and the backend keeps the bot token. One declaration is one app installation. `scopes` defaults to the bot scopes the workspace agent's Slack channel uses; request only those you call, such as ``["chat:write"]``, when the bot only posts. User scopes are not requested. Call Web API methods by name, such as ``/chat.postMessage``; ``api="files"`` downloads a file's ``url_private`` from ``https://files.slack.com/``.

class SlackConnection(OAuth2Connection):
    name: str = 'Slack'
    provider: str = 'slack'
    authorization_url: str = SLACK_AUTHORIZATION_URL
    token_url: str = SLACK_TOKEN_URL
    scopes: tuple[str, ...] = SLACK_BOT_SCOPES
    scope_separator: Literal[' ', ','] = ','
    access_token_type: str = 'bot'
    client_authentication: Literal['client_secret_basic', 'client_secret_post'] = 'client_secret_basic'
    pkce: bool = False
    require_refresh_token: bool = False
    apis: dict[str, str] = Field(default_factory=lambda: {'web': SLACK_WEB_API, 'files': SLACK_FILES_API})
    default_api: str | None = 'web'
    accept_only_key_name_and_scopes(cls, data: Any)
StarlingConnection

Starling API access with a personal access token. Declare a stable key, deploy, then configure the token in the connection. From Starling Developer Portal > Personal Access; select account:read, balance:read, transaction:read and account-list:read. The backend sends it as ``Authorization: Bearer <token>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.starlingbank.com/api/v2/``.

class StarlingConnection(_ApiKeyPreset):
    name: str = 'Starling'
    provider: str = 'starling'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='Personal access token', description='From Starling Developer Portal > Personal Access; select account:read, balance:read, transaction:read and account-list:read.'))})
    apis: dict[str, str] = Field(default_factory=lambda: {'v2': STARLING_API})
StripeConnection

Stripe API access with a secret or restricted API key. Declare a stable key, deploy, then paste a key from Stripe Dashboard > Developers > API keys into the connection; prefer a restricted key with read access only. The backend sends it as ``Authorization: Bearer <key>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.stripe.com/v1/``, such as ``/charges``. A webhook that names this connection checks Stripe's signatures against ``webhook_signing_secret``, which members paste from the endpoint's page in Stripe.

class StripeConnection(_ApiKeyPreset):
    name: str = 'Stripe'
    provider: str = 'stripe'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='API key', description='From Stripe Dashboard > Developers > API keys; a restricted key (rk_live_) with read access is safest.'))})
    apis: dict[str, str] = Field(default_factory=lambda: {'v1': STRIPE_API})
    verification: Mapping[str, SecretReference] = Field(default_factory=lambda: {'webhook_signing_secret': Secret(label='Webhook signing secret', description='From Stripe Dashboard > Developers > Webhooks > your endpoint; starts with whsec_. Only a webhook that names this connection reads it.')})
SupabaseConnection

Supabase REST API access to one project with a secret key. Declare a stable key and the project ref, the subdomain of the project URL ``https://<ref>.supabase.co``. Deploy, then paste a secret key from Supabase Dashboard > Project Settings > API Keys into the connection. The backend sends it on the ``apikey`` header, as Supabase requires for its non-JWT keys. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://<ref>.supabase.co/rest/v1/``, such as ``/orders?select=*``.

class SupabaseConnection(ApiKeyConnection):
    name: str = 'Supabase'
    provider: str = 'supabase'
    project: str
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'apikey': Secret(label='Secret key', description='From Supabase Dashboard > Project Settings > API Keys; starts with sb_secret_.')})
    derive_project_api(cls, data: Any)
TelegramBotConnection

Telegram Bot API access with a bot token. Declare a stable key, deploy, then paste the token @BotFather gave the bot into the connection. Telegram reads the token from the URL path, so the backend sends requests to ``https://api.telegram.org/bot<token>/`` and the token never reaches pipeline code or its request URLs. Use ``get_connection(key).get_http_client()`` with method paths such as ``/getUpdates``, and ``api="file"`` to download a file's ``file_path``. ``segmentstream connection authorize KEY`` creates the bot through SegmentStream instead, and stores its token in the connection.

class TelegramBotConnection(ApiKeyConnection):
    token: SecretReference | None = Field(default=None, exclude=True)
    name: str = 'Telegram'
    provider: str = 'telegram'
    path: Mapping[str, SecretReference] = Field(default_factory=lambda: {'bot': Secret(label='Bot token', description='From @BotFather; looks like 123456789:AA...')})
    apis: dict[str, str] = Field(default_factory=lambda: {'bot': TELEGRAM_BOT_API, 'file': TELEGRAM_FILE_API})
    default_api: str | None = 'bot'
    derive_token_reference(cls, data: Any)
TikTokAdsConnection

TikTok Ads account discovery and reporting, managed by SegmentStream.

class TikTokAdsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'tiktok_ads'
    name: str = 'TikTok Ads'
TurnstileConnection

The secret key of a Cloudflare Turnstile widget, for the guests' bot check. Create a widget for the website in Cloudflare > Turnstile, render it on the website with its site key, declare a stable key, deploy, and paste the widget's secret key into the connection. The ontology's guests check each new guest's challenge token with it: ``guest.botCheck = {"scheme": "turnstile", "connection": turnstile, "input": "secret_key"}``. The connection has nothing to call; SegmentStream sends the key only to Turnstile's verification endpoint.

class TurnstileConnection(_ApiKeyPreset):
    name: str = 'Turnstile'
    provider: str = 'cloudflare-turnstile'
    apis: dict[str, str] = Field(default_factory=dict)
    verification: Mapping[str, SecretReference] = Field(default_factory=lambda: {'secret_key': Secret(label='Secret key', description="From Cloudflare > Turnstile > your widget's settings.")})
Uses

A verification value that is another value of the same connection. Some providers sign what they send with a secret the connection already holds, such as an OAuth application's client secret or a Meta app secret: ``uses("client_secret")`` checks signatures against it instead of asking members to paste it twice. Only signature checks read it; a registration token is always a value of its own.

class Uses(BaseModel):
    field: str
Value

A configured input that is not secret, such as an account id. Members set it after deployment, like a `Secret(...)`. The backend sends it as configured and responses may contain it, while every secret a response contains is replaced with ``***``. Use it for a header or query parameter, never for `Authorization`.

class Value(Secret)
VercelConnection

Vercel's REST API, through Sign in with Vercel or an access token. Declare a stable key, deploy, then authorize in either way Vercel offers: through SegmentStream's Vercel app, on Vercel's consent page, granting the app's permissions to a team; or with an access token you supply, created in Vercel > Account Settings > Tokens and scoped to the team, or to one project, which then reaches only that project's endpoints (``segmentstream connection authorize KEY --token-file -``). The connection acts as the member who authorized it, so it can do what that member may: a team's invoices need its Owner or Billing role. The backend refreshes consent tokens; a supplied token is used until it expires or is revoked in Vercel. The client reaches ``https://api.vercel.com/``, reads and writes, with each endpoint's version in its path, and team resources take the team as ``teamId``: projects and their environment variables, deployments, domains, a team's invoices (``/v1/invoices``, ``/v1/invoices/{id}``, ``/v1/invoices/upcoming``) and the rest of Vercel's API, with the query parameters and body fields its API reference names. Operations that would hand out a raw credential or delete the user or a team are never admitted. Set ``read_only=True`` to refuse every write. An invoice's ``pdfDownloadUrl`` is a signed link on another host: fetch it without the connection. Set ``application="own"`` to authorize through your own Vercel app instead: enter its client ID and secret on the connection and add the redirect URI shown there to the app. Only the consent flow reads them; a token you supply needs neither.

class VercelConnection(_ManagedConnection):
    provider: ClassVar[str] = 'vercel'
    available_scopes: ClassVar[tuple[str, ...]] = ('openid', 'offline_access')
    own_application_supported: ClassVar[bool] = True
    name: str = 'Vercel'
WhatsAppBusinessConnection

WhatsApp Cloud API access through a customer-owned Meta app. ``WhatsAppConnection(key=..., application="own")`` authorizes with the same system user token and also receives the number's messages and serves the agent's WhatsApp channel. Create an app with WhatsApp in the customer's business portfolio, assign a least-privilege system user to its WhatsApp assets, and generate a token with ``whatsapp_business_messaging`` and ``whatsapp_business_management``. Deploy, then paste that system-user access token into the connection. Check its actual expiry and rotate it before expiration or after revocation. The backend sends only ``Authorization: Bearer <token>`` to the fixed Graph and media APIs. Use ``api="media"`` for a download path after validating the returned URL's origin is exactly ``https://lookaside.fbsbx.com``. The Meta app secret is never part of this connection. See docs/connections.md for setup, account limits and Meta's AI-policy requirements.

class WhatsAppBusinessConnection(_ApiKeyPreset):
    name: str = 'WhatsApp Business'
    provider: str = 'whatsapp'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='System user access token', description="From the customer's Meta Business Settings > System users."))})
    apis: dict[str, str] = Field(default_factory=lambda: {'graph': WHATSAPP_GRAPH_API, 'media': WHATSAPP_MEDIA_API})
    default_api: str | None = 'graph'
WhatsAppConnection

A WhatsApp Business number, connected through SegmentStream's Meta app. Declare a stable key, deploy, then authorize in either way Meta offers: the member finishes Meta's Embedded Signup and connects a number, or, for a number in the business portfolio that owns the app, which Embedded Signup does not offer, enters a system user token of the app with both WhatsApp permissions and the ID of the WhatsApp Business account it reaches (``segmentstream connection authorize KEY --token-file - --account ID``). A number already used in the WhatsApp Business app stays there (Coexistence). The client reaches the Cloud API through aliases for the connected number and account, so code never handles their IDs: ``POST /phone/messages``, ``GET /phone``, ``GET /media/{id}``, ``DELETE /media/{id}`` and ``/account/message_templates``. Messages send media by ``link``. Download received media through ``api="media"`` after checking the returned URL's origin is exactly ``https://lookaside.fbsbx.com``. SegmentStream relays inbound messages, echoes, history and statuses to the workspace's ontology webhook named like the connection key, declared without a signature. Set ``history=True`` to request the contacts and up to six months of chat history of a Coexistence number when it connects; Meta allows this once, within 24 hours. Set ``coexistence=False`` to onboard through Meta's standard Embedded Signup instead, for a number used only through the Cloud API: a new number, or one removed from the WhatsApp apps first. Set ``application="own"`` to connect through your own Meta app instead: enter its App ID, App secret and a webhook verify token of your choice on the connection, then authorize with a system user token of the app, or, for an app admitted to Embedded Signup as a Tech Provider, enter its Embedded Signup configuration ID, add the redirect URI shown there to the app and authorize through Embedded Signup. Then enter the webhook URL the connection shows, with that verify token, in the app's WhatsApp webhook settings: messages reach the workspace as with SegmentStream's app.

class WhatsAppConnection(_ManagedConnection):
    own_application_supported: ClassVar[bool] = True
    provider: ClassVar[str] = 'whatsapp'
    available_scopes: ClassVar[tuple[str, ...]] = ('whatsapp_business_management', 'whatsapp_business_messaging')
    name: str = 'WhatsApp'
    history: bool = Field(default=False, strict=True)
    coexistence: bool = Field(default=True, strict=True)
    validate_history(self)
WiseConnection

Wise API access with a personal API token. Declare a stable key, deploy, then configure the token in the connection. From Wise > Your Account > Connect and manage apps > API tokens; create a read-only token. The backend sends it as ``Authorization: Bearer <token>``. Use ``get_connection(key).get_http_client()`` with paths relative to ``https://api.wise.com/``.

class WiseConnection(_ApiKeyPreset):
    name: str = 'Wise'
    provider: str = 'wise'
    headers: Mapping[str, SecretReference | Bearer] = Field(default_factory=lambda: {'Authorization': Bearer(Secret(label='Personal API token', description='From Wise > Your Account > Connect and manage apps > API tokens; create a read-only token.'))})
    apis: dict[str, str] = Field(default_factory=lambda: {'api': WISE_API})
XAdsConnection

X Ads account discovery and reporting, managed by SegmentStream.

class XAdsConnection(_ManagedConnection):
    provider: ClassVar[str] = 'x_ads'
    name: str = 'X Ads'
XeroConnection

Xero API access through a Xero custom connection. A custom connection belongs to one Xero organisation; declare one key per organisation. Deploy, then paste the custom connection's client ID and client secret from developer.xero.com > My Apps. The backend exchanges them for 30-minute tokens. The default `accounting` API is ``https://api.xero.com/api.xro/2.0/``; `api` reaches the other Xero APIs under ``https://api.xero.com/``.

class XeroConnection(_ClientCredentialsPreset):
    name: str = 'Xero'
    provider: str = 'xero'
    token_url: str = XERO_TOKEN_URL
    client_id: SecretReference = Field(default_factory=lambda: Secret(label='Client ID', description='From the custom connection at developer.xero.com.'))
    client_secret: SecretReference = Field(default_factory=lambda: Secret(label='Client secret', description='Shown once in Xero.'))
    apis: dict[str, str] = Field(default_factory=lambda: {'accounting': 'https://api.xero.com/api.xro/2.0/', 'api': 'https://api.xero.com/'})
    default_api: str | None = 'accounting'
secret_ref

Read a value from the workspace secret `name`: the older form of `Secret(...)`. Deprecated: declare the connection's own ``Secret(...)``. Deploying that change takes over a workspace secret only this value named, so nobody enters it again.

secret_ref(name: str) -> SecretReference
uses

The verification value that is the connection's own `field`, such as ``client_secret``.

uses(field: str) -> Uses