Accounts and providers
Declare providers, user and app account requirements, credential placements, account health checks, and setup help in an Executor app.
An Executor app requests credentials with defineProvider and lists requirements under user.accounts or app.accounts in defineApp. Providers declare secrets or oauth2 methods, allowed hosts, outbound request placements, a health check, and Markdown setup help (guide, clientGuide, field description). This works on Local, Self-host, and Cloud.
The step that matters most: declare hosts and request on every provider so Executor keeps secret fields as sealed handles injected only on requests to those hosts.
Prerequisites and permissions: a deployable app (Build an app). Any user with app access links their own user accounts on the Accounts tab; linking app accounts requires the Local owner, or the app creator, admin, or owner on Cloud and Self-host.
You’ll know it worked when… connecting an account on the Accounts tab passes your health check and a tool call reaches the upstream API.
How to use it
The provider code is identical across Local, Self-host, and Cloud. Linking differs only in who links shared accounts: on Local, you link every slot yourself; on Cloud and Self-host, each member links their own user.accounts while an app manager links app.accounts for everyone who uses the app.
1. Define a provider with hosts and request
Call defineProvider({ name, hosts, auth, health }):
authmaps method names tosecrets({ label, guide?, fields, request? })oroauth2({ ..., clientGuide?, request? }).hostslists the exact hostnames (such as["api.linear.app"]) that may receive this provider’s credentials. Whenhostsis declared, unmarked string fields reach app code as sealedSecretStringhandles that the host replaces only on outbound requests to those hosts.requestrestricts where each secret field may be sent usingbearer(token),basic(user, pass),header(name, value),query(name, value),base64(value), and thettemplate helper. Callaccount.request.headers()oraccount.request.url(baseUrl)inside your tools to build matching requests.- Wrap non-secret configuration fields (such as a base URL or workspace subdomain) with
plain(string()). Wrap a secret that app code must inspect directly (such as an HMAC signing key) withraw(string()).
2. Declare user vs app requirements
Pass requirements as the first argument to defineApp:
user: { accounts: { github } }— each caller links their own account, read atctx.user.accounts.github.app: { accounts: { service } }— an app manager links one shared account for the whole app, read atctx.app.accounts.service. App-scoped schedules and webhooks can use onlyapp.accountsbecause they run without a caller.provider.many()— lets a caller link zero or more accounts of the same provider (for example multiple workspaces). Pairprovider.many()withaccountRouter(ctx.user?.accounts.linear ?? [], (account) => ...)inside a factorydefineApp(requirements, async (ctx) => ...)to mount one sub-router per linked account.
3. Add a health check
Add a health: async ({ account, fetch, signal, deadline }) => { ... } function to defineProvider. Make one safe authenticated read (never a write) that proves the account works. Returning resolves as healthy; throwing ProviderError (or a non-2xx HTTP failure handled by decodeJson) tells the connect form why credentials were rejected without exposing secrets. For MCP servers, use mcpHealth from apps/mcp.
4. Write setup help
Setup help belongs to your app version, not the provider’s identity, so editing text never breaks existing account links:
- Put per-field instructions in each field’s options (
string({ title: "...", description: "..." })), wheredescriptionis Markdown. - Add
guideon asecretsmethod for ordered setup steps, prerequisites, or warnings shown above the form. - Add
clientGuideon anoauth2method to explain where to create an OAuth client and which scopes or settings to pick; Executor displays its own redirect URL above yourclientGuide.
Example
import {
bearer,
decodeJson,
defineApp,
defineProvider,
object,
plain,
ProviderError,
query,
router,
secrets,
string,
} from "apps";
const linear = defineProvider({
name: "Linear",
hosts: ["api.linear.app"],
auth: {
apiKey: secrets({
label: "Personal API key",
guide: `
1. Open [Linear Security & access](https://linear.app/settings/account/security).
2. Create a personal API key and paste it below.
`,
fields: object({
apiKey: string({ description: "Personal API key starting with `lin_api_`." }),
teamKey: plain(
string({ description: "Optional default team key, such as `ENG`." }),
).optional(),
}),
request: ({ apiKey }) => [bearer(apiKey)],
}),
},
health: async ({ account, fetch, signal }) => {
const res = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
...account.request.headers(),
"Content-Type": "application/json",
},
body: JSON.stringify({ query: "{ viewer { id } }" }),
signal,
});
if (res.status === 401 || res.status === 403) {
throw new ProviderError({
reason: res.status === 401 ? "unauthorized" : "rejected",
status: res.status,
});
}
if (!res.ok) {
throw new ProviderError({ reason: "unavailable", status: res.status });
}
},
});
const requirements = { user: { accounts: { linear } } };
const viewer = query(
{
description: "Return the signed-in Linear viewer",
input: object({}),
output: object({ id: string(), name: string() }),
},
async ({ fetch, signal, user }) => {
const res = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
...user.accounts.linear.request.headers(),
"Content-Type": "application/json",
},
body: JSON.stringify({ query: "{ viewer { id name } }" }),
signal,
});
const body = await decodeJson(
res,
object({ data: object({ viewer: object({ id: string(), name: string() }) }) }),
);
return body.data.viewer;
},
);
export default defineApp(requirements, { tools: router({ viewer }) });
Limits
- Setup help limits:
guideandclientGuideallow at most 4,000 characters, and each fielddescriptionallows at most 1,000 characters. Links must be absolutehttps:URLs; HTML tags and Markdown images are rejected. Common leading indentation is stripped automatically. - Sealed handle scanning: outbound request bodies over 1 MiB and streamed bodies are not scanned for sealed handles; place credentials in headers or query parameters via
requestinstead. - OAuth protocol parameters:
authorizationParamsandauthorizationUrlquery strings cannot set host-owned protocol parameters (response_type,client_id,redirect_uri,state,scope,code_challenge,code_challenge_method,nonce,resource,request,request_uri). Settingpkce: falserequires a confidentialtokenEndpointAuthMethod(client_secret_post,client_secret_basic, orclient_secret_basic_raw). - Health check deadline: Executor passes a
deadlinetimestamp onAccountCheckContext; a check that is still running whendeadlinepasses fails without its own message. Passsignalto everyfetchcall. - Account isolation: managing an app on Cloud or Self-host does not grant access to another member’s linked
user.accounts. App-scopedapp.accountsare shared by everyone who can use the app.