> ## Documentation Index
> Fetch the complete documentation index at: https://auth0-genai-fix-a4aa-connections-content-audit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Call First-Party APIs on User's Behalf

> Enable your AI agents to securely call first-party APIs on behalf of authenticated users.

A first-party API in Auth0 is owned and operated by your organization and [registered](https://auth0.com/docs/get-started/auth0-overview/set-up-apis) in the Auth0 Dashboard.

The user can grant your AI agent permission to access a first-party API on their behalf. After a user authenticates, Auth0 issues an access token scoped to the first-party API that contains the permissions granted by the user.

## How it works

The following diagram shows the delegated authorization flow for calling a first-party API:

<Frame caption="Authorization Flow">
  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/auth0-genai-fix-a4aa-connections-content-audit/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-fix-a4aa-connections-content-audit/img/intro/delegated_authorization_diagram_light.png" alt="Authorization Flow" />
</Frame>

<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">
    After the user authenticates, Auth0 issues an access token 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
    the user's behalf and returns the response to the AI agent.
  </Step>

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

## Get started

To enable your AI agents to call your own APIs, 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>
