1
Get an API key
Sign up for Nango and copy the default Environment API key for your agent. Your backend uses it to call the Nango API.
For agents
For agents
If the user gave you an Environment API key, for example in the prompt, use it.Otherwise, ask the user to sign up at
https://app.nango.dev/signup and copy the default key from https://app.nango.dev/dev/environment-settings#api-keys. It has full permissions.Store it as NANGO_API_KEY in the backend’s local env file, and make sure that file is ignored by Git. Never send the key to a browser or client.All requests below go to https://api.nango.dev with Authorization: Bearer <NANGO-API-KEY>.2
Enable the APIs your agent needs
Pick the APIs your agent can use, for example Gmail, Google Calendar, Slack, or Notion. Nango-managed OAuth apps let you test right away, without registering an app with each provider.
For agents
For agents
Ask the user which APIs their agent needs. Suggest Each result has a Create each missing integration, with the provider slug as the integration ID.If it fails because there is no Nango-managed app for this provider, tell the user. They need to register their own OAuth app.Any other Check the integration has tools. Nango catalog actions are available out of the box, with nothing to deploy:
google-mail (Gmail), google-calendar, slack, and notion if they are unsure.Look up each provider. search matches slugs only, so Gmail is found with google, not gmail:name (the provider slug) and an auth_mode, which decides how to create the integration below.List the integrations that already exist, and reuse them:auth_mode is OAUTH2, OAUTH1, or APP: use a Nango-managed OAuth app, so the user doesn’t need to register one with the provider:auth_mode, such as API_KEY or BASIC: create it with POST /integrations. No developer app is needed, and users enter their own credentials when they connect:3
Create an agent session in your backend
Before each agent run, your backend creates a session for the user the agent acts for. It covers every API you enabled.
For agents
For agents
Before each agent run, create an agent session server-side:Set
<YOUR-USER-ID> to the stable ID of the user the agent acts for, the same value in both places. Without user accounts, use a fixed ID like local-dev-user.The session covers every integration. When the user hasn’t connected one yet, the agent gets a connect link to hand them. See creating a session for all options.The response’s data contains an mcp_url and a session_token.4
Connect the session to your agent
Pass the session’s MCP server to your agent. It works with any agent framework that supports remote MCP servers.
For agents
For agents
Pass the Use the MCP client of the framework the project already uses: see OpenAI, Anthropic, LangChain, and Mastra examples. Keep the agent’s existing tools.Make sure links in the agent’s replies render as clickable links, so the user can open connect links from the chat.
mcp_url to the agent as a remote MCP server, with the session_token as bearer auth. For example, with the Vercel AI SDK:5
Test it
Ask your agent something like “Summarize the last 5 emails in my inbox”. The first time, it replies with a link to connect your account. Authorize, ask again, and the agent runs the right tool.See what was created in the Integrations, Connections, and Logs tabs of the Nango dashboard.
For agents
For agents
Ask the user to run the app and ask the agent something that needs an enabled API, for example:
Summarize the last 5 emails in my inbox.The first time, the agent replies with a connect link. The user opens it, authorizes, and asks again. The agent then finds and runs the right tool.Then point the user to the Integrations, Connections, and Logs tabs in the Nango dashboard. Logs shows every tool call, provider request, and response.Finally, suggest the user connect the Management MCP server with OAuth. It’s the most efficient way for their coding agent to manage integrations, connections, and logs, and to search the Nango docs moving forward.
Next steps
Configure agent sessions
Restrict tools, pin connections, and scope access per user or organization.
Build custom tools
Write action functions for tools the catalog doesn’t have.