> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Call Other's APIs on User's Behalf

> [Token Vault](/intro/token-vault) lets your AI agent call external APIs on the user's behalf. We provide SDKs for Python, JavaScript, and popular AI frameworks like LangChain, LlamaIndex, Genkit, and Vercel AI, making it easy and straightforward to get access tokens for external applications.

## Applications with refresh tokens

In a typical scenario, a user interacts with a frontend application (e.g., a chatbot interface). This frontend communicates with a secure backend service, often a Backend for Frontend (BFF) or an agent, which is responsible for calling the external API. Such applications can use refresh tokens for long-lived sessions and use the same refresh tokens to securely call external APIs on the user's behalf via Token Vault.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  If your application uses [Organizations](https://auth0.com/docs/manage-users/organizations), authenticate the user with the target organization before authorizing the external provider through Connected Accounts. Organizations determine the session context, but Token Vault still exchanges tokens for the individual signed-in user.
</Callout>

<Frame caption="Token Vault using Refresh Tokens">
  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai/img/intro/authentication_for_users_of_ai_applications_diagram_dark.png" alt="Token Vault using Refresh Tokens" />

  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai/img/intro/authentication_for_users_of_ai_applications_diagram_light.png" alt="Token Vault using Refresh Tokens" />
</Frame>

By modeling your agent's backend as a secure application, it can obtain the necessary tokens from Token Vault to interact with external APIs while maintaining the user's context and permissions.

## Applications without refresh tokens

In scenarios where refresh tokens cannot be used, such as single-page applications (SPAs) or headless agents and CLIs, you can still call external APIs on the user's behalf via Token Vault using Auth0 access tokens. To do so, use the Auth0 Dashboard to configure the following:

* [An API in Auth0](https://auth0.com/docs/get-started/auth0-overview/set-up-apis): You need to register an API in the Auth0 Dashboard with the appropriate settings.
* A Custom API Client in Auth0: The Custom API Client allows your API server to perform token exchanges using access tokens instead of refresh tokens. This client enables Token Vault to exchange an access token for an external API access token (e.g., Google Calendar API).

<Frame caption="Token Vault using Access Tokens">
  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai/img/intro/web_applications_with_spa_diagram_dark.png" alt="Token Vault using Access Tokens" />

  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai/img/intro/web_applications_with_spa_diagram_light.png" alt="Token Vault using Access Tokens" />
</Frame>

Check out this [guide](/ai/docs/get-started/call-others-apis-on-users-behalf#vercel-ai-%2B-react-spa) for an example.

## Get started

To begin using Auth0 Token Vault with your AI agents, refer to the following resources:

### Quickstarts

<Columns cols={2}>
  <Card title="Call Other's APIs on User's Behalf" href="/ai/docs/get-started/call-others-apis-on-users-behalf" icon="key" horizontal />
</Columns>

### Guides

<Columns cols={2}>
  <Card title="Check Google Calendar Availability" href="/ai/docs/how-tos/check-google-calendar-availability" icon="calendar" horizontal />

  <Card title="List GitHub Repositories" href="/ai/docs/how-tos/list-github-repositories" icon="github" horizontal />

  <Card title="List Slack Channels" href="/ai/docs/how-tos/list-slack-channels" icon="slack" horizontal />

  <Card title="Get Salesforce Opportunities" href="/ai/docs/how-tos/get-salesforce-opportunities" icon="salesforce" horizontal />
</Columns>

### Sample Apps

<Columns cols={2}>
  <Card
    title="Assistant0: Next.js + LangGraph"
    href="https://github.com/auth0-samples/auth0-assistant0/tree/main/ts-langchain"
    icon={
  <img
    src="https://mintlify-assets.b-cdn.net/auth0/langchain.svg"
    alt="LangChain"
  />
}
    horizontal
  />

  <Card
    title="Assistant0: Next.js + Vercel AI SDK"
    href="https://github.com/auth0-samples/auth0-assistant0/tree/main/ts-vercel-ai"
    icon={
  <img
    src="https://mintlify-assets.b-cdn.net/auth0/vercel.svg"
    alt="Vercel AI"
  />
}
    horizontal
  />

  <Card
    title="Assistant0: FastAPI + LangGraph"
    href="https://github.com/auth0-samples/auth0-assistant0/tree/main/py-langchain"
    icon={
  <img
    src="https://mintlify-assets.b-cdn.net/auth0/langchain.svg"
    alt="LangChain"
  />
}
    horizontal
  />

  <Card
    title="Assistant0: Next.js + LlamaIndex"
    href="https://github.com/auth0-samples/auth0-assistant0/tree/main/ts-llamaindex"
    icon={
  <img
    src="https://mintlify-assets.b-cdn.net/auth0/llamadex.svg"
    alt="LlamaIndex"
  />
}
    horizontal
  />

  <Card title="Auth0 AI SDK TypeScript samples" href="https://github.com/auth0/auth0-ai-js/tree/main/examples/calling-apis" icon="github" horizontal />

  <Card title="Auth0 AI SDK Python samples" href="https://github.com/auth0/auth0-ai-python/tree/main/examples/calling-apis" icon="github" horizontal />
</Columns>

### Learn more

<Columns cols={2}>
  <Card title="Configure Token Vault" href="https://auth0.com/docs/secure/tokens/token-vault/configure-token-vault" icon="gear" horizontal />

  <Card title="Refresh Token Exchange with Token Vault" href="https://auth0.com/docs/secure/tokens/token-vault/refresh-token-exchange-with-token-vault" icon="key" horizontal />

  <Card title="Access Token Exchange with Token Vault" href="https://auth0.com/docs/secure/tokens/token-vault/access-token-exchange-with-token-vault" icon="key" horizontal />
</Columns>
