Documentation Index
Fetch the complete documentation index at: https://mintlify.com/metabase/metabase/llms.txt
Use this file to discover all available pages before exploring further.
The Agent API is available on Metabase Pro and Enterprise plans.
Why use the Agent API
The Agent API offers several advantages over the standard Metabase API:- Explicitly supported for agents - Endpoints are designed specifically for building agentic BI applications
- Versioned and stable - Your apps can rely on consistent responses across updates
- JWT authentication - Requests can be scoped to a user’s permissions
- No MBQL required - You don’t need to work with Metabase’s internal querying language
Supported features
The Agent API currently supports:- Discovering tables and metrics - List available data sources
- Inspecting fields - Get detailed field information and metadata
- Constructing and executing queries - Build and run queries programmatically
Base path:
/api/agentView the full API reference for detailed endpoint documentation.Authentication
The Agent API supports two authentication modes, both requiring JWT to be configured in Metabase admin settings (Admin > Settings > Authentication > JWT).Stateless JWT (recommended for agents)
Pass a signed JWT directly in each request. This is the recommended approach for AI agents and headless applications.Required JWT claims
| Claim | Type | Required | Description |
|---|---|---|---|
iat | int | Yes | Issued-at time (Unix seconds). JWT must be less than 180 seconds old. |
email | string | Yes | Email matching a Metabase user. The claim name is configurable via the jwt-attribute-email admin setting (default: “email”). |
first_name | string | No | User’s first name. |
last_name | string | No | User’s last name. |
groups | array | No | List of groups for group sync. |
Example JWT payload
Session-based authentication
Alternatively, exchange a JWT atPOST /auth/sso to get a session token, then pass the session token via:
Common use cases
Building an AI agent
The Agent API is designed for AI agents that need to:- Discover available data - Query what tables and metrics exist
- Understand schema - Inspect fields and relationships
- Generate queries - Construct queries based on user questions
- Execute queries - Run queries and return results
Configure JWT authentication
Set up JWT in Admin > Settings > Authentication > JWT with a shared secret
Generate JWT tokens
Create JWTs signed with your secret for each request, including the user’s email
Discover available data
Call
/api/agent/tables to list available tables and metrics the user can accessExample: Building a Slack bot
Here’s how you might use the Agent API to build a Slack bot that answers data questions:Permissions and security
The Agent API respects Metabase’s permission system:- User-scoped - All requests are scoped to the authenticated user’s permissions
- Data permissions - Users can only access tables and fields they have permission to see
- Collection permissions - Users can only access metrics and models they have permission to use
- Row-level security - Sandboxing and row-level permissions apply to Agent API requests
Because the Agent API uses JWT authentication, you can dynamically scope requests to different users by including their email in the JWT. This makes it perfect for multi-tenant applications.
Rate limiting and quotas
The Agent API follows standard Metabase API rate limits:- Rate limits apply per authenticated user
- Quotas depend on your Metabase plan
- Failed authentication attempts are rate limited separately
For high-volume applications, consider implementing caching and request batching to stay within rate limits.
Best practices
JWT token management
Generate fresh tokens
Generate a new JWT for each request or set of related requests. JWTs expire after 180 seconds.
Keep secrets secure
Store your JWT secret securely using environment variables or a secrets manager. Never commit secrets to version control.
Query optimization
- Cache results - Cache frequently accessed data to reduce API calls
- Batch requests - When possible, batch multiple operations into fewer requests
- Use filters - Apply filters to limit result set sizes
- Monitor performance - Track query execution times and optimize slow queries
Error handling
Example workflows
Workflow 1: Answer a natural language question
Workflow 2: Build a custom BI dashboard
Migrating from standard API
If you’re currently using the standard Metabase API:| Standard API | Agent API | Notes |
|---|---|---|
| Session-based auth | JWT-based auth | Agent API uses stateless JWT |
| MBQL queries | Simplified queries | No need to construct MBQL |
/api/database | /api/agent/tables | Simpler table discovery |
/api/card/:id/query | /api/agent/query | Streamlined query execution |
The Agent API is designed to be simpler and more stable than the standard API, but it currently supports fewer features. Use the standard API for features not yet available in the Agent API.