Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ComposioHQ/composio/llms.txt

Use this file to discover all available pages before exploring further.

Composio handles authentication end-to-end. You define an auth config for each toolkit — or use Composio’s managed defaults — and Composio generates a Connect Link that users follow to grant access. Once a user completes the flow, Composio creates a connected account, stores the credentials, and handles token refresh automatically. Your agent never touches raw tokens.

Auth schemes

Composio supports four authentication schemes:
SchemeDescriptionExamples
OAUTH2Three-legged OAuth 2.0. Composio handles the redirect, code exchange, and token refresh.Gmail, GitHub, Slack, Notion
API_KEYUser provides a static API key. Stored securely and passed in request headers.Linear, OpenAI, Pinecone
BEARER_TOKENA bearer token passed in the Authorization header. Similar to API key but typed as a Bearer scheme.Some REST APIs
BASICUsername and password sent with each request using HTTP Basic Auth.Legacy APIs, self-hosted tools
Composio auto-detects the correct scheme for each toolkit. You only need to think about schemes when creating custom auth configs.

Managed auth (default)

Most toolkits work out of the box with Composio managed auth. Composio provides its own registered OAuth app credentials, so you can authenticate users immediately without setting up your own OAuth apps.
import { Composio } from '@composio/core';

const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });

// Composio auto-creates an auth config with its managed credentials
const session = await composio.create("user_123");

const connectionRequest = await session.authorize("github");
console.log(connectionRequest.redirectUrl);
// User visits this URL to connect their GitHub account
With managed auth, the OAuth consent screen shows Composio’s branding. If you want your own app name and logo on the OAuth screen, use a custom auth config instead.

Custom auth configs

Create a custom auth config when you want to use your own OAuth app credentials — for white-labeling, custom scopes, or toolkits that require your own API registration.
import { Composio } from '@composio/core';

const composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY });

const authConfig = await composio.authConfigs.create("gmail", {
  type: "use_custom_auth",
  name: "My Gmail OAuth App",
  authScheme: "OAUTH2",
  credentials: {
    client_id: process.env.GOOGLE_CLIENT_ID,
    client_secret: process.env.GOOGLE_CLIENT_SECRET,
  },
});

console.log(authConfig.id); // "ac_abc123" — store this ID
For API key-based toolkits, pass the key in the credentials directly:
const authConfig = await composio.authConfigs.create("linear", {
  type: "use_custom_auth",
  name: "Linear API Key",
  authScheme: "API_KEY",
  credentials: {
    api_key: process.env.LINEAR_API_KEY,
  },
});
Once you have an auth config ID, use it when creating sessions or initiating connections to ensure your credentials are used:
const session = await composio.create("user_123", {
  authConfigs: {
    gmail: "ac_abc123",
  },
});
You can also list, update, enable, and disable auth configs:
// List all auth configs for a toolkit
const configs = await composio.authConfigs.list({ toolkit: "gmail" });

// Get a specific config
const config = await composio.authConfigs.get("ac_abc123");

// Disable a config (prevents new connections, doesn't break existing ones)
await composio.authConfigs.disable("ac_abc123");

// Delete a config
await composio.authConfigs.delete("ac_abc123");
A Connect Link is a hosted page where users securely authenticate with a toolkit. Composio generates a unique link for each user-toolkit pair. The link handles the entire OAuth flow — redirect, code exchange, token storage — and then redirects back to your callbackUrl. Via session:
const session = await composio.create("user_123");

const connectionRequest = await session.authorize("github", {
  callbackUrl: "https://myapp.com/auth/callback",
});

console.log(connectionRequest.redirectUrl);
// "https://connect.composio.dev/link/ln_abc123"

// After the user visits the URL and authenticates:
const connectedAccount = await connectionRequest.waitForConnection();
console.log(connectedAccount.status); // "ACTIVE"
Via connectedAccounts.link() directly:
const connectionRequest = await composio.connectedAccounts.link(
  "user_123",
  "ac_abc123",
  { callbackUrl: "https://myapp.com/auth/callback" }
);

const redirectUrl = connectionRequest.redirectUrl;

In-chat authentication

When your agent needs a toolkit that the user hasn’t connected yet, Composio’s COMPOSIO_MANAGE_CONNECTIONS meta tool automatically generates a Connect Link and presents it in chat — no code required. In-chat authentication is enabled by default in all sessions. The agent pauses, presents the link, and continues once the user confirms they’ve authenticated. No session configuration is needed.
Use in-chat authentication for broad agents that connect different apps depending on user intent. Use session.authorize() for onboarding flows where you want users connected before they start chatting.

When to use managed vs. custom auth

ScenarioRecommendation
Getting started, prototypingManaged auth — zero setup, works immediately
You want your brand on the OAuth consent screenCustom auth config with your own OAuth app
You need specific OAuth scopes beyond Composio’s defaultsCustom auth config with scopes override
The toolkit requires your own API registration (e.g., some enterprise apps)Custom auth config
You have existing OAuth apps and connected users to migrateCustom auth config — import your existing credentials

Connected Accounts

List, create, and manage per-user credentials

Sessions

How sessions scope auth to a single user

Authenticating Users Guide

Step-by-step onboarding flow with Connect Links

TypeScript Reference

Full API reference for authConfigs and connectedAccounts

Build docs developers (and LLMs) love