> ## 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 Your APIs on User's Behalf

> Once Auth0 is set up for User Authentication, you can enable your AI applications and AI agents to securely call your own APIs (first-party APIs) on behalf of authenticated users. This capability allows AI agents to access user-specific data or perform actions with explicit user consent and scope.

## Delegated authorization

The process relies on **delegated authorization**, where the user grants your AI application or AI agent permission to access protected resources without sharing their credentials directly. This is achieved through **access tokens:**. After a user authenticates, Auth0 issues an access token to your AI application. This token represents the user's consent and defines the scope of permissions granted.

<Frame caption="Authorization Flow">
  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai/img/intro/delegated_authorization_diagram_dark.png" alt="Authorization Flow" />

  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai/img/intro/delegated_authorization_diagram_light.png" alt="Authorization Flow" />
</Frame>

### API on Auth0

An API is an entity that represents an external resource, capable of accepting and responding to protected resource requests made by applications. These APIs are configured to accept and validate access tokens. To protect an API, it must be [registered as an API](https://auth0.com/docs/get-started/auth0-overview/set-up-apis) using the Auth0 Dashboard.

### How it works for AI apps and agents

<Steps>
  <Step title="User authentication">
    A user logs into your AI application or agent interface (e.g., via Universal
    Login).
  </Step>

  <Step title="Access token issuance">
    Upon successful authentication, an access token is issued to your
    application.
  </Step>

  <Step title="AI agent makes a tool call">
    When the AI agent needs to access user-specific data or perform an action,
    it makes a tool call to an API endpoint.
  </Step>

  <Step title="Token forwarding">
    The access token obtained in step 2 is included in the API request
    (typically in the `Authorization` header).
  </Step>

  <Step title="API validation & response">
    The API validates the access token. If valid, it processes the request on
    behalf of the user and returns the response to the AI agent.
  </Step>

  <Step title="AI agent receives and processes the information">
    The AI agent then uses this response to fulfill the user's request.
  </Step>
</Steps>

## Get started

To begin Calling your APIs with your AI agents, refer to the following resources:

### Quickstarts

<Columns>
  <Card title="Call Your APIs On User's Behalf" icon="key" iconType="solid" horizontal href="/get-started/call-your-apis-on-users-behalf" />
</Columns>

### Sample Apps

<Columns>
  <Card title="Fullstack (Next.js, FastAPI)" icon="github" iconType="solid" horizontal href="https://github.com/auth0-samples/auth0-ai-samples/tree/main/call-apis-on-users-behalf/your-api" />

  <Card title="Agent0 (React + Fastify + Vercel AI SDK)" icon="github" iconType="solid" horizontal href="https://github.com/auth0-samples/agent0" />

  <Card title="Assistant0 (Next.js, FastAPI)" href="https://github.com/auth0-samples/auth0-assistant0" icon="github" iconType="solid" horizontal />
</Columns>

### Learn more

<Columns>
  <Card title="Auth0 Docs for APIs" icon="book" iconType="solid" horizontal href="https://auth0.com/docs/get-started/apis" />
</Columns>
