HomeDocsDeveloper Quickstart

Developer Quickstart

Register an agent, connect one of your users' tools, and make a governed call — in about ten lines.

Fabriq DeveloperPython SDKTypeScript SDK

Fabriq Developer is for building products whose agents act on your users' own accounts — their Gmail, their Slack, their Notion — without those users ever creating an Agentic Fabriq account. You keep the customer relationship. Agentic Fabriq holds the credentials, and governs and records every call made against them.


1. Register an agent

In the console, go to Agents → Register. You get back an app ID and an app secret.

The app secret is shown once. Store it in your backend's secret manager. It authenticates your server to Agentic Fabriq and must never reach a browser.

Two settings on the agent matter for this flow, both under Settings → Connect & webhooks: the redirect URL your users return to after connecting, and (optionally) a webhook URL so your backend is told when a connection completes even if the user closes the tab.

2. Install the SDK

pip install agentic-fabriq-sdk        # Python — import as af_sdk
npm install @agenticfabriq/sdk        # TypeScript

Both clients read their credentials from the environment, so a quickstart fits on one screen:

AF_APP_ID=org-xxx_my-app
AF_APP_SECRET=...
# optional — defaults to https://dashboard.agenticfabriq.com
AF_BASE_URL=https://dashboard.agenticfabriq.com
Environment variableUsed for
AF_APP_IDYour agent's app ID
AF_APP_SECRETYour agent's app secret
AF_BASE_URLOverride the Agentic Fabriq host
AF_PRIVATE_KEYOptional signing key — see proving who the user is

3. Connect a user's tool

initiate_connection returns a URL. Send your user there; they approve at the provider; the credential lands in Agentic Fabriq's vault. It never passes through your backend.

Python

from af_sdk import AgenticFabriq

af = AgenticFabriq()  # reads AF_APP_ID / AF_APP_SECRET / AF_BASE_URL

# inside your request handler
url = await af.initiate_connection(request, provider="gmail")
return redirect(url)

TypeScript

import { AgenticFabriq } from "@agenticfabriq/sdk";

const af = new AgenticFabriq();

const url = await af.initiateConnection(req, { provider: "gmail" });
res.redirect(url);

You pass the request, not a user id. Identity is read from the session your own auth already established, so there is no user-id argument for an agent to get wrong. See Connecting Your Users' Tools for how that extraction works and the one explicit escape hatch.

Optional arguments: connection_id (defaults to "default", letting one user hold several accounts for the same provider) and scopes (merged with the scopes configured on the agent).

4. Make a governed tool call

for_user mints a short-lived, user-scoped token and hands back a session whose identity is already baked in — no method on it takes a user id.

Python

async with await af.for_user(request) as session:
    tools = await session.get_tools()          # only what this user actually granted
    result = await session.call_tool(
        "google_gmail_list_messages",
        {"max_results": 5},
    )

If you are driving a model rather than calling tools directly, the session converts the same tool list into the shape your provider expects. Load the tools first — the adapters read the cached list:

await session.get_tools()
openai_tools    = session.to_openai_tools()
anthropic_tools = session.to_anthropic_tools()
langchain_tools = session.to_langchain_tools()   # needs langchain-core installed

TypeScript

The TypeScript SDK deliberately does not wrap an MCP client. It gives you the token and the URL; hand them to the MCP client you already use.

const session = await af.forUser(req);

session.userId;     // the id your app authenticated
session.token;      // short-lived, user-scoped bearer token
session.expiresIn;  // seconds
session.mcpUrl;     // MCP endpoint to point your client at

Tokens are short-lived — 900 seconds by default, with a hard ceiling of one hour. The Python client caches and re-mints them 60 seconds before expiry, so calling for_user per request is the intended pattern rather than a waste.

5. What just happened

The SDK is a thin wrapper over an HTTP API you can call directly. Every request authenticates with X-App-Id and X-App-Secret headers (HTTP Basic app_id:secret also works).

SDK callHTTP endpoint
create_userPOST /api/v1/apps/{app_id}/external-users
initiate_connectionPOST /api/v1/apps/{app_id}/external-users/{external_user_id}/oauth/{provider}/initiate
for_userPOST /api/v1/apps/{app_id}/external-users/{external_user_id}/token
session.call_toolPOST /mcp/external (JSON-RPC 2.0, bearer token)

The full request and response shapes are in External Users (B2B2C).

The CLI comes with the Python SDK

Installing agentic-fabriq-sdk also installs afctl. The commands most useful while building:

afctl users list                       # everyone your product has connected
afctl sessions list --population external   # live tokens, and the proof behind each
afctl sessions revoke <jti>            # kill one immediately
afctl triggers list                    # provider-event subscriptions
afctl triggers deliveries              # did my webhook arrive?

Full command reference: CLI Reference (afctl).


What to read next

Need help?

Our team is here to help you get started.