From 138217eb14832441cf0d7550e4b5e1ca8a9b8067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?batuhan=20i=C3=A7=C3=B6z?= Date: Tue, 24 Nov 2026 20:24:38 +0000 Subject: [PATCH 1/5] Update Connectors docs for Public Beta on Go, Pro, and Enterprise --- content/(account)/api-keys.mdx | 14 +++- content/(concepts)/teams.mdx | 2 + content/(dynamic)/connectors.mdx | 46 +++++++---- content/(dynamic)/team-connectors.mdx | 40 +++++++--- content/api/authentication.mdx | 5 +- content/api/connectors.mdx | 26 +++++-- content/cli/api-keys.mdx | 25 +++++- content/cli/connectors.mdx | 108 +++++++++++++++++++++++--- scripts/pricing-next.mjs | 2 +- 9 files changed, 221 insertions(+), 47 deletions(-) diff --git a/content/(account)/api-keys.mdx b/content/(account)/api-keys.mdx index dd6b2888..bf8a622e 100644 --- a/content/(account)/api-keys.mdx +++ b/content/(account)/api-keys.mdx @@ -69,7 +69,7 @@ Your own browser session has no stored policy. Spacefast compiles one per team f |---|---| | `owner` | Every action (`*`) | | `admin` | Every action (`*`) | -| `member` | A fixed list: read, create, update, rename, and publish spaces; read, promote, and download versions; read, attach, and verify domains; read, trigger, and create builds; read the team; read billing | +| `member` | A fixed list: read, create, update, rename, and publish spaces; read, promote, and download versions; read, attach, and verify domains; read, trigger, and create builds; read and run team connectors (`connectors:read`, `connectors:execute`); read the team; read billing | Two rules follow from that: @@ -78,6 +78,18 @@ Two rules follow from that: Keys created through the API can also be scoped to a single Space instead of the whole team, which narrows the policy to exactly that Space. +## Limit connector access + +By default, a key with connector scopes (such as `team_admin`) can reach every team connection. Narrow it to specific connections when an integration should only touch one account: + +```bash +sf api-keys create --name linear-bot --preset team_admin --connection cxn_abc123 +sf api-keys update key_0123456789abcdef --connection cxn_abc123 --connection cxn_def456 +sf api-keys update key_0123456789abcdef --all-connections +``` + +Over the API, pass `connectorAccess: { connectionIds: ["cxn_abc123"] }` on `POST /v1/api-keys` or `PATCH /v1/api-keys/{apiKeyId}`, or `connectorAccess: null` to remove the limit. For OAuth apps and CLI logins, choose specific connections under **Choose Connections** on the consent screen, or edit them later on **Connected apps**. See [Team connectors](/team-connectors). + ## What an agent grant cannot do Some actions are reserved for a signed-in person, at every permission level. No API key, agent grant, or OAuth token can do them: diff --git a/content/(concepts)/teams.mdx b/content/(concepts)/teams.mdx index f8eb61df..32d19030 100644 --- a/content/(concepts)/teams.mdx +++ b/content/(concepts)/teams.mdx @@ -93,6 +93,8 @@ Things that catch people out: On **Members**, each row has role and removal actions for owners and admins. Removing someone takes away their access to the team and every Space in it. Anything they published stays where it is, and you can invite them back later. +If the team uses [Connectors](/team-connectors), the removal review lists the departing member's connector dependencies. Their personal connections disconnect automatically along with any Space bindings pointing to them. Team connections they created stay active so you can reconnect or rebind them without downtime. + Two guards you cannot talk your way past: - The last owner cannot be removed, and cannot be demoted. Add another owner first. diff --git a/content/(dynamic)/connectors.mdx b/content/(dynamic)/connectors.mdx index 5c7a5fa6..5eff75c3 100644 --- a/content/(dynamic)/connectors.mdx +++ b/content/(dynamic)/connectors.mdx @@ -2,14 +2,14 @@ title: Connectors description: Show live data from your team's tools on any Space page. Declare a role in your config, call it from the page, and the account's credentials never reach the browser. sidebar: - badge: Private Beta + badge: Public Beta --- -Private Beta +Public Beta Connectors put live data from your team's tools on any page of a Space, with no backend to write and no keys in the page. You declare a role in your config, bind an account to it, and the page calls `/__spacefast/connectors//`. Spacefast runs the tool with the account's credentials on the server and answers the page with JSON. -Connectors are in Private Beta. A team without access gets `feature_unavailable`. +Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. To register tool sources, connect accounts, and manage agent rules, see [Team connectors](/team-connectors). ## Declare a role @@ -46,7 +46,7 @@ Or in `sf.jsonc`, with the same shape: } ``` -When both files exist, `spacefast.config.ts` wins. Publish to apply the roles: each version freezes the roles it was published with. +When both files exist, `spacefast.config.ts` wins. Publish to apply the roles, because each version freezes the roles it was published with. The tool names and arguments on this page, such as `list_deals` and `stage`, are examples. Use the names your connection lists: [`listConnectionTools`](/api/reference/connectors/listconnectiontools) returns each tool with its input schema. @@ -69,7 +69,7 @@ sf connectors create hubspot --slug hubspot sf connectors connections connect hubspot ``` -Publishing binds a role for you when exactly one eligible connection exists. The publish receipt lists the roles that still need one. Bind the rest yourself: +Publishing a live version binds a role for you when exactly one eligible connection exists. The publish receipt lists any roles that still need one. Bind the rest yourself: ```bash sf connectors bindings --space example @@ -84,8 +84,8 @@ A `visitor` role binds nothing. Each viewer connects their own account. | `as` | Whose account | Who reads through it | Who writes through it | | --- | --- | --- | --- | -| `team` | A team connection with site serving on | Everyone who can open the Space | A signed-in member of the team or one of the Space's users | -| `personal` | The connection of the person who bound it | Everyone who can open the Space, which only works while the Space is private | A signed-in member of the team or one of the Space's users | +| `team` | A team connection with site serving on | Everyone who can open the Space | A signed-in current member of the owning team | +| `personal` | The connection of the person who bound it | Everyone who can open the Space, which only works while the Space is private | A signed-in current member of the owning team | | `visitor` | Each viewer's own connection | That viewer | That viewer | The connectors route sits behind the Space's own access check, so the data is never more public than the pages. A private Space's data stays private. A share link or password admits anyone with the share link or the password, and they read too. @@ -95,10 +95,18 @@ That's why two roles have extra rules: - **`team` on a Space anyone can open.** When the Space is public, or shared by link or password, a `team` role serves only after a team owner or admin allows it: `sf connectors public-serving set crm --enable --space example`. Until then, calls answer `connection_forbidden`. The allowance covers the account bound when it was given; rebinding the role takes it away. - **`personal` needs a private Space.** A `personal` role works only while the Space is private and has no share link or password. Otherwise every call answers `connection_forbidden`. -Writes need a signed-in viewer. An anonymous visitor of a public Space reads through a `team` role and never writes through it: the call answers `connector_write_sign_in_required`. Send viewers to sign in with `space.access.signIn()`. A `visitor` role asks the viewer to sign in first, then to connect their account. +Writes through a `team` or `personal` role require a signed-in current member of the owning team. Anyone else—an anonymous visitor, an external guest, or a non-member—reads through a `team` role and never writes through it: the call answers `connector_write_sign_in_required`. Send viewers to sign in with `space.access.signIn()`. A `visitor` role asks the viewer to sign in first, then to connect their own account. A team's connector policy still applies to every call. A tool it blocks is refused, and a call it holds for approval answers `approval_pending`. +## Previews + +Preview and held versions protect your live Space's bindings and shared accounts: + +- **No auto-binding on preview publishes.** Publishing a version that doesn't go live leaves existing bindings untouched and binds no new roles. Promoting the version to live (or rolling back to it) binds its roles then. +- **No shared writes from previews.** A preview version can read through already-bound `team` or `personal` roles, but non-read-only tools on shared bindings are refused with `connector_preview_write_not_allowed`. Promote the version to run writes. +- **`visitor` roles work normally in previews**, because each call uses the viewer's own connected account. + ## Call it from a page Install the client: @@ -203,7 +211,8 @@ Failures a page can't wait out come back as an RFC 9457 problem with a stable `c | [`connector_role_unknown`](/errors/connector_role_unknown) | 404 | The live version doesn't declare this role | | `connector_tool_not_allowed` | 403 | The role's `tools` doesn't list this tool | | `connector_arg_pinned` | 422 | The call sent a different value for a pinned argument | -| `connector_write_sign_in_required` | 403 | A write through a `team` or `personal` role from a viewer who isn't signed in as a member | +| `connector_preview_write_not_allowed` | 403 | A preview version tried to run a non-read-only tool through a shared `team` or `personal` role | +| `connector_write_sign_in_required` | 403 | A write through a `team` or `personal` role from a viewer who isn't signed in as a current member of the owning team | | [`connector_tool_blocked`](/errors/connector_tool_blocked) | 403 | The team's connector policy blocks this write tool on a `team` or `personal` role | | [`connector_write_in_read_handler`](/errors/connector_write_in_read_handler) | 403 | A `GET` to a tool that writes. Send a `POST` | | [`browser_origin_not_allowed`](/errors/browser_origin_not_allowed) | 403 | The call came from another site, or a write without same-origin proof | @@ -211,11 +220,11 @@ Failures a page can't wait out come back as an RFC 9457 problem with a stable `c ### Visitor accounts -A `visitor` role needs a connector with an OAuth sign-in method, since each viewer signs in to their own account. A connector that only takes API keys can't serve one: connecting answers `connector_oauth_required`. When the connector needs an OAuth app your team hasn't registered, it answers `connector_oauth_app_required`. +A `visitor` role needs a connector with an OAuth sign-in method, since each viewer signs in to their own account. A connector that only takes API keys can't serve one, and connecting answers `connector_oauth_required`. When the connector needs an OAuth app your team hasn't registered, it answers `connector_oauth_app_required`. A `visitor` role's `connectUrl` is `/__spacefast/connectors//connect`. It signs the viewer in if needed, then sends them to the provider and back. Add `?return_to=/some/path` to land somewhere other than `/`. A `POST` to `/__spacefast/connectors//disconnect` from the Space's own page forgets the viewer's account. -[`listVisitorConnectionUsers`](/api/reference/spaces/listvisitorconnectionusers) counts which of the Space's users connected each role, and [`revokeVisitorConnection`](/api/reference/spaces/revokevisitorconnection) disconnects one user's account for a role. +Review or revoke visitor connections from the CLI with `sf connectors visitors list --space example` and `sf connectors visitors revoke --space example`. Through the API, [`listVisitorConnectionUsers`](/api/reference/spaces/listvisitorconnectionusers) lists which Space users connected each role, and [`revokeVisitorConnection`](/api/reference/spaces/revokevisitorconnection) disconnects one user's account for a role. ## Pinned arguments @@ -267,17 +276,26 @@ sf connectors serving approve csr_abc123 sf connectors serving deny csr_abc123 ``` -Approving turns serving on, and the role's state flips to ready. A team can keep serving decisions to owners and admins, and can limit which connectors may serve sites at all. +Approving turns serving on, and the role's state flips to ready. On Enterprise plans, owners and admins can keep serving decisions to admins and limit which connectors may serve sites with `sf connectors serving set`. The API operations are `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, and `denyConnectorServingRequest`. Public serving for a `team` role is `setSpaceConnectorPublicServing`. -## Change roles from the dashboard +## Change roles without a publish The Space's **Integrations** page lists every role. An override lives with the Space, not in your config file, and replaces that one role: - **Turn off** removes a role your config declares. It moves to **Removed roles**, where **Restore** brings it back. - **Use config file** drops an override and returns the role to what the file says. +From the CLI, `sf connectors roles` manages the same overrides: + +```bash +sf connectors roles list --space example +sf connectors roles set crm --connector hubspot --tools list_deals --cache 60s --space example +sf connectors roles remove crm --space example +sf connectors roles reset crm --space example +``` + Saving re-applies the live version, so the change takes effect without a publish. The next publish keeps the overrides. Through the API, overrides are `config.connectors` on [`updateSpace`](/api/reference/spaces/updatespace). An entry replaces the file's role of the same name, and `null` removes it. `config` replaces the Space's whole stored overlay, so read it from [`getSpace`](/api/reference/spaces/getspace) first and send it back with your change, along with its `settingsDigest` as `baseSettingsDigest`. @@ -293,7 +311,7 @@ export async function GET(request, { env }) { } ``` -The role proxy returns the tool's result, or throws a `ConnectorCallError` whose `state.code` says why, such as `connect_required` or `forbidden`. `env.CONNECTORS.call("crm", "list_deals", args)` returns `{ state, result }` instead of throwing. The worker forwards the request's signed-in viewer, so `visitor` roles and writes follow the same rules as a page. Calls from a worker are never shared reads. +The role proxy returns the tool's result, or throws a `ConnectorCallError` whose `state.code` says why, such as `connect_required` or `forbidden`. `env.CONNECTORS.call("crm", "list_deals", args)` returns `{ state, result }` instead of throwing. The worker forwards the request's signed-in viewer, so `visitor` roles, preview write rules, and writes follow the same rules as a page. Calls from a worker are never shared reads. ## Call it from outside the Space diff --git a/content/(dynamic)/team-connectors.mdx b/content/(dynamic)/team-connectors.mdx index ff0ca14e..40c87896 100644 --- a/content/(dynamic)/team-connectors.mdx +++ b/content/(dynamic)/team-connectors.mdx @@ -2,25 +2,26 @@ title: Team connectors description: Register an OpenAPI spec, GraphQL endpoint, or remote MCP server for your team, connect an account, decide what agents may call, and run tools sidebar: - badge: Private Beta + badge: Public Beta --- -Private Beta +Public Beta -A connector is a source of tools that a team registers once: an OpenAPI spec, a GraphQL endpoint, or a remote MCP server. A connection is one account on that connector. Agents get the tools. The credential stays in Spacefast, and no endpoint ever returns it. +A connector is a source of tools that a team registers once: an OpenAPI spec, a GraphQL endpoint, or a remote MCP server. A connection is one account on that connector. Agents and Spaces get the tools. The credential stays in Spacefast, and no endpoint ever returns it. -Connectors are in Private Beta. A team without access gets `feature_unavailable`. +Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. Enterprise adds team-wide connector allowlists, blocklists, and site-serving governance. ## Before you start -- Only team owners and admins can open the connectors pages. A member sees **Only Team Owners and Admins Can Manage Connectors**. -- An API key needs connector scopes. `connectors:read` reads everything. `connectors:write` registers connectors, connects accounts, and sets policy. `connectors:execute` runs tools. `write` and `execute` both include `read`, but neither includes the other. See [API keys](/api-keys). +- **Team owners and admins** manage connectors in the dashboard: registering tool sources, connecting or disconnecting team accounts, and setting team rules (`connectors:write`). +- **Team members** can list and run team connections through the API, CLI, and On-Device MCP (`connectors:read` and `connectors:execute`), subject to the team's policy rules and any per-credential connection limits. The team's **Connectors** dashboard pages remain owner and admin only. +- **API keys** need connector scopes. `connectors:read` reads connectors, connections, tools, rules, and runs. `connectors:write` registers connectors, connects accounts, and sets policy. `connectors:execute` runs tools. `write` and `execute` both include `read`, but neither includes the other. You can also limit an API key or OAuth grant to specific connections. See [API keys](/api-keys). -The pages live under **Connectors** in the team sidebar. A switch in the header moves between **Connectors**, **Runs**, and **Policies**. +The dashboard pages live under **Connectors** in the team sidebar. A switch in the header moves between **Connectors**, **Runs**, and **Policies**. ## Add a connector from the catalog -The catalog lists curated presets, the public registry, and your team's own connectors. It has one row per surface, so a service with an API and an MCP server is two rows. +The catalog lists curated presets, the public registry, and your team's own connectors. It has one row per source type, so a service with an API and an MCP server is two rows. 1. Open **Connectors** in the team sidebar. 2. Click **Browse Connectors**. @@ -29,9 +30,10 @@ The catalog lists curated presets, the public registry, and your team's own conn The row changes to **View** when the connector exists. A row that needs a provider-specific endpoint shows **Set Up** instead of **Add**, and opens the add form. -From the CLI, pass a catalog slug: +From the CLI, search the catalog or pass a catalog slug: ```bash +sf connectors search linear sf connectors create linear ``` @@ -98,6 +100,15 @@ An account in `needs_reauth` or `degraded` also shows a **Reconnect** button. To Credentials cannot be edited. To rotate a key, reconnect the account. A disconnected account cannot be reconnected. Connecting the service again makes a new account with a new id. +## Limit which connections a key or app can use + +By default, a credential with connector scopes can reach every team connection it has permission for. Narrow it to specific connections when a script, CI job, or AI client should only touch one account: + +- **API keys:** Pass one or more `--connection ` flags when creating or updating a key (`sf api-keys create --name linear-bot --preset team_admin --connection cxn_abc123`), or send `connectorAccess: { connectionIds: ["cxn_abc123"] }` over the API. Remove the limit later with `sf api-keys update --all-connections` or `connectorAccess: null`. See [API keys](/api-keys#limit-connector-access). +- **OAuth apps and CLI logins:** On the consent screen, open **Choose Connections** to pick which connections the app may reach. You can change that list later on **Connected apps** in the dashboard without re-authorizing. + +A connection outside a credential's allowlist answers `404` as if it doesn't exist. + ## Decide what agents can call A policy rule pairs an address pattern with an action. @@ -141,11 +152,13 @@ sf connectors policies add '*' --action require_approval sf connectors policies explain cxn_abc123/charges.create ``` +On Enterprise plans, team owners and admins can also set a team-wide connector allowlist or blocklist and restrict which connectors may serve Spaces. + ## Find a tool Click **See tools** on a connector row, or open **Connector tools** from the command palette. The **Tools** page lists every tool the team's accounts reach. Each row shows the tool name, its summary, its resolved effect, and its safety: **Read-only**, **Writes**, or **Destructive**. Safety comes from the source and is not a setting. -Open a tool to see its address, the rule that decided its effect, and its **Input schema**. The API equivalents are [`listConnectorTools`](/api/reference/connectors/listconnectortools) and [`listConnectionTools`](/api/reference/connectors/listconnectiontools). +Open a tool to see its address, the rule that decided its effect, and its **Input schema**. From the CLI, inspect a connector or a connection's tools with `sf connectors inspect ` or `sf connectors connections inspect `. The API equivalents are [`listConnectorTools`](/api/reference/connectors/listconnectortools) and [`listConnectionTools`](/api/reference/connectors/listconnectiontools). ## Run a tool @@ -192,6 +205,13 @@ The CLI and the [connectors API](/api/connectors) give an agent everything else. To show a connection's data on a Space's pages, declare a role and bind the connection to it. See [Connectors](/connectors). +## When a member leaves + +Before removing a team member, the dashboard lists the connector dependencies they own or created: + +- **Personal connections** owned by that member disconnect automatically when they leave or are removed. Their stored credentials are purged, pending sign-ins are canceled, and any Space bindings using them are removed. +- **Team connections** the departing member created stay active, but are listed during member removal so an owner or admin can reconnect them with a team-owned account or rebind affected Spaces if the provider account will be deactivated. + ## Remove a connector ```bash diff --git a/content/api/authentication.mdx b/content/api/authentication.mdx index 92d92ba8..0eaf9d62 100644 --- a/content/api/authentication.mdx +++ b/content/api/authentication.mdx @@ -69,6 +69,7 @@ const created = await client.post("/v1/api-keys", { | `ipAllowlist` | up to 100 strings, each ≤ 255 chars | Restrict the key to these addresses. Optional, nullable. | | `expiresAt` | ISO 8601 | When the key stops working. Optional, nullable. Omit for no expiry. | | `notBefore` | ISO 8601 | When the key starts working. Optional, nullable. | +| `connectorAccess` | `{ connectionIds: string[] }` or `null` | Limit the key to specific connector connections (`cxn_…`). Omit or pass `null` to allow every team connection. | Three rules the code enforces: @@ -76,7 +77,7 @@ Three rules the code enforces: - **A key can never exceed its creator.** The derived policy must be a subset of the calling credential's policy. A wider request fails with `policy_exceeds_grantor`. - **Secrets are immutable.** There is no rotate-in-place. Create a new key, move traffic, then revoke the old one with `DELETE /v1/api-keys/{apiKeyId}`. That returns `204` and keeps the record for audit. -`PATCH /v1/api-keys/{apiKeyId}` changes name, scope, permissions, allowlist, and expiry. `scope` and `permissions` must be sent together or both omitted. +`PATCH /v1/api-keys/{apiKeyId}` changes name, scope, permissions, allowlist, expiry, and `connectorAccess`. `scope` and `permissions` must be sent together or both omitted. In the dashboard, keys live on the team's **Agents** page under **API keys**. The create form asks for **Name**, a **Policy preset**, and an optional **Expires**, then shows the secret once behind **Copy this key now. It won't be shown again.** @@ -115,7 +116,7 @@ Creating, rotating, and revoking a machine credential all need an API key or a s ## Sessions and OAuth -A signed-in browser session works as a cookie and as `Authorization: Bearer `. A session has no stored policy. It compiles one per team from the caller's live role, so an owner or admin gets everything the team can do and a member gets read, create, write, rename, publish, promote, download, and build actions. +A signed-in browser session works as a cookie and as `Authorization: Bearer `. A session has no stored policy. It compiles one per team from the caller's live role, so an owner or admin gets everything the team can do and a member gets read, create, write, rename, publish, promote, download, build, and connector read/execute actions. For third-party apps, Spacefast is an OAuth 2.0 authorization server. diff --git a/content/api/connectors.mdx b/content/api/connectors.mdx index ad0ad586..4be01dd9 100644 --- a/content/api/connectors.mdx +++ b/content/api/connectors.mdx @@ -3,12 +3,12 @@ title: Connectors description: Register tool sources, connect accounts, set policy rules, and run connector tools over the API, with the scopes, shapes, and error codes each step uses sidebar: order: 9 - badge: Private Beta + badge: Public Beta --- -Private Beta +Public Beta -Connectors are in Private Beta. A team without access gets `feature_unavailable`. +Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. The connectors API lets a team register tool sources, connect accounts, set policy rules, and run tools. Every operation sits under `/v1/connectors` with the `Connectors` tag. For the concepts and the dashboard, see [Team connectors](/team-connectors). To show a connection's data on a Space's pages, see [Connectors](/connectors). @@ -20,9 +20,13 @@ The connectors API lets a team register tool sources, connect accounts, set poli | `connectors:write` | Register and remove connectors, connect and disconnect accounts, set policy rules. Includes `connectors:read` | | `connectors:execute` | Create and resume runs. Includes `connectors:read` | -`connectors:write` does not include `connectors:execute`, and `connectors:execute` does not include `connectors:write`. A dashboard session has these actions for team owners and admins only. See [Authentication](/api/authentication). +`connectors:write` does not include `connectors:execute`, and `connectors:execute` does not include `connectors:write`. -Connector routes are team-scoped but carry no team in the path. Pass `?team=` when your credential can act for more than one team. Without it, the request fails with `team_required`. A team with connectors turned off answers `feature_unavailable`. +A signed-in session compiles scopes from the caller's team role: team owners and admins receive all three scopes, and team members receive `connectors:read` and `connectors:execute`. Team policy rules and per-credential connection limits still apply to every member call. + +To limit an API key to specific connections, pass `connectorAccess: { connectionIds: ["cxn_…"] }` when creating or updating the key (`POST /v1/api-keys` or `PATCH /v1/api-keys/{apiKeyId}`). Send `connectorAccess: null` to remove the limit. OAuth grants can be limited to specific connections on the consent screen or updated later on **Connected apps**. See [Authentication](/api/authentication). + +Connector routes are team-scoped but carry no team in the path. Pass `?team=` when your credential can act for more than one team. Without it, the request fails with `team_required`. A team without connectors access answers `feature_unavailable`. ## Register a connector @@ -344,8 +348,14 @@ These codes appear in a failed run's `error`, inside a successful HTTP response | `connector_run_budget_exhausted` | 429 | The run passed its budget of 400 outbound requests or 64 MiB read | | `run_replay_diverged` | 409 | A resumed program made different calls than before the pause | -## Space bindings and agents +## Space bindings, serving, and agents + +A Space manages its connector roles, bindings, site-serving requests, public-serving allowances, and visitor connections under the `Spaces` tag: + +- **Bindings:** `listSpaceConnectorBindings`, `bindSpaceConnector`, and `unbindSpaceConnector`. +- **Site serving:** `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, `denyConnectorServingRequest`, and `setSpaceConnectorPublicServing`. +- **Visitor connections:** `listVisitorConnectionUsers` and `revokeVisitorConnection`. -A Space binds its connector roles to team connections through `listSpaceConnectorBindings`, `bindSpaceConnector`, and `unbindSpaceConnector` under the `Spaces` tag. See [Connectors](/connectors#bind-an-account). +See [Connectors](/connectors#bind-an-account) for the Space workflow. -Hosted MCP exposes no connector operations. On-device MCP, `sf mcp`, reaches connectors through one gateway tool. See [MCP server](/agents/mcp-server). +Hosted MCP exposes no connector operations. On-device MCP, `sf mcp`, reaches connectors through one gateway tool, `search_connector_tools`. See [MCP server](/agents/mcp-server). diff --git a/content/cli/api-keys.mdx b/content/cli/api-keys.mdx index 43652bc0..1c436bb5 100644 --- a/content/cli/api-keys.mdx +++ b/content/cli/api-keys.mdx @@ -7,14 +7,14 @@ sidebar: API keys authenticate anything that cannot run a browser login: CI jobs, scripts, servers, agents. A key belongs to a team and carries the permissions of the preset you created it with. -All three subcommands need a login or a `--token` of their own, and they act on your default team unless you name another. Every command here also takes the [global flags](/cli#global-flags). +Every subcommand needs a login or a `--token` of its own, and acts on your default team unless you name another. Every command here also takes the [global flags](/cli#global-flags). ## sf api-keys create Create an API key and print its one-time secret. ```text -sf api-keys create [--name ] [--preset ] +sf api-keys create [--name ] [--preset ] [--connection ...] ``` @@ -25,6 +25,7 @@ sf api-keys create [--name ] [--preset ] | `--name=` | none | Human-readable API key name. Set one so you can tell keys apart later | | `--[no-]open` | on | Open the browser. `--no-open` prints the link instead | | `--preset=` | `space_publisher` | Access preset compiled into the key's policy. One of `ci_deploy`, `space_publisher`, `space_admin`, `domain_manager`, `team_admin`, `billing_viewer`. | +| `--connection=` | all team connections | Connector connection (`cxn_…`) the key may use. Repeat for more. Only `team_admin` includes connector access. | ### Presets @@ -42,6 +43,7 @@ sf api-keys create [--name ] [--preset ] ```bash sf api-keys create --name ci sf api-keys create --name domains-bot --preset domain_manager +sf api-keys create --name linear-bot --preset team_admin --connection cxn_abc123 ``` ### Output @@ -112,6 +114,25 @@ A table of keys, and with `--json` the list envelope from the API straight throu `secretPreview` is the only fragment of the secret you ever see again. `lastUsedAt` tells you which keys are dead weight. +## sf api-keys update + +Rename an API key, or change which connector connections it may use. + +```text +sf api-keys update [--name ] [--connection ... | --all-connections] +``` + +| Flag | Default | What it does | +| --- | --- | --- | +| `--name=` | unchanged | New API key name | +| `--connection=` | unchanged | Connector connection (`cxn_…`) the key may use. Repeat for more. Cannot be combined with `--all-connections` | +| `--all-connections` | `false` | Remove the connection limit so the key can use every team connection again | + +```bash +sf api-keys update key_0123456789abcdef --connection cxn_abc123 --connection cxn_def456 +sf api-keys update key_0123456789abcdef --all-connections +``` + ## sf api-keys revoke Revoke an API key. diff --git a/content/cli/connectors.mdx b/content/cli/connectors.mdx index ccc513d5..a970ef21 100644 --- a/content/cli/connectors.mdx +++ b/content/cli/connectors.mdx @@ -3,14 +3,16 @@ title: sf connectors description: Register tool sources for a team, connect accounts, set policy rules, and run connector tools from the terminal sidebar: order: 18 - badge: Private Beta + badge: Public Beta --- -Private Beta +Public Beta -`sf connectors` manages a team's connectors: tool sources, the accounts connected to them, the policy rules that decide what agents may call, and runs. For the concepts and the dashboard, see [Team connectors](/team-connectors). +`sf connectors` manages a team's connectors: tool sources, the accounts connected to them, the policy rules that decide what agents may call, runs, and Space connector roles and bindings. For the concepts and the dashboard, see [Team connectors](/team-connectors). -Connectors are in Private Beta. A team without access gets `feature_unavailable` and exits 2. +Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable` and exits 2. + +To limit an API key to specific connections, pass `--connection ` to `sf api-keys create` or `sf api-keys update`. See [sf api-keys](/cli/api-keys). Every command takes the global flags (`--api-url`, `--profile`, `--token`, `-y`/`--yes`, `--json`) and `-T`/`--team` (team slug, ID, or name, env `SPACEFAST_TEAM`). Without `--team`, the server picks the team your credential acts for. A credential that can act for several teams must name one. See [the CLI overview](/cli). @@ -45,6 +47,46 @@ A table of `SLUG | TITLE | SOURCE | TOOLS | CONNECTIONS`. `CONNECTIONS` shows th With `--json`, the receipt is the API list envelope `{ data, pagination }`. +## sf connectors search + +Search the connector catalog: curated presets and the public registry, with connectors already added to your team marked. + +```text +sf connectors search [query] [--source openapi|graphql|mcp] [--limit ] [--cursor ] +``` + +```bash +sf connectors search calendar +sf connectors search --source mcp +``` + +Pass a row's id to `sf connectors create ` to add it. + +## sf connectors inspect + +Show one connector, the connections you can use on it, and its tools with the policy effect each resolves to. + +```text +sf connectors inspect [--query ] [--effect approve|require_approval|block] + [--limit ] [--cursor ] +``` + +```bash +sf connectors inspect hubspot --query deals +``` + +## sf connectors update + +Rename a connector, change the agent-visible description, or re-fetch its source and rebuild its tool list. Connections and policy rules survive a refresh. + +```text +sf connectors update [--title ] [--description ] [--refresh] +``` + +```bash +sf connectors update hubspot --refresh +``` + ## sf connectors create Register a connector. A URL is detected first, and the most confident candidate is registered. Any other value is looked up in the catalog. @@ -179,6 +221,19 @@ sf connectors connections list --owner personal A table of `ID | CONNECTOR | OWNER | NAME | STATUS | TOOLS`. `(default)` marks the connection an agent gets when it names the connector alone. With `--json`, the receipt is `{ data, pagination }`. +## sf connectors connections inspect + +Show one connection's state, whether site serving is on, and the tools it reaches with the policy effect each resolves to. + +```text +sf connectors connections inspect [--query ] + [--effect approve|require_approval|block] [--limit ] [--cursor ] +``` + +```bash +sf connectors connections inspect cxn_abc123 +``` + ## sf connectors connections connect Connect an account. @@ -693,16 +748,51 @@ The same as `sf connectors run`, with the same exit codes. | `connector_approval_required` | 2 | No action, and nobody has decided yet | | `connector_run_not_resumable` | 30 | The run already settled, or someone else claimed the decision | -## Space bindings +## Space bindings, roles, serving, and visitors + +These commands manage how a Space declares roles, binds team connections, turns on site serving, and handles visitor accounts. Space-scoped commands require `--space` or `SPACEFAST_SPACE` (without one, they fail with `validation_error` and exit 2). See [Connectors](/connectors). -These three commands connect a Space's connector roles to team connections. They require `--space` or `SPACEFAST_SPACE`. For roles and bindings, see [Connectors](/connectors). +### Bindings | Command | What it does | | --- | --- | -| `sf connectors bindings --space ` | List the Space's roles: `ROLE | AS | CONNECTOR | SOURCE | CONNECTION | STATE` | +| `sf connectors bindings --space ` | List the Space's roles: `ROLE \| AS \| CONNECTOR \| SOURCE \| CONNECTION \| STATE` | | `sf connectors bind --space ` | Bind one role to a connection id | | `sf connectors unbind --space ` | Remove one binding. Prompts unless you pass `--yes` | -Without `--space` or `SPACEFAST_SPACE`, each fails with `validation_error` and exit 2. +### Role overrides -`sf connectors` also has `serving` and `public-serving set` commands. Run `sf connectors serving --help` for their flags. +Change a Space's connector roles without a publish. Overrides replace the config file's role of the same name and apply to the live version right away. + +| Command | What it does | +| --- | --- | +| `sf connectors roles list --space ` | List every role the live version serves, its source, its state, and any roles turned off here. Aliased as `ls` | +| `sf connectors roles set --space ` | Add or update a role (`--connector`, `--as team\|personal\|visitor`, `--tools`, `--args`, `--cache`, `--wait`) | +| `sf connectors roles remove --space ` | Turn off a role so pages calling it get `connector_role_unknown`. Aliased as `rm`. Prompts unless you pass `--yes` | +| `sf connectors roles reset --space ` | Drop the Space's override and hand the role back to the config file | + +```bash +sf connectors roles set crm --connector hubspot --tools list_deals --cache 60s --space example +sf connectors roles list --space example +``` + +### Site serving and public serving + +A team connection serves a Space only after site serving is turned on. On a public Space (or one shared by link or password), a team owner or admin must also allow public serving per role. + +| Command | What it does | +| --- | --- | +| `sf connectors serving create --space ` | Ask team owners and admins to turn site serving on for a role's bound connection (`csr_…`) | +| `sf connectors serving list [--status pending\|approved\|denied\|canceled]` | List the team's site-serving requests. Aliased as `ls` | +| `sf connectors serving inspect ` | Show one site-serving request and whether it is still pending | +| `sf connectors serving approve ` | Approve a request and turn site serving on (owners and admins) | +| `sf connectors serving deny ` | Deny a request and leave site serving off (owners and admins) | +| `sf connectors serving set [--admin-only \| --no-admin-only] [--allow \| --any-connector]` | View or update the team's site-serving policy (owners and admins) | +| `sf connectors public-serving set --enable\|--no-enable --space ` | Allow or stop a `team` role from serving a public, link-shared, or password-protected Space (owners and admins) | + +### Visitor accounts + +| Command | What it does | +| --- | --- | +| `sf connectors visitors list --space ` | List Space users who connected an account for `visitor` roles. Aliased as `ls` | +| `sf connectors visitors revoke --space ` | Disconnect one Space user's account for one `visitor` role. Prompts unless you pass `--yes` | diff --git a/scripts/pricing-next.mjs b/scripts/pricing-next.mjs index 22d2b120..477cdb0d 100644 --- a/scripts/pricing-next.mjs +++ b/scripts/pricing-next.mjs @@ -168,7 +168,7 @@ const FEATURES = [ row("Sign in with Spacefast for your apps", null, all(BETA)), row("Managed content", null, all(BETA)), row("Tag Manager", null, all(BETA)), - row("Connectors to other services", "Connect services like Linear or Google once and let agents and Spaces use them.", all(SOON)), + row("Connectors to other services", "Connect services like Linear or Google once and let agents and Spaces use them. Public Beta on Go, Pro, and Enterprise.", [NO, BETA, BETA, BETA], "beta"), row("Store and payments", "Sell digital downloads and physical products, with checkout and orders. In private beta.", all(BETA), "beta"), row("Draw on pages when giving feedback", null, all(SOON)), ]], From 2830a7c218c358a79bdb51c33bd308781ac91da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?batuhan=20i=C3=A7=C3=B6z?= Date: Tue, 24 Nov 2026 20:39:19 +0000 Subject: [PATCH 2/5] Rebuild Connectors docs from first principles for Public Beta --- content/(account)/api-keys.mdx | 2 +- content/(concepts)/teams.mdx | 2 +- content/(dynamic)/connectors.mdx | 396 ++++++++++--------------- content/(dynamic)/functions.mdx | 2 +- content/(dynamic)/meta.ts | 2 +- content/(dynamic)/space-connectors.mdx | 307 +++++++++++++++++++ content/(dynamic)/team-connectors.mdx | 221 -------------- content/(reference)/config-file.mdx | 2 +- content/api/connectors.mdx | 4 +- content/api/index.mdx | 2 +- content/cli/connectors.mdx | 6 +- 11 files changed, 469 insertions(+), 477 deletions(-) create mode 100644 content/(dynamic)/space-connectors.mdx delete mode 100644 content/(dynamic)/team-connectors.mdx diff --git a/content/(account)/api-keys.mdx b/content/(account)/api-keys.mdx index bf8a622e..18998862 100644 --- a/content/(account)/api-keys.mdx +++ b/content/(account)/api-keys.mdx @@ -88,7 +88,7 @@ sf api-keys update key_0123456789abcdef --connection cxn_abc123 --connection cxn sf api-keys update key_0123456789abcdef --all-connections ``` -Over the API, pass `connectorAccess: { connectionIds: ["cxn_abc123"] }` on `POST /v1/api-keys` or `PATCH /v1/api-keys/{apiKeyId}`, or `connectorAccess: null` to remove the limit. For OAuth apps and CLI logins, choose specific connections under **Choose Connections** on the consent screen, or edit them later on **Connected apps**. See [Team connectors](/team-connectors). +Over the API, pass `connectorAccess: { connectionIds: ["cxn_abc123"] }` on `POST /v1/api-keys` or `PATCH /v1/api-keys/{apiKeyId}`, or `connectorAccess: null` to remove the limit. For OAuth apps and CLI logins, choose specific connections under **Choose Connections** on the consent screen, or edit them later on **Connected apps**. See [Connectors](/connectors). ## What an agent grant cannot do diff --git a/content/(concepts)/teams.mdx b/content/(concepts)/teams.mdx index 32d19030..2a82402a 100644 --- a/content/(concepts)/teams.mdx +++ b/content/(concepts)/teams.mdx @@ -93,7 +93,7 @@ Things that catch people out: On **Members**, each row has role and removal actions for owners and admins. Removing someone takes away their access to the team and every Space in it. Anything they published stays where it is, and you can invite them back later. -If the team uses [Connectors](/team-connectors), the removal review lists the departing member's connector dependencies. Their personal connections disconnect automatically along with any Space bindings pointing to them. Team connections they created stay active so you can reconnect or rebind them without downtime. +If the team uses [Connectors](/connectors), the removal review lists the departing member's connector dependencies. Their personal connections disconnect automatically along with any Space bindings pointing to them. Team connections they created stay active so you can reconnect or rebind them without downtime. Two guards you cannot talk your way past: diff --git a/content/(dynamic)/connectors.mdx b/content/(dynamic)/connectors.mdx index 5eff75c3..b20a18ff 100644 --- a/content/(dynamic)/connectors.mdx +++ b/content/(dynamic)/connectors.mdx @@ -1,331 +1,237 @@ --- title: Connectors -description: Show live data from your team's tools on any Space page. Declare a role in your config, call it from the page, and the account's credentials never reach the browser. +description: Connect an external service once and let your AI agents, Spaces, and scripts call its tools while credentials stay sealed in Spacefast. sidebar: badge: Public Beta --- Public Beta -Connectors put live data from your team's tools on any page of a Space, with no backend to write and no keys in the page. You declare a role in your config, bind an account to it, and the page calls `/__spacefast/connectors//`. Spacefast runs the tool with the account's credentials on the server and answers the page with JSON. +Connectors let your team connect an external service once—an OpenAPI spec, a GraphQL endpoint, or a remote MCP server—and call its tools from AI agents, Space pages, Functions, and scripts. Credentials stay sealed in Spacefast and never enter prompts, source code, or browsers. -Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. To register tool sources, connect accounts, and manage agent rules, see [Team connectors](/team-connectors). +Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. Enterprise adds team-wide connector allowlists, blocklists, and site-serving controls. -## Declare a role +## How Connectors work -A role names one connector, the tools a page may call through it, and whose account answers. Put it under `connectors` in `spacefast.config.ts`: +Four building blocks cover everything Connectors do: -```ts spacefast.config.ts -import { defineConfig } from "spacefast/config"; +| Concept | What it is | +| --- | --- | +| **Connector** | A tool source your team registers once (from the catalog or by pasting any URL). Its slug becomes the tool namespace, such as `hubspot` or `linear`. | +| **Connection** | One authenticated account (`cxn_…`) on a connector, owned by the **Team** (shared) or **Personal** (only yours within this team). | +| **Policy** | Rules that decide whether a tool call **Runs freely** (`approve`), **Asks first** (`require_approval`), or is **Blocked** (`block`). | +| **Role** | A Space-level declaration in `spacefast.config.ts` or `sf.jsonc` that exposes chosen tools to a Space's pages and Functions. See [Connectors in Spaces](/space-connectors). | -export default defineConfig({ - connectors: { - crm: { - connector: "hubspot", - tools: ["list_deals"], - args: { list_deals: { pipeline: "sales" } }, - cache: "60s", - }, - }, -}); -``` - -Or in `sf.jsonc`, with the same shape: - -```jsonc sf.jsonc -{ - "$schema": "https://spacefast.com/schemas/sf.json", - "connectors": { - "crm": { - "connector": "hubspot", - "tools": ["list_deals"], - "args": { "list_deals": { "pipeline": "sales" } }, - "cache": "60s" - } - } -} -``` +## Three ways to use a connector -When both files exist, `spacefast.config.ts` wins. Publish to apply the roles, because each version freezes the roles it was published with. - -The tool names and arguments on this page, such as `list_deals` and `stage`, are examples. Use the names your connection lists: [`listConnectionTools`](/api/reference/connectors/listconnectiontools) returns each tool with its input schema. - -| Key | Required | What it does | +| Surface | Best for | How it runs | | --- | --- | --- | -| `connector` | yes | The slug your team registered the connector under, such as `hubspot`. `sf connectors list` shows them | -| `tools` | yes | A list of tool names, or `"*"` for every tool on the connection, including tools it gains later | -| `as` | no | Whose account answers: `team` (the default), `personal`, or `visitor`. See [Who reads and who writes](#who-reads-and-who-writes) | -| `args` | no | Argument values pinned per tool, applied on the server. See [Pinned arguments](#pinned-arguments) | -| `cache` | no | How long viewers share one read: `"30s"` by default, up to a day (`"1440m"`). `"0"` turns sharing off. See [Shared reads](#shared-reads) | +| **AI agents (On-Device MCP)** | Letting Claude Code, Cursor, Codex, or Claude Desktop search and call your team's tools | `sf mcp` exposes one gateway tool, `search_connector_tools`, under your team's policy and approval rules. Hosted MCP and `sf mcp proxy` intentionally omit connector tools. See [MCP server](/agents/mcp-server). | +| **Space pages and Functions** | Showing live data or running actions on a Space with no backend to write | Declare a role, bind an account, and call `space.connectors..()` or `env.CONNECTORS`. See [Connectors in Spaces](/space-connectors). | +| **CLI and API** | Scripts, CI jobs, or testing a single call | Run one tool or a multi-tool sandbox program with `sf connectors run` or `POST /v1/connectors/runs`. See [sf connectors](/cli/connectors) and the [connectors API](/api/connectors). | -Role names are camelCase and start with a lowercase letter, up to 64 characters. A Space declares at most 32 roles, and a role lists at most 200 tools. Tool names use letters, digits, `_`, `.`, `:`, and `-`. `connect`, `callback`, and `disconnect` are reserved. +## Who can do what -## Bind an account +- **Team owners and admins** manage connectors in the dashboard: registering tool sources, connecting or disconnecting team accounts, and editing team policy rules (`connectors:write`). +- **Team members** can list and run team connections through the API, CLI, and On-Device MCP (`connectors:read` and `connectors:execute`), subject to team policy rules and any per-credential connection limits. The team's **Connectors** dashboard pages remain owner and admin only. +- **API keys** need connector scopes: `connectors:read` reads connectors, connections, tools, rules, and runs; `connectors:write` manages connectors, accounts, and rules; `connectors:execute` runs tools. `write` and `execute` each include `read`, and neither includes the other. See [API keys](/api-keys). -A `team` or `personal` role needs an account bound to it. Add the connector to your team and connect an account from the team's **Connectors** page, or from the CLI: +## Quickstart -```bash -sf connectors create hubspot --slug hubspot -sf connectors connections connect hubspot -``` - -Publishing a live version binds a role for you when exactly one eligible connection exists. The publish receipt lists any roles that still need one. Bind the rest yourself: - -```bash -sf connectors bindings --space example -sf connectors bind crm cxn_abc123 --space example -``` + + + Open **Connectors** in the team sidebar, click **Browse Connectors**, and click **Add** on a catalog row—or paste any API or MCP URL and click **Detect**. From the terminal: -In the dashboard, a team owner or admin opens the Space's **Integrations** and chooses **Bind account**. Through the API, it's [`bindSpaceConnector`](/api/reference/spaces/bindspaceconnector), and [`listSpaceConnectorBindings`](/api/reference/spaces/listspaceconnectorbindings) shows each role's state. + ```bash + sf connectors search linear + sf connectors create linear + ``` + + + Open the connector, click **Connect Account**, pick **Team** or **Personal**, and finish OAuth sign-in or enter the required API key. From the terminal: -A `visitor` role binds nothing. Each viewer connects their own account. + ```bash + sf connectors connections connect linear + ``` + + + Open **Policies** in the connectors header to decide which tools run freely, ask a person first, or stay blocked: -## Who reads and who writes + ```bash + sf connectors policies add '*' --action require_approval + sf connectors policies explain cxn_abc123/issues.list + ``` + + + Try it from the **Tools** page, from the CLI, or from a local agent connected to `sf mcp`: -| `as` | Whose account | Who reads through it | Who writes through it | -| --- | --- | --- | --- | -| `team` | A team connection with site serving on | Everyone who can open the Space | A signed-in current member of the owning team | -| `personal` | The connection of the person who bound it | Everyone who can open the Space, which only works while the Space is private | A signed-in current member of the owning team | -| `visitor` | Each viewer's own connection | That viewer | That viewer | + ```bash + sf connectors run --tool cxn_abc123/issues.list --args '{"limit":5}' + ``` + + -The connectors route sits behind the Space's own access check, so the data is never more public than the pages. A private Space's data stays private. A share link or password admits anyone with the share link or the password, and they read too. +The dashboard pages live under **Connectors** in the team sidebar. A switch in the header moves between **Connectors**, **Runs**, and **Policies**. -That's why two roles have extra rules: +## Add a connector -- **`team` on a Space anyone can open.** When the Space is public, or shared by link or password, a `team` role serves only after a team owner or admin allows it: `sf connectors public-serving set crm --enable --space example`. Until then, calls answer `connection_forbidden`. The allowance covers the account bound when it was given; rebinding the role takes it away. -- **`personal` needs a private Space.** A `personal` role works only while the Space is private and has no share link or password. Otherwise every call answers `connection_forbidden`. +### From the catalog -Writes through a `team` or `personal` role require a signed-in current member of the owning team. Anyone else—an anonymous visitor, an external guest, or a non-member—reads through a `team` role and never writes through it: the call answers `connector_write_sign_in_required`. Send viewers to sign in with `space.access.signIn()`. A `visitor` role asks the viewer to sign in first, then to connect their own account. +The catalog lists curated presets, the public registry, and your team's own connectors. It has one row per source type, so a service with an API and an MCP server appears as two rows. -A team's connector policy still applies to every call. A tool it blocks is refused, and a call it holds for approval answers `approval_pending`. +1. Open **Connectors** in the team sidebar and click **Browse Connectors**. +2. Search, or filter by **All**, **API**, **GraphQL**, or **MCP**. +3. Click **Add** on the row you want. -## Previews +The row changes to **View** once added. A row that needs a provider-specific endpoint shows **Set Up** and opens the add form. -Preview and held versions protect your live Space's bindings and shared accounts: +### From any URL -- **No auto-binding on preview publishes.** Publishing a version that doesn't go live leaves existing bindings untouched and binds no new roles. Promoting the version to live (or rolling back to it) binds its roles then. -- **No shared writes from previews.** A preview version can read through already-bound `team` or `personal` roles, but non-read-only tools on shared bindings are refused with `connector_preview_write_not_allowed`. Promote the version to run writes. -- **`visitor` roles work normally in previews**, because each call uses the viewer's own connected account. +Paste any URL a service published. Detection inspects it, so the endpoint it registers can differ from the URL you pasted. -## Call it from a page +1. On **Browse**, paste the URL into the search box and click **Detect**. +2. Click **Add Connector** on the candidate you want. +3. Check **Name**, **Namespace**, and **Description**, then click **Register**. -Install the client: +**Namespace** is the connector slug: lowercase letters, digits, and dashes, starting with a letter or digit. Agents read **Description** when choosing between connectors. You enter no credentials here; authentication comes from the source, and Spacefast asks remote MCP servers how they authenticate. ```bash -npm install @spacefast/client -``` - -Then generate the typed module and call the role: - -```ts -import { space } from "./spacefast.generated"; - -const answer = await space.connectors.crm.list_deals({ stage: "won" }); -if (answer.state === "ok") render(answer.data); -else showNotice(answer.message); -``` - -Each tool knows its HTTP method. A read-only tool reads with `GET`, and a tool that writes sends a `POST`. Pass `{ idempotencyKey }` as the last argument to make a retried write run once. - -To keep a read live, watch it. A watched read refreshes on an interval and when the page regains focus, and identical reads share one request. Only reads can be watched, since every refresh would run a write again. - -```ts -const deals = space.connectors.crm.list_deals.watch({ stage: "won" }, { every: "60s" }); -const stop = deals.subscribe(() => render(deals.getSnapshot())); -``` - -`every` takes milliseconds or `"30s"`, `"5m"`, `"1h"`, never under one second. - -### React - -`useConnector` from `@spacefast/client/react` watches a read: - -```tsx -import { useConnector } from "@spacefast/client/react"; -import { space } from "./spacefast.generated"; - -export function Deals() { - const deals = useConnector(space.connectors.crm.list_deals, { stage: "won" }, { every: "60s" }); - if (deals.state === "ok") return ; - return

{deals.message ?? "Loading…"}

; -} +sf connectors detect https://api.example.com +sf connectors create https://api.example.com/openapi.json ``` -It returns `data`, `state`, `message`, `connectUrl`, `approvalUrl`, `cachedAt`, `refreshing`, `error`, and `refresh`. `data` keeps the last good answer while a refresh runs or fails. Components that ask the same question share one request. - -### Pages without a build - -A plain HTML page imports the same client from the Space itself: - -```html - -``` - -Without generated types, every tool reads with `GET`. Pass `{ method: "POST" }` to a tool that writes. The published version's types are at `/__spacefast/client.d.ts`. - -The route also answers plain `fetch`. Query parameters are string arguments (`?stage=won`), and `__args` takes a JSON object for typed values: - -```js -const args = encodeURIComponent(JSON.stringify({ stage: "won", limit: 5 })); -const response = await fetch(`/__spacefast/connectors/crm/list_deals?__args=${args}`); -const { state, data } = await response.json(); -``` +1. On **Connectors**, open a connector row and click **Connect Account**. +2. Under **Who can use it**, choose **Team** or **Personal**. +3. If the connector offers more than one auth method, pick one under **Method**. +4. Optional: add a **Label** so agents can tell accounts apart when a connector has more than one. +5. Click **Connect**. -A `POST` sends its arguments as a JSON body of at most 64 KiB. Other sites' pages can't call the route with a viewer's cookies. A browser read that says it came from elsewhere, through `Sec-Fetch-Site` or an `Origin` naming another host, answers `browser_origin_not_allowed`. A read that sends neither header passes that check but still goes through the Space's access check. A write always needs an `Origin` naming this host or `Sec-Fetch-Site: same-origin`, which browsers send for you. Every answer is `private, no-store`. +**Team** shares the account with the team and agents acting for it. **Personal** keeps it yours, only within this team. API keys can connect **Team** accounts only. -## The typed client +Connecting ends in one of three states: -`sf client` writes `spacefast.generated.ts` next to your config file, typed from the connections behind your roles: +| Result | What to do | +| --- | --- | +| `connected` | Ready to use | +| `authorization_required` | Complete OAuth sign-in at the provider (`Open Sign-In` in the dashboard, or open the printed URL from the CLI). The callback finishes the connection automatically | +| `input_required` | Provide the fields the connector asks for and connect again. Provider setup notes and links appear inline (or via [`getConnectorCredentialGuidance`](/api/reference/connectors/getconnectorcredentialguidance)) | ```bash -sf client +sf connectors connections connect stripe --api-key "$STRIPE_KEY" +sf connectors connections connect linear --owner personal ``` -You rarely run it by hand. `sf dev` and `sf publish` regenerate the module before the build in any project that installs `@spacefast/client`. With roles declared, a publish whose regeneration fails stops rather than ship against stale types, and `sf dev` warns and keeps going. `--out` writes the module somewhere else. +A tool address is `/`. While a connector has one usable account, `/` also works. Adding a second account turns the short form into `connection_ambiguous`, so address tools by connection id. -In the generated module, pinned arguments are left out of each tool's type. A tool name that isn't an identifier becomes a quoted key, such as `space.connectors.github["issues.list"]()`. A tool whose source publishes no output schema returns `unknown`. +## Policy rules and approvals -## What a page renders +A policy rule pairs an address pattern with an action: -A call answers `{ state, data }`. When `state` is `ok`, `data` holds the tool's result. Any other state carries `data: null` and a `message` you can show as is. +| Pattern | Matches | +| --- | --- | +| `*` | Every tool | +| `/*` | Every tool on every account of one connector | +| `/` | One tool on every account of one connector | +| `/*` | Every tool of one account | +| `/` | One tool on one account | -| State | What it means | What the page can do | +| Action | Dashboard label | When an agent or tool call matches | | --- | --- | --- | -| `ok` | `data` is the provider's payload. An HTTP-backed tool adds `http` with the upstream `status` and `headers`, and an answer served from a shared read adds `cachedAt` | Render it | -| `unbound` | No account serves this role yet | Tell the viewer it isn't set up. The Space's owner binds an account | -| `connect_required` | A `visitor` role needs this viewer's account | Link to `connectUrl`. See [Visitor accounts](#visitor-accounts) | -| `reconnect_required` | The account's authorization expired | On a `visitor` role, link to `connectUrl`. On a `team` or `personal` role, the team reconnects the account; the answer still carries a `connectUrl`, but it only works for `visitor` roles, so don't show it | -| `approval_pending` | The call is waiting for approval | Say so, and link to `approvalUrl` when it's there | -| `running` | The call is still going | Try again shortly. A watched read retries by itself | +| `approve` | **Runs freely** | Runs immediately | +| `require_approval` | **Ask first** | Parks until a person approves or denies it | +| `block` | **Blocked** | Fails with `connector_tool_blocked` | -Failures a page can't wait out come back as an RFC 9457 problem with a stable `code`, which the client throws as a `ConnectorError` (`status`, `code`, `message`). With `useConnector`, `state` is `error` and `error` holds it. +How rules combine: -| Code | Status | When | -| --- | --- | --- | -| [`connection_forbidden`](/errors/connection_forbidden) | 403 | The team's policy blocks the connector, a read tool, or a write on a `visitor` role; an approval was denied; the account doesn't serve sites; or the Space is too open for the role | -| [`connector_role_unknown`](/errors/connector_role_unknown) | 404 | The live version doesn't declare this role | -| `connector_tool_not_allowed` | 403 | The role's `tools` doesn't list this tool | -| `connector_arg_pinned` | 422 | The call sent a different value for a pinned argument | -| `connector_preview_write_not_allowed` | 403 | A preview version tried to run a non-read-only tool through a shared `team` or `personal` role | -| `connector_write_sign_in_required` | 403 | A write through a `team` or `personal` role from a viewer who isn't signed in as a current member of the owning team | -| [`connector_tool_blocked`](/errors/connector_tool_blocked) | 403 | The team's connector policy blocks this write tool on a `team` or `personal` role | -| [`connector_write_in_read_handler`](/errors/connector_write_in_read_handler) | 403 | A `GET` to a tool that writes. Send a `POST` | -| [`browser_origin_not_allowed`](/errors/browser_origin_not_allowed) | 403 | The call came from another site, or a write without same-origin proof | -| `connectors_unavailable` | 502 or 503 | The provider or Spacefast couldn't answer. Try again | - -### Visitor accounts - -A `visitor` role needs a connector with an OAuth sign-in method, since each viewer signs in to their own account. A connector that only takes API keys can't serve one, and connecting answers `connector_oauth_required`. When the connector needs an OAuth app your team hasn't registered, it answers `connector_oauth_app_required`. - -A `visitor` role's `connectUrl` is `/__spacefast/connectors//connect`. It signs the viewer in if needed, then sends them to the provider and back. Add `?return_to=/some/path` to land somewhere other than `/`. A `POST` to `/__spacefast/connectors//disconnect` from the Space's own page forgets the viewer's account. - -Review or revoke visitor connections from the CLI with `sf connectors visitors list --space example` and `sf connectors visitors revoke --space example`. Through the API, [`listVisitorConnectionUsers`](/api/reference/spaces/listvisitorconnectionusers) lists which Space users connected each role, and [`revokeVisitorConnection`](/api/reference/spaces/revokevisitorconnection) disconnects one user's account for a role. - -## Pinned arguments - -`args` fixes argument values per tool on the server: - -```jsonc sf.jsonc -{ - "connectors": { - "crm": { - "connector": "hubspot", - "tools": ["list_deals"], - "args": { "list_deals": { "pipeline": "sales" } } - } - } -} -``` +- **Most specific pattern wins.** Spacefast evaluates rules by specificity, not creation order. +- **Team rules are a floor.** A **Personal** rule can tighten a **Team** rule, never loosen it. +- **Unmatched tools use the source's own default.** A tool can also ask for approval itself. +- **Pattern and owner are fixed.** To change either, delete the rule and add a new one. Deleting a block hands its tools back to the next matching rule. -Every call to `list_deals` through `crm` runs with `pipeline: "sales"`, whatever the page sends. A call may repeat the pinned value. A different value is refused with `connector_arg_pinned`, and its `pointer` names the argument. Pin anything a viewer shouldn't choose, such as which pipeline, project, or account a public page shows. +Add rules on **Policies** in the connectors header (an API key can add **Team** rules only), or check what an address resolves to without calling it: -## Shared reads +```bash +sf connectors policies add '*' --action require_approval +sf connectors policies explain cxn_abc123/charges.create +``` -A `team` or `personal` role shows every viewer the same account, so every viewer asks the same question. Spacefast answers them together: one upstream read serves everyone for the role's `cache` window. +On Enterprise plans, team owners and admins can also set a team-wide connector allowlist or blocklist and restrict which connectors may serve Spaces. -- **The key** is the Space, role, tool, and the final arguments with pins applied. Argument order doesn't matter. -- **One viewer fills a cold key.** Others arriving meanwhile wait for that read rather than starting their own. -- **The budget** is 60 upstream reads per role per rolling minute, for each Space. -- **Stale serving.** When the budget is spent, the last value keeps answering for up to an hour past its window. With no value to fall back on, the call answers `connectors_unavailable`. -- **`cachedAt`** appears on an `ok` answer served from the shared value and says when it was fetched. The read that fetches it answers without one. +### Decide a parked run -Only successful reads are shared. `cache: "0"` turns sharing off, but each call still spends the budget. Writes, `visitor` roles, and tools the team's policy holds for approval are never shared: each call runs. +A parked run returns an `approvalUrl` and appears in two dashboard views: -## Serving a team account on Spaces +- **Approvals**, under **Connector calls awaiting approval**. +- **Runs**, filtered to **Waiting on you**. Click **Review** to inspect the matched rule, arguments, and deadline before approving, or click **Deny** on the row. -A team connection reads for a Space's viewers only once site serving is on for it. Until then, the role's state is `needs_serving_grant` and calls answer `connection_forbidden`. +**Approve** runs the call once. **Deny** fails it with `connector_tool_blocked`. A parked run expires after 15 minutes. -If you may turn serving on, do it from the connection in the dashboard, or with `sf connectors connections update cxn_abc123 --serving`. If you can't, ask: +Approvals require a signed-in person. A CLI login or API key trying to approve fails with `human_approval_required`; read back a person's decision with `sf connectors run inspect` or `sf connectors run resume `. Pass `--deny-unattended` on `sf connectors run` to fail immediately with `connector_approval_required` instead of parking. -```bash -sf connectors serving create crm --space example -``` +## Find and run tools -The answer is a pending request with a `csr_` id, and asking again returns the same one. When you're allowed to grant serving yourself, it turns on at once and the request comes back `approved`. +Click **See tools** on a connector row (or open **Connector tools** from the command palette) to browse every reachable tool, its summary, resolved policy effect, input schema, and source-declared safety (**Read-only**, **Writes**, or **Destructive**). Open any tool to run it directly from a form or JSON payload. -Team owners and admins get a notification. They decide in the dashboard, or with: +From the CLI, inspect a connector or connection, then run a single tool or a sandboxed program: ```bash -sf connectors serving list -sf connectors serving approve csr_abc123 -sf connectors serving deny csr_abc123 +sf connectors inspect hubspot --query deals +sf connectors connections inspect cxn_abc123 +sf connectors run --tool cxn_abc123/issues.list --args '{"limit":5}' ``` -Approving turns serving on, and the role's state flips to ready. On Enterprise plans, owners and admins can keep serving decisions to admins and limit which connectors may serve sites with `sf connectors serving set`. +| Status | Meaning | +| --- | --- | +| `running` | Still working. Check again with `sf connectors run inspect` | +| `awaiting_approval` | Parked on a person's decision | +| `succeeded` | Finished. Output is in `result` | +| `failed` | Finished with an RFC 9457 problem document in `error` | +| `expired` | Parked past 15 minutes without a decision | -The API operations are `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, and `denyConnectorServingRequest`. Public serving for a `team` role is `setSpaceConnectorPublicServing`. +`sf connectors run` waits up to 30 seconds by default (`--wait` up to 120 seconds) and exits `1` on `failed` or `expired`. -## Change roles without a publish +## Limit which connections a key or app can use -The Space's **Integrations** page lists every role. An override lives with the Space, not in your config file, and replaces that one role: +By default, a credential with connector scopes reaches every team connection it is allowed to use. Narrow it to specific connections when a script, CI job, or AI client should touch only one account: -- **Turn off** removes a role your config declares. It moves to **Removed roles**, where **Restore** brings it back. -- **Use config file** drops an override and returns the role to what the file says. +- **API keys:** Pass `--connection ` (repeatable) on `sf api-keys create` or `sf api-keys update`, or pass `connectorAccess: { connectionIds: ["cxn_abc123"] }` over the API. Remove the limit with `--all-connections` or `connectorAccess: null`. See [API keys](/api-keys#limit-connector-access). +- **OAuth apps and CLI logins:** Open **Choose Connections** on the consent screen, or edit the allowlist later on **Connected apps** without re-authorizing. -From the CLI, `sf connectors roles` manages the same overrides: +A connection outside a credential's allowlist answers `404` as if it doesn't exist. -```bash -sf connectors roles list --space example -sf connectors roles set crm --connector hubspot --tools list_deals --cache 60s --space example -sf connectors roles remove crm --space example -sf connectors roles reset crm --space example -``` - -Saving re-applies the live version, so the change takes effect without a publish. The next publish keeps the overrides. +## Keep connections working and clean up -Through the API, overrides are `config.connectors` on [`updateSpace`](/api/reference/spaces/updatespace). An entry replaces the file's role of the same name, and `null` removes it. `config` replaces the Space's whole stored overlay, so read it from [`getSpace`](/api/reference/spaces/getspace) first and send it back with your change, along with its `settingsDigest` as `baseSettingsDigest`. +Open a connector's **Accounts** tab for connection actions: -## Call it from Functions +| Action | What it does | CLI | +| --- | --- | --- | +| **Edit…** | Changes **Label** and the agent note, **What it's for** | `sf connectors connections update` | +| **Check Health** | Probes the provider without changing state | `sf connectors connections health` | +| **Re-Sync Tools** | Re-reads the tool list so added or removed tools show up | `sf connectors connections refresh` | +| **Reconnect…** | Re-authenticates or replaces a key while keeping the id, label, policies, and Space bindings | `sf connectors connections reconnect` | +| **Disconnect…** | Purges the stored credential permanently | `sf connectors connections disconnect` | -A [Functions](/functions) worker whose version declares roles gets `env.CONNECTORS`: +Token refresh happens automatically; reconnect only when a connection reports `needs_reauth` or `degraded`, or to rotate an API key. A disconnected account cannot be reconnected—connect again to create a new connection id. -```js functions/deals.js -export async function GET(request, { env }) { - const deals = await env.CONNECTORS.crm.list_deals({ stage: "won" }); - return Response.json(deals); -} -``` +### When a member leaves -The role proxy returns the tool's result, or throws a `ConnectorCallError` whose `state.code` says why, such as `connect_required` or `forbidden`. `env.CONNECTORS.call("crm", "list_deals", args)` returns `{ state, result }` instead of throwing. The worker forwards the request's signed-in viewer, so `visitor` roles, preview write rules, and writes follow the same rules as a page. Calls from a worker are never shared reads. +Before removing a team member, the dashboard shows their connector dependencies: -## Call it from outside the Space +- **Personal connections** owned by that member disconnect automatically on removal. Stored credentials are purged, pending sign-ins are canceled, and any Space bindings pointing to them are removed. +- **Team connections** the departing member created stay active, listed during removal so an owner or admin can reconnect them with a team-owned account or rebind affected Spaces if needed. -The page route is for the Space's own pages: it acts for the viewer, and other sites' pages can't use it. From anywhere else, such as a script, a CI job, or an agent, run the tool with your own API key through [`createConnectorRun`](/api/reference/connectors/createconnectorrun): +### Remove a connector ```bash -curl -X POST https://api.spacefast.com/v1/connectors/runs \ - -H "Authorization: Bearer $SPACEFAST_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{"input":{"kind":"tool","address":"cxn_abc123/list_deals","args":{"stage":"won"}},"waitMs":10000}' +sf connectors delete linear --yes ``` -The address is `/`, straight off [`listConnectionTools`](/api/reference/connectors/listconnectiontools). From the CLI, it's `sf connectors run --tool cxn_abc123/list_deals --args '{"stage":"won"}'`. A run answers to your credential and the team's policy, not to a role: no pins, no shared reads. Read the run's status and result before treating it as done. +Deleting a connector disconnects every account on it, then deletes the connector and its tools. Built-in connectors cannot be removed. -## First +## Next steps -Pages in a [First](https://first-docs.space.fast/) app call roles with `@spacefast/client`, like any other page. Declare the roles in `spacefast.config.ts` or `sf.jsonc` as above. First's server code can't call connectors yet. +- Put live connector data on any Space page or Function: [Connectors in Spaces](/space-connectors) +- Manage everything from the terminal: [sf connectors](/cli/connectors) +- Call every endpoint directly: [Connectors API](/api/connectors) diff --git a/content/(dynamic)/functions.mdx b/content/(dynamic)/functions.mdx index 139e8ffa..0a370084 100644 --- a/content/(dynamic)/functions.mdx +++ b/content/(dynamic)/functions.mdx @@ -130,7 +130,7 @@ Outbound requests from a worker leave from Cloudflare's shared network addresses `env` carries the space's environment variables. See [Environment variables](/environment-variables) for how to set them. -`env.CONNECTORS` calls your Space's [connector roles](/connectors#call-it-from-functions) when the version declares any. +`env.CONNECTORS` calls your Space's [connector roles](/space-connectors#call-it-from-functions) when the version declares any. `env.DB` is always there. It is D1-shaped, so `env.DB.prepare(sql).bind(...).all()` is the call you already know. It reaches the space's own database through a broker, so no connection string ever lands in the bundle. diff --git a/content/(dynamic)/meta.ts b/content/(dynamic)/meta.ts index 922f5c9b..2e9af7a6 100644 --- a/content/(dynamic)/meta.ts +++ b/content/(dynamic)/meta.ts @@ -4,5 +4,5 @@ export default defineMeta({ title: "Dynamic", collapsed: false, order: 5, - pages: ["zero-runtime", "functions", "connectors", "team-connectors", "database", "environment-variables", "crons", "object-storage", "logs", "wordpress"], + pages: ["zero-runtime", "functions", "connectors", "space-connectors", "database", "environment-variables", "crons", "object-storage", "logs", "wordpress"], }); diff --git a/content/(dynamic)/space-connectors.mdx b/content/(dynamic)/space-connectors.mdx new file mode 100644 index 00000000..60d89acd --- /dev/null +++ b/content/(dynamic)/space-connectors.mdx @@ -0,0 +1,307 @@ +--- +title: Connectors in Spaces +description: Show live data from your team's connectors on any Space page or Function. Declare a role in your config, bind an account, and call it with no backend code and no credentials in the browser. +sidebar: + badge: Public Beta +--- + +Public Beta + +Put live data from a connected service on any page of a Space—or inside a [Function](/functions)—with no backend to write and no keys in the browser. You declare a role in your Space config, bind an account to it, and call `/__spacefast/connectors//`. Spacefast runs the tool with the account's sealed credentials on the server and returns JSON. + +Connectors are in Public Beta on Go, Pro, and Enterprise plans. If you haven't added a connector or connected an account to your team yet, start with [Connectors](/connectors). + +## How a Space call works + +1. **Declare a role** in `spacefast.config.ts` or `sf.jsonc` naming the connector, allowed tools, account mode (`team`, `personal`, or `visitor`), optional pinned arguments, and read cache window. +2. **Bind an account** (for `team` or `personal` roles) and enable site serving on the connection. Publishing a live version auto-binds any role with a single eligible connection. +3. **Call the role** from a page using `@spacefast/client`, `/__spacefast/client.js`, plain `fetch`, or from a Function via `env.CONNECTORS`. + +## Declare a role + +Put roles under `connectors` in `spacefast.config.ts`: + +```ts spacefast.config.ts +import { defineConfig } from "spacefast/config"; + +export default defineConfig({ + connectors: { + crm: { + connector: "hubspot", + tools: ["list_deals"], + args: { list_deals: { pipeline: "sales" } }, + cache: "60s", + }, + }, +}); +``` + +Or in `sf.jsonc`, with the same shape: + +```jsonc sf.jsonc +{ + "$schema": "https://spacefast.com/schemas/sf.json", + "connectors": { + "crm": { + "connector": "hubspot", + "tools": ["list_deals"], + "args": { "list_deals": { "pipeline": "sales" } }, + "cache": "60s" + } + } +} +``` + +When both files exist, `spacefast.config.ts` wins. Publish to apply the roles, because each version freezes the roles it was published with. + +The tool names and arguments on this page, such as `list_deals` and `stage`, are examples. Check what your connection exposes with `sf connectors connections inspect ` or [`listConnectionTools`](/api/reference/connectors/listconnectiontools). + +| Key | Required | What it does | +| --- | --- | --- | +| `connector` | yes | Connector slug registered on your team, such as `hubspot`. `sf connectors list` shows them | +| `tools` | yes | A list of tool names, or `"*"` for every tool on the connection, including tools added later | +| `as` | no | Whose account answers: `team` (default), `personal`, or `visitor`. See [Who reads and who writes](#who-reads-and-who-writes) | +| `args` | no | Argument values pinned per tool on the server. See [Pinned arguments](#pinned-arguments) | +| `cache` | no | How long viewers share one read: `"30s"` by default, up to `"1440m"` (1 day). `"0"` disables sharing. See [Shared reads](#shared-reads) | + +Role names are camelCase, start with a lowercase letter, and are up to 64 characters. A Space declares at most 32 roles, and each role lists at most 200 tools. Tool names use letters, digits, `_`, `.`, `:`, and `-`. `connect`, `callback`, and `disconnect` are reserved. + +## Bind an account and turn on site serving + +A `team` or `personal` role needs a bound account (`visitor` roles bind nothing; each viewer connects their own). + +Publishing a live version binds a role automatically when exactly one eligible connection exists. The publish receipt lists roles that still need a binding or site serving. Bind remaining roles from the CLI or the Space's **Integrations** page: + +```bash +sf connectors bindings --space example +sf connectors bind crm cxn_abc123 --space example +``` + +Through the API, use [`listSpaceConnectorBindings`](/api/reference/spaces/listspaceconnectorbindings) and [`bindSpaceConnector`](/api/reference/spaces/bindspaceconnector). + +### Site serving for team connections + +A `team` connection serves Space viewers only after site serving is turned on. Until then, the role's state is `needs_serving_grant` and calls answer `connection_forbidden`. + +Owners and admins can turn serving on directly from the connection in the dashboard or with `sf connectors connections update cxn_abc123 --serving`. Anyone else can request it: + +```bash +sf connectors serving create crm --space example +``` + +That returns a pending request (`csr_…`), or approves immediately if you already have permission. Owners and admins receive a notification and decide in the dashboard or CLI: + +```bash +sf connectors serving list +sf connectors serving approve csr_abc123 +sf connectors serving deny csr_abc123 +``` + +On Enterprise plans, owners and admins can restrict serving approvals to admins and allowlist which connectors may serve Spaces with `sf connectors serving set`. The API operations are `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, and `denyConnectorServingRequest`. + +## Who reads and who writes + +| `as` | Whose account | Who reads through it | Who writes through it | +| --- | --- | --- | --- | +| `team` | A team connection with site serving on | Everyone who can open the Space | A signed-in current member of the owning team | +| `personal` | The connection of the person who bound it | Everyone who can open the Space (private Spaces only) | A signed-in current member of the owning team | +| `visitor` | Each viewer's own connection | That viewer | That viewer | + +The connectors route sits behind the Space's own access check, so data is never more public than the pages. A private Space's data stays private; a share link or password admits viewers with that link or password for reads. + +Two extra guardrails prevent accidental exposure: + +- **`team` on a Space anyone can open.** When a Space is public, or shared by link or password, a `team` role serves only after a team owner or admin allows public serving: `sf connectors public-serving set crm --enable --space example` (API: `setSpaceConnectorPublicServing`). Until then, calls answer `connection_forbidden`. Rebinding the role resets the allowance. +- **`personal` requires a private Space.** A `personal` role works only while the Space is private with no share link or password. Otherwise every call answers `connection_forbidden`. + +Writes through a `team` or `personal` role require a signed-in current member of the owning team. Anyone else can read through an allowed `team` role, never write: writes answer `connector_write_sign_in_required`. Send viewers to sign in with `space.access.signIn()`. A `visitor` role signs the viewer in first, then asks them to connect their own account. + +Your team's connector policy still applies to every call: blocked tools are refused, and tools set to **Ask first** answer `approval_pending`. + +## Previews + +Preview and held versions protect your live Space's bindings and shared accounts: + +- **No auto-binding on preview publishes.** Publishing a version that doesn't go live leaves existing bindings untouched and binds no new roles. Promoting or rolling back to that version binds its roles then. +- **No shared writes from previews.** A preview version can read through already-bound `team` or `personal` roles, but non-read-only tools on shared bindings are refused with `connector_preview_write_not_allowed`. Promote the version to run writes. +- **`visitor` roles work normally in previews**, because each call uses the viewer's own connected account. + +## Call it from a page + +### Typed client (TypeScript and JavaScript) + +Install `@spacefast/client`: + +```bash +npm install @spacefast/client +``` + +`sf dev` and `sf publish` generate `spacefast.generated.ts` next to your config file automatically (or run `sf client` by hand; pass `--out` to place it elsewhere). With roles declared, `sf publish` stops if regeneration fails so you never ship stale types; `sf dev` warns and continues. + +```ts +import { space } from "./spacefast.generated"; + +const answer = await space.connectors.crm.list_deals({ stage: "won" }); +if (answer.state === "ok") render(answer.data); +else showNotice(answer.message); +``` + +Each generated method knows its HTTP method: read-only tools send `GET`, and write tools send `POST`. Pass `{ idempotencyKey }` as the last argument so a retried write runs once. Pinned arguments are omitted from the tool's parameter type, non-identifier tool names use bracket keys (`space.connectors.github["issues.list"]()`), and tools without an output schema return `unknown`. + +Keep a read live with `.watch()`, which refreshes on an interval and on window focus while sharing identical requests (writes cannot be watched): + +```ts +const deals = space.connectors.crm.list_deals.watch({ stage: "won" }, { every: "60s" }); +const stop = deals.subscribe(() => render(deals.getSnapshot())); +``` + +`every` takes milliseconds or `"30s"`, `"5m"`, `"1h"`, never under one second. + +### React + +`useConnector` from `@spacefast/client/react` wraps `.watch()`: + +```tsx +import { useConnector } from "@spacefast/client/react"; +import { space } from "./spacefast.generated"; + +export function Deals() { + const deals = useConnector(space.connectors.crm.list_deals, { stage: "won" }, { every: "60s" }); + if (deals.state === "ok") return ; + return

{deals.message ?? "Loading…"}

; +} +``` + +It returns `data`, `state`, `message`, `connectUrl`, `approvalUrl`, `cachedAt`, `refreshing`, `error`, and `refresh`, keeping the last good `data` during refreshes and sharing requests across components. + +### Plain HTML and `fetch` + +Pages with no build step import the client directly from the Space (types live at `/__spacefast/client.d.ts`): + +```html + +``` + +Without generated types, every call uses `GET`; pass `{ method: "POST" }` for writes. + +You can also call the route with `fetch`. Query parameters pass string arguments (`?stage=won`), and `__args` passes typed JSON: + +```js +const args = encodeURIComponent(JSON.stringify({ stage: "won", limit: 5 })); +const response = await fetch(`/__spacefast/connectors/crm/list_deals?__args=${args}`); +const { state, data } = await response.json(); +``` + +A `POST` sends a JSON body of at most 64 KiB. Cross-site calls are blocked with `browser_origin_not_allowed` when `Sec-Fetch-Site` or `Origin` names another host, and writes always require same-origin proof (`Origin` or `Sec-Fetch-Site: same-origin`). Every response is `private, no-store`. + +## States and errors + +A call returns `{ state, data }`. When `state` is `ok`, `data` holds the tool's output; every other state returns `data: null` and a user-facing `message`: + +| State | What it means | What the page should do | +| --- | --- | --- | +| `ok` | `data` is the provider's payload. HTTP-backed tools add `http` (`status`, `headers`), and shared reads add `cachedAt` | Render `data` | +| `unbound` | No account serves this role yet | Show `message`; the Space's owner binds an account | +| `connect_required` | A `visitor` role needs this viewer's account | Link to `connectUrl` | +| `reconnect_required` | The account's authorization expired | For `visitor` roles, link to `connectUrl`. For `team` or `personal` roles, the team reconnects it—don't show `connectUrl` | +| `approval_pending` | The call is waiting for human approval | Show `message` and link to `approvalUrl` when present | +| `running` | Still executing | Retry shortly (watched reads retry automatically) | + +Hard failures return an RFC 9457 problem document with a stable `code`, thrown as `ConnectorError` (`status`, `code`, `message`) by the client (`state: "error"` in `useConnector`): + +| Code | Status | When | +| --- | --- | --- | +| [`connection_forbidden`](/errors/connection_forbidden) | 403 | Policy blocks the connector, read tool, or visitor write; approval denied; site serving off; or Space too open for the role | +| [`connector_role_unknown`](/errors/connector_role_unknown) | 404 | The live version doesn't declare this role | +| `connector_tool_not_allowed` | 403 | The role's `tools` list omits this tool | +| `connector_arg_pinned` | 422 | The call sent a different value for a pinned argument | +| `connector_preview_write_not_allowed` | 403 | A preview version tried to run a non-read-only tool on a shared `team` or `personal` role | +| `connector_write_sign_in_required` | 403 | A write on a `team` or `personal` role from someone who isn't a signed-in current member of the owning team | +| [`connector_tool_blocked`](/errors/connector_tool_blocked) | 403 | Team policy blocks this write tool on a `team` or `personal` role | +| [`connector_write_in_read_handler`](/errors/connector_write_in_read_handler) | 403 | A `GET` to a write tool—send `POST` instead | +| [`browser_origin_not_allowed`](/errors/browser_origin_not_allowed) | 403 | Cross-site call, or write without same-origin proof | +| `connectors_unavailable` | 502 or 503 | The provider or Spacefast couldn't answer; retry | + +## Visitor accounts + +A `visitor` role requires a connector with an OAuth sign-in method (API-key-only connectors answer `connector_oauth_required`; missing team OAuth apps answer `connector_oauth_app_required`). + +Its `connectUrl` is `/__spacefast/connectors//connect`, which signs the viewer in if needed, sends them to the provider, and returns them to `/` (or `?return_to=/some/path`). A same-origin `POST` to `/__spacefast/connectors//disconnect` disconnects the viewer's account. + +Inspect or revoke visitor connections from the CLI or API (`listVisitorConnectionUsers`, `revokeVisitorConnection`): + +```bash +sf connectors visitors list --space example +sf connectors visitors revoke 42 calendar --space example +``` + +## Pinned arguments + +`args` fixes argument values per tool on the server: + +```jsonc sf.jsonc +{ + "connectors": { + "crm": { + "connector": "hubspot", + "tools": ["list_deals"], + "args": { "list_deals": { "pipeline": "sales" } } + } + } +} +``` + +Every call to `list_deals` runs with `pipeline: "sales"` regardless of what the page sends. Sending a different value fails with `connector_arg_pinned` and a `pointer` naming the argument. Pin anything viewers shouldn't choose, such as a pipeline, project, or workspace id. + +## Shared reads + +Because a `team` or `personal` role queries one account for every viewer, Spacefast shares one upstream read across viewers for the role's `cache` window: + +- **Key:** Space, role, tool, and final arguments with pins applied (argument order ignored). +- **Single-flight fill:** One viewer fills a cold key while concurrent viewers wait for it. +- **Budget:** 60 upstream reads per role per rolling minute, per Space. +- **Stale fallback:** When the budget is spent, the last cached value serves for up to an hour past its window (otherwise `connectors_unavailable`). +- **`cachedAt`:** Included on cached `ok` answers; omitted on the request that fetched fresh data. + +Only successful reads are shared. `cache: "0"` disables sharing while still counting against the budget. Writes, `visitor` roles, and tools requiring approval are never shared. + +## Change roles without a publish + +Use the Space's **Integrations** page or `sf connectors roles` to override, turn off, or reset roles on a live Space without republishing: + +```bash +sf connectors roles list --space example +sf connectors roles set crm --connector hubspot --tools list_deals --cache 60s --space example +sf connectors roles remove crm --space example +sf connectors roles reset crm --space example +``` + +Overrides apply immediately to the live version and persist across future publishes until reset (**Use config file**). Over the API, send `config.connectors` on [`updateSpace`](/api/reference/spaces/updatespace) (setting a role to `null` removes it) alongside `baseSettingsDigest` from [`getSpace`](/api/reference/spaces/getspace). + +## Call it from Functions + +A [Functions](/functions) worker whose version declares roles receives `env.CONNECTORS`: + +```js functions/deals.js +export async function GET(request, { env }) { + const deals = await env.CONNECTORS.crm.list_deals({ stage: "won" }); + return Response.json(deals); +} +``` + +The proxy returns the tool's output or throws `ConnectorCallError` with `state.code` (such as `connect_required` or `forbidden`). `env.CONNECTORS.call("crm", "list_deals", args)` returns `{ state, result }` without throwing. Workers forward the request's signed-in viewer, so `visitor` roles, write permissions, and preview write rules match page calls. Worker calls are never shared reads. + +## Call it from outside the Space + +The `/__spacefast/connectors/...` route answers only the Space's own pages. From a script, CI job, or agent, call [`createConnectorRun`](/api/reference/connectors/createconnectorrun) or `sf connectors run` with your own API key: + +```bash +sf connectors run --tool cxn_abc123/list_deals --args '{"stage":"won"}' +``` + +Direct runs follow your credential and team policy rather than a Space role (no pinned arguments, no shared reads). diff --git a/content/(dynamic)/team-connectors.mdx b/content/(dynamic)/team-connectors.mdx deleted file mode 100644 index 40c87896..00000000 --- a/content/(dynamic)/team-connectors.mdx +++ /dev/null @@ -1,221 +0,0 @@ ---- -title: Team connectors -description: Register an OpenAPI spec, GraphQL endpoint, or remote MCP server for your team, connect an account, decide what agents may call, and run tools -sidebar: - badge: Public Beta ---- - -Public Beta - -A connector is a source of tools that a team registers once: an OpenAPI spec, a GraphQL endpoint, or a remote MCP server. A connection is one account on that connector. Agents and Spaces get the tools. The credential stays in Spacefast, and no endpoint ever returns it. - -Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. Enterprise adds team-wide connector allowlists, blocklists, and site-serving governance. - -## Before you start - -- **Team owners and admins** manage connectors in the dashboard: registering tool sources, connecting or disconnecting team accounts, and setting team rules (`connectors:write`). -- **Team members** can list and run team connections through the API, CLI, and On-Device MCP (`connectors:read` and `connectors:execute`), subject to the team's policy rules and any per-credential connection limits. The team's **Connectors** dashboard pages remain owner and admin only. -- **API keys** need connector scopes. `connectors:read` reads connectors, connections, tools, rules, and runs. `connectors:write` registers connectors, connects accounts, and sets policy. `connectors:execute` runs tools. `write` and `execute` both include `read`, but neither includes the other. You can also limit an API key or OAuth grant to specific connections. See [API keys](/api-keys). - -The dashboard pages live under **Connectors** in the team sidebar. A switch in the header moves between **Connectors**, **Runs**, and **Policies**. - -## Add a connector from the catalog - -The catalog lists curated presets, the public registry, and your team's own connectors. It has one row per source type, so a service with an API and an MCP server is two rows. - -1. Open **Connectors** in the team sidebar. -2. Click **Browse Connectors**. -3. Search, or filter by **All**, **API**, **GraphQL**, or **MCP**. -4. Click **Add** on the row you want. - -The row changes to **View** when the connector exists. A row that needs a provider-specific endpoint shows **Set Up** instead of **Add**, and opens the add form. - -From the CLI, search the catalog or pass a catalog slug: - -```bash -sf connectors search linear -sf connectors create linear -``` - -## Add a connector from a URL - -Paste any URL the service published. Detection looks behind it, so the URL it registers can differ from the one you pasted. - -1. On **Browse**, paste the URL into the search box. -2. Click **Detect**. -3. Click **Add Connector** on the candidate you want. -4. Check **Name**, **Namespace**, and **Description**. -5. Click **Register**. - -**Namespace** is the connector slug. It takes lowercase letters, digits, and dashes, and starts with a letter or a digit. Every tool address of the connector starts with it. Agents read **Description** when they choose between connectors. - -You enter no credential here. Authentication comes from the source. Spacefast asks an MCP server how it authenticates, so a server that wants OAuth gets an OAuth connector. - -```bash -sf connectors detect https://api.example.com -sf connectors create https://api.example.com/openapi.json -``` - -## Connect an account - -1. On **Connectors**, open the connector row. -2. Click **Connect Account**. -3. Under **Who can use it**, choose **Team** or **Personal**. -4. If the connector offers more than one method, choose one under **Method**. -5. Optional: enter a **Label**. Agents see it when a connector has more than one account. -6. Click **Connect**. - -**Team** shares the account with everyone on the team and every agent that acts for it. **Personal** keeps it yours, and only within this team. An API key can connect **Team** accounts only. - -Connecting ends in one of three ways: - -| Result | What to do | -| --- | --- | -| `connected` | Nothing. The account is ready | -| `authorization_required` | Sign in at the provider. In the dashboard, click **Open Sign-In**. The CLI prints the URL. The callback finishes the connection, so there is nothing to paste back | -| `input_required` | Give the values the connector asks for, then connect again | - -For an `input_required` answer, the dashboard shows each field with the provider's own help when the registry has some: setup notes, steps, a **Create one** link, and a **Provider docs** link. The CLI prints the same help under each `--field`. The same help is available from [`getConnectorCredentialGuidance`](/api/reference/connectors/getconnectorcredentialguidance). - -```bash -sf connectors connections connect stripe --api-key "$STRIPE_KEY" -sf connectors connections connect linear --owner personal -``` - -A tool address is `/`. While exactly one usable account matches, `/` also works. Connect a second account and the short form fails with `connection_ambiguous`, so use the connection id. No account is the default once a connector has two. - -## Keep a connection working - -Open a connector, then the **Accounts** tab. Each account has an actions menu. - -| Action | What it does | CLI | -| --- | --- | --- | -| **Edit…** | Changes the **Label** and the agent note, **What it's for** | `sf connectors connections update` | -| **Check Health** | Probes the provider and reports what came back. It changes nothing | `sf connectors connections health` | -| **Re-Sync Tools** | Reads the tool list again, so new or dropped tools show up | `sf connectors connections refresh` | -| **Reconnect…** | Signs in again, or replaces the key. The account keeps its id, label, policies, and Space bindings | `sf connectors connections reconnect` | -| **Disconnect…** | Destroys the stored credential. Anything that uses the account stops working | `sf connectors connections disconnect` | - -An account in `needs_reauth` or `degraded` also shows a **Reconnect** button. Token refresh happens on its own, so reconnect only when the status asks for it. - -Credentials cannot be edited. To rotate a key, reconnect the account. A disconnected account cannot be reconnected. Connecting the service again makes a new account with a new id. - -## Limit which connections a key or app can use - -By default, a credential with connector scopes can reach every team connection it has permission for. Narrow it to specific connections when a script, CI job, or AI client should only touch one account: - -- **API keys:** Pass one or more `--connection ` flags when creating or updating a key (`sf api-keys create --name linear-bot --preset team_admin --connection cxn_abc123`), or send `connectorAccess: { connectionIds: ["cxn_abc123"] }` over the API. Remove the limit later with `sf api-keys update --all-connections` or `connectorAccess: null`. See [API keys](/api-keys#limit-connector-access). -- **OAuth apps and CLI logins:** On the consent screen, open **Choose Connections** to pick which connections the app may reach. You can change that list later on **Connected apps** in the dashboard without re-authorizing. - -A connection outside a credential's allowlist answers `404` as if it doesn't exist. - -## Decide what agents can call - -A policy rule pairs an address pattern with an action. - -| Pattern | Matches | -| --- | --- | -| `*` | Every tool | -| `/*` | Every tool on every account of one connector | -| `/` | One tool on every account of one connector | -| `/*` | Every tool of one account | -| `/` | One tool on one account | - -| Action | Dashboard label | When an agent calls a matching tool | -| --- | --- | --- | -| `approve` | **Runs freely** | The call runs | -| `require_approval` | **Ask first** | The run parks until a person decides | -| `block` | **Blocked** | The run fails with `connector_tool_blocked` | - -How rules combine: - -- The most specific pattern wins. Spacefast orders rules by specificity, not by the order you add them. -- A **Team** rule is a floor. A **Personal** rule can tighten it but never loosen it. -- When no rule matches, the tool's own default from its source applies. A tool can also ask for approval on its own. -- A rule's pattern and owner are fixed. To change either, delete the rule and add a new one. -- Deleting a rule hands its tools to the next matching rule. Deleting a block can open a tool again. - -To add a rule: - -1. Click **Policies** in the connectors header. -2. Type a **Pattern**. The hint below it counts the tools it matches today. -3. Choose an action under **Then**. -4. Choose **Team** or **Personal** under **Applies to**. -5. Click **Add Rule**. - -A pattern that names an unknown connector or connection is refused. An API key can add **Team** rules only. - -To check one address without calling it, run `sf connectors policies explain`. It prints the effect, the rule that decided it, and the reason. The API equivalent is [`resolveConnectorPolicy`](/api/reference/connectors/resolveconnectorpolicy). - -```bash -sf connectors policies add '*' --action require_approval -sf connectors policies explain cxn_abc123/charges.create -``` - -On Enterprise plans, team owners and admins can also set a team-wide connector allowlist or blocklist and restrict which connectors may serve Spaces. - -## Find a tool - -Click **See tools** on a connector row, or open **Connector tools** from the command palette. The **Tools** page lists every tool the team's accounts reach. Each row shows the tool name, its summary, its resolved effect, and its safety: **Read-only**, **Writes**, or **Destructive**. Safety comes from the source and is not a setting. - -Open a tool to see its address, the rule that decided its effect, and its **Input schema**. From the CLI, inspect a connector or a connection's tools with `sf connectors inspect ` or `sf connectors connections inspect `. The API equivalents are [`listConnectorTools`](/api/reference/connectors/listconnectortools) and [`listConnectionTools`](/api/reference/connectors/listconnectiontools). - -## Run a tool - -To try a tool yourself, open it on **Tools**, fill in **Arguments** as a form or as JSON, and click **Run**. Your run follows the same policy an agent gets. - -From the CLI, pass the tool address and its arguments: - -```bash -sf connectors run --tool cxn_abc123/issues.list --args '{"limit":5}' -``` - -A run is one tool call, or a program that calls several tools. Both get one run id (`cxr_…`) and the same statuses. - -| Status | Meaning | -| --- | --- | -| `running` | Still working. Read it again with `sf connectors run inspect` | -| `awaiting_approval` | Parked on a decision | -| `succeeded` | Done. The result is in `result` | -| `failed` | Done. The reason is in `error`, a problem document | -| `expired` | Parked too long. Submit it again | - -The request waits up to 30 seconds for a final status by default. Set `--wait` to change that, up to 120 seconds. A failed run is still a successful request, so read the run's status before you report success. The CLI exits `1` for a `failed` or `expired` run. - -## Decide a parked run - -A parked run carries an `approvalUrl` that opens the dashboard on the decision. You can also find it in two places: - -- **Approvals**, under **Connector calls awaiting approval**. -- **Runs**, with the **Waiting on you** filter. Click **Review** to see the rule, the arguments, and the deadline, then approve. **Deny** sits on the row. - -**Approve** runs the call once. **Deny** fails the run with `connector_tool_blocked`. A run left parked for 15 minutes expires. - -A run parks for a person. A CLI login or an API key cannot approve it, and an attempt fails with `human_approval_required`. After a person decides, read the outcome with `sf connectors run inspect`. - -To fail fast instead of parking when nobody is watching, pass `--deny-unattended`. The run then fails with `connector_approval_required`. - -## Let an agent use connectors - -On-device MCP, `sf mcp`, has one gateway tool, `search_connector_tools`. It searches the team's connected services, calls a tool, and resumes a parked call. Hosted MCP and `sf mcp proxy` do not offer it, and they have no connector operation tools. See [MCP server](/agents/mcp-server). - -The CLI and the [connectors API](/api/connectors) give an agent everything else. - -## Use a connection in a Space - -To show a connection's data on a Space's pages, declare a role and bind the connection to it. See [Connectors](/connectors). - -## When a member leaves - -Before removing a team member, the dashboard lists the connector dependencies they own or created: - -- **Personal connections** owned by that member disconnect automatically when they leave or are removed. Their stored credentials are purged, pending sign-ins are canceled, and any Space bindings using them are removed. -- **Team connections** the departing member created stay active, but are listed during member removal so an owner or admin can reconnect them with a team-owned account or rebind affected Spaces if the provider account will be deactivated. - -## Remove a connector - -```bash -sf connectors delete linear --yes -``` - -Removing a connector disconnects every account on it, then deletes the connector and its tools. Built-in connectors cannot be removed. diff --git a/content/(reference)/config-file.mdx b/content/(reference)/config-file.mdx index 43138c50..188ce173 100644 --- a/content/(reference)/config-file.mdx +++ b/content/(reference)/config-file.mdx @@ -379,7 +379,7 @@ The project config is the only writer. See [Crons](/crons) for the schedule gram | --- | --- | --- | --- | | `connectors` | object, up to 32 roles | none | Connector roles your pages call at `/__spacefast/connectors//` | -See [Connectors](/connectors) for each role's keys. +See [Connectors in Spaces](/space-connectors) for each role's keys. diff --git a/content/api/connectors.mdx b/content/api/connectors.mdx index 4be01dd9..9f1085d9 100644 --- a/content/api/connectors.mdx +++ b/content/api/connectors.mdx @@ -10,7 +10,7 @@ sidebar: Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. -The connectors API lets a team register tool sources, connect accounts, set policy rules, and run tools. Every operation sits under `/v1/connectors` with the `Connectors` tag. For the concepts and the dashboard, see [Team connectors](/team-connectors). To show a connection's data on a Space's pages, see [Connectors](/connectors). +The connectors API lets a team register tool sources, connect accounts, set policy rules, and run tools. Every operation sits under `/v1/connectors` with the `Connectors` tag. For concepts and dashboard workflows, see [Connectors](/connectors). To show a connection's data on a Space's pages, see [Connectors in Spaces](/space-connectors). ## Scopes and team selection @@ -356,6 +356,6 @@ A Space manages its connector roles, bindings, site-serving requests, public-ser - **Site serving:** `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, `denyConnectorServingRequest`, and `setSpaceConnectorPublicServing`. - **Visitor connections:** `listVisitorConnectionUsers` and `revokeVisitorConnection`. -See [Connectors](/connectors#bind-an-account) for the Space workflow. +See [Connectors in Spaces](/space-connectors#bind-an-account-and-turn-on-site-serving) for the Space workflow. Hosted MCP exposes no connector operations. On-device MCP, `sf mcp`, reaches connectors through one gateway tool, `search_connector_tools`. See [MCP server](/agents/mcp-server). diff --git a/content/api/index.mdx b/content/api/index.mdx index e202c22b..6215d864 100644 --- a/content/api/index.mdx +++ b/content/api/index.mdx @@ -163,4 +163,4 @@ Stop when `data.status` is `succeeded`, `failed`, or `canceled`. Then read `spac ## Connect external tools -Connectors make OpenAPI, GraphQL, and remote MCP tools available to a team, with credentials that stay in Spacefast. Connectors are in Private Beta; a team without access gets `feature_unavailable`. The [connectors API guide](/api/connectors) covers the operations, scopes, and errors, and [Team connectors](/team-connectors) covers the dashboard and the CLI. To show a connection's data on a Space's pages, declare a role instead; see [Connectors](/connectors). +Connectors make OpenAPI, GraphQL, and remote MCP tools available to a team, with credentials that stay in Spacefast. Connectors are in Public Beta on Go, Pro, and Enterprise plans; Personal (Free) teams get `feature_unavailable`. Start with [Connectors](/connectors) for concepts and dashboard setup, [Connectors in Spaces](/space-connectors) for Space roles and pages, and the [connectors API guide](/api/connectors) for operations, scopes, and errors. diff --git a/content/cli/connectors.mdx b/content/cli/connectors.mdx index a970ef21..9b64805b 100644 --- a/content/cli/connectors.mdx +++ b/content/cli/connectors.mdx @@ -8,7 +8,7 @@ sidebar: Public Beta -`sf connectors` manages a team's connectors: tool sources, the accounts connected to them, the policy rules that decide what agents may call, runs, and Space connector roles and bindings. For the concepts and the dashboard, see [Team connectors](/team-connectors). +`sf connectors` manages a team's connectors: tool sources, the accounts connected to them, the policy rules that decide what agents may call, runs, and Space connector roles and bindings. For concepts and dashboard workflows, see [Connectors](/connectors). Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable` and exits 2. @@ -308,7 +308,7 @@ sf connectors connections update [--name ] [--description ` | unchanged | New label. Must not be blank | | `--description=` | unchanged | New agent note. An empty string clears it | -| `--serving`, `--no-serving` | unchanged | Let Spaces bound to this team connection act as this account. See [Connectors](/connectors#serving-a-team-account-on-spaces) | +| `--serving`, `--no-serving` | unchanged | Let Spaces bound to this team connection act as this account. See [Connectors in Spaces](/space-connectors#site-serving-for-team-connections) | Credentials cannot be edited. To rotate one, run `sf connectors connections reconnect`. @@ -750,7 +750,7 @@ The same as `sf connectors run`, with the same exit codes. ## Space bindings, roles, serving, and visitors -These commands manage how a Space declares roles, binds team connections, turns on site serving, and handles visitor accounts. Space-scoped commands require `--space` or `SPACEFAST_SPACE` (without one, they fail with `validation_error` and exit 2). See [Connectors](/connectors). +These commands manage how a Space declares roles, binds team connections, turns on site serving, and handles visitor accounts. Space-scoped commands require `--space` or `SPACEFAST_SPACE` (without one, they fail with `validation_error` and exit 2). See [Connectors in Spaces](/space-connectors). ### Bindings From 815419b7e40c3e121485c38ad7d4d85b89e9558c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?batuhan=20i=C3=A7=C3=B6z?= Date: Tue, 24 Nov 2026 20:53:08 +0000 Subject: [PATCH 3/5] Address Connectors docs review findings --- content/(concepts)/teams.mdx | 2 +- content/(dynamic)/connectors.mdx | 19 +++++++++++-------- content/(dynamic)/space-connectors.mdx | 6 +++--- content/api/connectors.mdx | 1 + content/cli/connectors.mdx | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/content/(concepts)/teams.mdx b/content/(concepts)/teams.mdx index 2a82402a..0fdec33b 100644 --- a/content/(concepts)/teams.mdx +++ b/content/(concepts)/teams.mdx @@ -93,7 +93,7 @@ Things that catch people out: On **Members**, each row has role and removal actions for owners and admins. Removing someone takes away their access to the team and every Space in it. Anything they published stays where it is, and you can invite them back later. -If the team uses [Connectors](/connectors), the removal review lists the departing member's connector dependencies. Their personal connections disconnect automatically along with any Space bindings pointing to them. Team connections they created stay active so you can reconnect or rebind them without downtime. +If the team uses [Connectors](/connectors), the removal review lists the departing member's connector dependencies. Their personal connections disconnect automatically along with any Space bindings pointing to them. Team connections they created stay active while their existing Space bindings stay in place; if an owner or admin rebinds a role on a public, link-shared, or password-protected Space, restore its public-serving allowance before expecting calls to succeed. Two guards you cannot talk your way past: diff --git a/content/(dynamic)/connectors.mdx b/content/(dynamic)/connectors.mdx index b20a18ff..23f4c82d 100644 --- a/content/(dynamic)/connectors.mdx +++ b/content/(dynamic)/connectors.mdx @@ -9,7 +9,7 @@ sidebar: Connectors let your team connect an external service once—an OpenAPI spec, a GraphQL endpoint, or a remote MCP server—and call its tools from AI agents, Space pages, Functions, and scripts. Credentials stay sealed in Spacefast and never enter prompts, source code, or browsers. -Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. Enterprise adds team-wide connector allowlists, blocklists, and site-serving controls. +Connectors are in Public Beta on Go, Pro, and Enterprise plans. A team on Personal (Free) gets `feature_unavailable`. Enterprise adds team-wide connector allowlists and blocklists. ## How Connectors work @@ -19,7 +19,7 @@ Four building blocks cover everything Connectors do: | --- | --- | | **Connector** | A tool source your team registers once (from the catalog or by pasting any URL). Its slug becomes the tool namespace, such as `hubspot` or `linear`. | | **Connection** | One authenticated account (`cxn_…`) on a connector, owned by the **Team** (shared) or **Personal** (only yours within this team). | -| **Policy** | Rules that decide whether a tool call **Runs freely** (`approve`), **Asks first** (`require_approval`), or is **Blocked** (`block`). | +| **Policy** | Rules that decide whether a tool call **Runs freely** (`approve`), **Ask first** (`require_approval`), or is **Blocked** (`block`). | | **Role** | A Space-level declaration in `spacefast.config.ts` or `sf.jsonc` that exposes chosen tools to a Space's pages and Functions. See [Connectors in Spaces](/space-connectors). | ## Three ways to use a connector @@ -48,17 +48,18 @@ Four building blocks cover everything Connectors do: ``` - Open the connector, click **Connect Account**, pick **Team** or **Personal**, and finish OAuth sign-in or enter the required API key. From the terminal: + Open the connector, click **Connect Account**, pick **Team** or **Personal**, and finish OAuth sign-in or enter the required API key. From the terminal, connect and then list your connection ID (OAuth connectors print a sign-in URL first; replace `cxn_abc123` below with your ID): ```bash sf connectors connections connect linear + sf connectors connections list --connector linear ``` - Open **Policies** in the connectors header to decide which tools run freely, ask a person first, or stay blocked: + Open **Policies** in the connectors header to decide which tools run freely, ask a person first, or stay blocked. Start with a rule scoped to the tool you want to test so other tools keep running: ```bash - sf connectors policies add '*' --action require_approval + sf connectors policies add cxn_abc123/issues.list --action require_approval sf connectors policies explain cxn_abc123/issues.list ``` @@ -68,6 +69,8 @@ Four building blocks cover everything Connectors do: ```bash sf connectors run --tool cxn_abc123/issues.list --args '{"limit":5}' ``` + + Because the rule above asks first, the CLI prints an approval URL and pauses with `awaiting_approval`. Open the URL to approve the call, then read the settled result with `sf connectors run inspect `—no need to submit a new run. @@ -157,7 +160,7 @@ sf connectors policies add '*' --action require_approval sf connectors policies explain cxn_abc123/charges.create ``` -On Enterprise plans, team owners and admins can also set a team-wide connector allowlist or blocklist and restrict which connectors may serve Spaces. +On Enterprise plans, team owners and admins can also set a team-wide connector allowlist or blocklist. ### Decide a parked run @@ -168,7 +171,7 @@ A parked run returns an `approvalUrl` and appears in two dashboard views: **Approve** runs the call once. **Deny** fails it with `connector_tool_blocked`. A parked run expires after 15 minutes. -Approvals require a signed-in person. A CLI login or API key trying to approve fails with `human_approval_required`; read back a person's decision with `sf connectors run inspect` or `sf connectors run resume `. Pass `--deny-unattended` on `sf connectors run` to fail immediately with `connector_approval_required` instead of parking. +Approvals require a signed-in person. A CLI login or API key trying to approve fails with `human_approval_required`. Read the outcome with `sf connectors run inspect `. Approving in the dashboard executes the call and settles the run, so `sf connectors run resume ` applies only while the run still awaits a decision (a settled run returns `connector_run_not_resumable`). Pass `--deny-unattended` on `sf connectors run` to fail immediately with `connector_approval_required` instead of parking. ## Find and run tools @@ -199,7 +202,7 @@ By default, a credential with connector scopes reaches every team connection it - **API keys:** Pass `--connection ` (repeatable) on `sf api-keys create` or `sf api-keys update`, or pass `connectorAccess: { connectionIds: ["cxn_abc123"] }` over the API. Remove the limit with `--all-connections` or `connectorAccess: null`. See [API keys](/api-keys#limit-connector-access). - **OAuth apps and CLI logins:** Open **Choose Connections** on the consent screen, or edit the allowlist later on **Connected apps** without re-authorizing. -A connection outside a credential's allowlist answers `404` as if it doesn't exist. +Direct lookups of a connection outside a credential's allowlist answer `404` as if it doesn't exist. Tool runs still return a run record (HTTP `200` or `201`) with `connection_not_found` in the failed run's `error`; see [Errors](/api/connectors#errors). ## Keep connections working and clean up diff --git a/content/(dynamic)/space-connectors.mdx b/content/(dynamic)/space-connectors.mdx index 60d89acd..dad2a05a 100644 --- a/content/(dynamic)/space-connectors.mdx +++ b/content/(dynamic)/space-connectors.mdx @@ -14,7 +14,7 @@ Connectors are in Public Beta on Go, Pro, and Enterprise plans. If you haven't a ## How a Space call works 1. **Declare a role** in `spacefast.config.ts` or `sf.jsonc` naming the connector, allowed tools, account mode (`team`, `personal`, or `visitor`), optional pinned arguments, and read cache window. -2. **Bind an account** (for `team` or `personal` roles) and enable site serving on the connection. Publishing a live version auto-binds any role with a single eligible connection. +2. **Bind an account** (for `team` or `personal` roles) and enable site serving on the connection. Publishing a live version as a team owner or admin auto-binds any role with a single eligible connection. 3. **Call the role** from a page using `@spacefast/client`, `/__spacefast/client.js`, plain `fetch`, or from a Function via `env.CONNECTORS`. ## Declare a role @@ -70,7 +70,7 @@ Role names are camelCase, start with a lowercase letter, and are up to 64 charac A `team` or `personal` role needs a bound account (`visitor` roles bind nothing; each viewer connects their own). -Publishing a live version binds a role automatically when exactly one eligible connection exists. The publish receipt lists roles that still need a binding or site serving. Bind remaining roles from the CLI or the Space's **Integrations** page: +Publishing a live version as a human team owner or admin (with `connectors:write` and access to the account) binds a role automatically when exactly one eligible connection exists. Publishes by team members without `connectors:write`, API keys, or settings republishes bind nothing. The publish receipt lists roles that still need a binding or site serving. Bind remaining roles from the CLI (`sf connectors bind`) or the Space's **Integrations** page: ```bash sf connectors bindings --space example @@ -97,7 +97,7 @@ sf connectors serving approve csr_abc123 sf connectors serving deny csr_abc123 ``` -On Enterprise plans, owners and admins can restrict serving approvals to admins and allowlist which connectors may serve Spaces with `sf connectors serving set`. The API operations are `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, and `denyConnectorServingRequest`. +Team owners and admins can also restrict serving approvals to admins and allowlist which connectors may serve Spaces with `sf connectors serving set`. The API operations are `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, and `denyConnectorServingRequest`. ## Who reads and who writes diff --git a/content/api/connectors.mdx b/content/api/connectors.mdx index 9f1085d9..1bfc64d0 100644 --- a/content/api/connectors.mdx +++ b/content/api/connectors.mdx @@ -352,6 +352,7 @@ These codes appear in a failed run's `error`, inside a successful HTTP response A Space manages its connector roles, bindings, site-serving requests, public-serving allowances, and visitor connections under the `Spaces` tag: +- **Roles:** `getSpace` (for `baseSettingsDigest`) and `updateSpace` (with `config.connectors` to override, remove, or reset roles without publishing). - **Bindings:** `listSpaceConnectorBindings`, `bindSpaceConnector`, and `unbindSpaceConnector`. - **Site serving:** `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, `denyConnectorServingRequest`, and `setSpaceConnectorPublicServing`. - **Visitor connections:** `listVisitorConnectionUsers` and `revokeVisitorConnection`. diff --git a/content/cli/connectors.mdx b/content/cli/connectors.mdx index 9b64805b..b6233051 100644 --- a/content/cli/connectors.mdx +++ b/content/cli/connectors.mdx @@ -782,7 +782,7 @@ A team connection serves a Space only after site serving is turned on. On a publ | Command | What it does | | --- | --- | -| `sf connectors serving create --space ` | Ask team owners and admins to turn site serving on for a role's bound connection (`csr_…`) | +| `sf connectors serving create --space ` | Turn site serving on immediately for a role's bound connection when you have permission, or create a pending request (`csr_…`) for team owners and admins to approve | | `sf connectors serving list [--status pending\|approved\|denied\|canceled]` | List the team's site-serving requests. Aliased as `ls` | | `sf connectors serving inspect ` | Show one site-serving request and whether it is still pending | | `sf connectors serving approve ` | Approve a request and turn site serving on (owners and admins) | From 3db72ba21382d6c0447989c03f3e883eab061026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?batuhan=20i=C3=A7=C3=B6z?= Date: Tue, 24 Nov 2026 21:00:19 +0000 Subject: [PATCH 4/5] Fix denied approval, connection allowlist, and updateSpace overlay docs --- content/(dynamic)/connectors.mdx | 4 ++-- content/(dynamic)/space-connectors.mdx | 2 +- content/api/connectors.mdx | 7 ++++--- content/cli/connectors.mdx | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/content/(dynamic)/connectors.mdx b/content/(dynamic)/connectors.mdx index 23f4c82d..1173b244 100644 --- a/content/(dynamic)/connectors.mdx +++ b/content/(dynamic)/connectors.mdx @@ -169,7 +169,7 @@ A parked run returns an `approvalUrl` and appears in two dashboard views: - **Approvals**, under **Connector calls awaiting approval**. - **Runs**, filtered to **Waiting on you**. Click **Review** to inspect the matched rule, arguments, and deadline before approving, or click **Deny** on the row. -**Approve** runs the call once. **Deny** fails it with `connector_tool_blocked`. A parked run expires after 15 minutes. +**Approve** runs the call once. **Deny** fails it with `connector_approval_declined`. A parked run expires after 15 minutes. Approvals require a signed-in person. A CLI login or API key trying to approve fails with `human_approval_required`. Read the outcome with `sf connectors run inspect `. Approving in the dashboard executes the call and settles the run, so `sf connectors run resume ` applies only while the run still awaits a decision (a settled run returns `connector_run_not_resumable`). Pass `--deny-unattended` on `sf connectors run` to fail immediately with `connector_approval_required` instead of parking. @@ -202,7 +202,7 @@ By default, a credential with connector scopes reaches every team connection it - **API keys:** Pass `--connection ` (repeatable) on `sf api-keys create` or `sf api-keys update`, or pass `connectorAccess: { connectionIds: ["cxn_abc123"] }` over the API. Remove the limit with `--all-connections` or `connectorAccess: null`. See [API keys](/api-keys#limit-connector-access). - **OAuth apps and CLI logins:** Open **Choose Connections** on the consent screen, or edit the allowlist later on **Connected apps** without re-authorizing. -Direct lookups of a connection outside a credential's allowlist answer `404` as if it doesn't exist. Tool runs still return a run record (HTTP `200` or `201`) with `connection_not_found` in the failed run's `error`; see [Errors](/api/connectors#errors). +Direct lookups of a connection outside a credential's allowlist answer `404` as if it doesn't exist. Tool runs still return a run record (HTTP `200` or `201`): addressing a disallowed connection by ID (`/`) fails in `error` with `connection_forbidden`, while the short `/` form fails with `connection_not_found`; see [Errors](/api/connectors#errors). ## Keep connections working and clean up diff --git a/content/(dynamic)/space-connectors.mdx b/content/(dynamic)/space-connectors.mdx index dad2a05a..b3553b89 100644 --- a/content/(dynamic)/space-connectors.mdx +++ b/content/(dynamic)/space-connectors.mdx @@ -281,7 +281,7 @@ sf connectors roles remove crm --space example sf connectors roles reset crm --space example ``` -Overrides apply immediately to the live version and persist across future publishes until reset (**Use config file**). Over the API, send `config.connectors` on [`updateSpace`](/api/reference/spaces/updatespace) (setting a role to `null` removes it) alongside `baseSettingsDigest` from [`getSpace`](/api/reference/spaces/getspace). +Overrides apply immediately to the live version and persist across future publishes until reset (**Use config file**). Over the API, `config` on [`updateSpace`](/api/reference/spaces/updatespace) replaces the Space's whole stored settings overlay (except `config.network`), so read `config` and `settingsDigest` from [`getSpace`](/api/reference/spaces/getspace), send back the full `config` with your `config.connectors` change (setting a role to `null` removes it), and pass `settingsDigest` as `baseSettingsDigest`. ## Call it from Functions diff --git a/content/api/connectors.mdx b/content/api/connectors.mdx index 1bfc64d0..e6d84182 100644 --- a/content/api/connectors.mdx +++ b/content/api/connectors.mdx @@ -301,7 +301,7 @@ Runs share a budget of 1,200 per team per hour. Past it, requests fail with `429 ## Resume a parked run -`resumeConnectorRun` takes `action` (`accept`, `decline`, or `cancel`) and `content`, the values a parked call asked for. A `decline` fails the run with `connector_tool_blocked`. +`resumeConnectorRun` takes `action` (`accept`, `decline`, or `cancel`) and `content`, the values a parked call asked for. A `decline` or `cancel` fails the run with `connector_approval_declined`. A run parked in `human` mode refuses a decision from an API key or an agent with `human_approval_required`. A person decides at `approvalUrl`. Then call `resumeConnectorRun` with no `action` to read back the outcome and let the run continue. While nobody has decided, that call fails with `connector_approval_required`. @@ -336,7 +336,8 @@ These codes appear in a failed run's `error`, inside a successful HTTP response | Code | Status in `error` | When | | --- | --- | --- | -| `connector_tool_blocked` | 403 | A `block` rule matched, or a person denied the call | +| `connector_tool_blocked` | 403 | A `block` rule matched | +| `connector_approval_declined` | 403 | A person declined or canceled the parked call | | `connector_approval_required` | 403 | The call needed approval and `unattendedApprovals` was `deny` | | `connection_ambiguous` | 409 | A `/` address matched more than one connection | | `connection_not_found` | 404 | The address names no connection the credential can use | @@ -352,7 +353,7 @@ These codes appear in a failed run's `error`, inside a successful HTTP response A Space manages its connector roles, bindings, site-serving requests, public-serving allowances, and visitor connections under the `Spaces` tag: -- **Roles:** `getSpace` (for `baseSettingsDigest`) and `updateSpace` (with `config.connectors` to override, remove, or reset roles without publishing). +- **Roles:** `getSpace` (for the current `config` overlay and `settingsDigest`) and `updateSpace` (sending the full `config` with your `config.connectors` change and `settingsDigest` as `baseSettingsDigest`, because `config` replaces the stored settings overlay). - **Bindings:** `listSpaceConnectorBindings`, `bindSpaceConnector`, and `unbindSpaceConnector`. - **Site serving:** `requestSpaceConnectorServing`, `listConnectorServingRequests`, `approveConnectorServingRequest`, `denyConnectorServingRequest`, and `setSpaceConnectorPublicServing`. - **Visitor connections:** `listVisitorConnectionUsers` and `revokeVisitorConnection`. diff --git a/content/cli/connectors.mdx b/content/cli/connectors.mdx index b6233051..7ca2ceb7 100644 --- a/content/cli/connectors.mdx +++ b/content/cli/connectors.mdx @@ -723,7 +723,7 @@ sf connectors run resume [--accept | --deny | --cancel] [--content ] | Flag | Default | What it does | | --- | --- | --- | | `--accept` | `false` | Approve the parked call | -| `--deny` | `false` | Refuse the parked call. The run fails with `connector_tool_blocked` | +| `--deny` | `false` | Refuse the parked call. The run fails with `connector_approval_declined` | | `--cancel` | `false` | Abandon the run | | `--content=` | none | JSON object of values the parked call asked for. Accepts `@file` or `-` for stdin | | `-T, --team=` | default team | Team slug, ID, or name. Env `SPACEFAST_TEAM` | From 8c15b6981d1197954f9ea4299a8710e754d7ebc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?batuhan=20i=C3=A7=C3=B6z?= Date: Tue, 24 Nov 2026 21:06:26 +0000 Subject: [PATCH 5/5] Align API and CLI run-approval read guidance with getConnectorRun --- content/api/connectors.mdx | 2 +- content/cli/connectors.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/api/connectors.mdx b/content/api/connectors.mdx index e6d84182..9dd90089 100644 --- a/content/api/connectors.mdx +++ b/content/api/connectors.mdx @@ -303,7 +303,7 @@ Runs share a budget of 1,200 per team per hour. Past it, requests fail with `429 `resumeConnectorRun` takes `action` (`accept`, `decline`, or `cancel`) and `content`, the values a parked call asked for. A `decline` or `cancel` fails the run with `connector_approval_declined`. -A run parked in `human` mode refuses a decision from an API key or an agent with `human_approval_required`. A person decides at `approvalUrl`. Then call `resumeConnectorRun` with no `action` to read back the outcome and let the run continue. While nobody has decided, that call fails with `connector_approval_required`. +A run parked in `human` mode refuses a decision from an API key or an agent with `human_approval_required`. A person decides at `approvalUrl`, which executes the call and settles the run. Read the settled status and `result` with `getConnectorRun` (`sf connectors run inspect `). Calling `resumeConnectorRun` on a settled run fails with `connector_run_not_resumable`, and calling it without an `action` before a decision fails with `connector_approval_required`. ## Errors diff --git a/content/cli/connectors.mdx b/content/cli/connectors.mdx index 7ca2ceb7..6753a39b 100644 --- a/content/cli/connectors.mdx +++ b/content/cli/connectors.mdx @@ -728,7 +728,7 @@ sf connectors run resume [--accept | --deny | --cancel] [--content ] | `--content=` | none | JSON object of values the parked call asked for. Accepts `@file` or `-` for stdin | | `-T, --team=` | default team | Team slug, ID, or name. Env `SPACEFAST_TEAM` | -Omit the action to read back a decision a person recorded in the dashboard. A run parked for a person refuses a decision from the CLI. +A run parked for a person refuses a decision from the CLI with `human_approval_required`. Once a person decides in the dashboard, the run settles—read the outcome with `sf connectors run inspect ` (`resume` returns `connector_run_not_resumable` on a settled run). ```bash sf connectors run resume cxr_abc123