This endpoint requires an embed ID, metric ID, and client ID. The metric must be associated with the specified embed configuration for the query to succeed.
Endpoint Formats
- New Endpoint (Recommended)
- Legacy Endpoint (Deprecated Soon)
Authentication
All API requests must include your API key in the Authorization header. Get your API token when creating a data app - see our data app creation guide for details. Finding your API token: For detailed instructions, see the API Token guide.Headers
Bearer token for API authentication. Use your API key from the data app.
Must be set to
application/json for all requests.Request Body
The unique identifier of the embed configuration containing the metric.
The unique identifier of the metric to query.
Unique identifier for the end user making the query. Used for row-level security and access control.
Dashboard-level filters to apply to the metric query. These filters affect the entire dashboard context.
Metric-specific filters to apply to the query. Used for row-level security and additional filtering.
Optional datasource name for multi-datasource environments.
Response
Array of objects containing the query results. Each object represents a row of data with column names as keys.
Example
Query execution time in milliseconds.
Comparison value for metrics with comparison enabled.
Total number of records in the result set.
The metric ID that was queried (echo of request parameter).
Error object if the request failed, otherwise
null for successful requests.Examples
Error Codes
Invalid embed ID - The specified embed ID doesn’t exist or you don’t have access
Invalid metric ID - The specified metric ID doesn’t exist or isn’t associated with the embed
Missing or invalid data app - Check your API key and data app configuration
Embed ID error - The embed ID was not found or doesn’t match the API key being used
Metric not found - The specified metric ID doesn’t exist or isn’t associated with the embed configuration
Invalid datasource name - The specified datasource name doesn’t exist in your workspace
HTTP Status Code Summary
| Status Code | Description |
|---|---|
200 | OK - Query executed successfully |
400 | Bad Request - Invalid request parameters or missing required fields |
401 | Unauthorized - Invalid or expired API token |
404 | Not Found - Embed ID or metric ID not found |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Unexpected server error |
Possible Errors
| Error Code | HTTP Status | Description | Solution |
|---|---|---|---|
INVALID_EMBED_ID | 400 | Embed ID not found | Verify embed ID exists and you have access |
INVALID_METRIC_ID | 400 | Invalid metric ID | Check metric ID and embed association |
INVALID_DATA_APP_API_KEY | 401 | Missing or invalid data app | Check your API key and permissions |
EMBED_PARAM_ERROR | 404 | Embed ID error | Verify embed ID and API key match |
METRIC_NOT_FOUND | 404 | Metric not found | Check metric ID and embed configuration |
DATASOURCE_NAME_ERROR | 400 | Invalid datasource name | Verify datasource name in workspace |
RATE_LIMIT_EXCEEDED | 429 | Too many requests | Implement exponential backoff |
INTERNAL_SERVER_ERROR | 500 | Unexpected failure | Contact support if error persists |
Filtering Guide
Dashboard Filters
Dashboard filters apply to the entire dashboard context and affect all metrics. Common use cases include:- Date range filtering: Limit data to specific time periods
- Category filtering: Filter by region, department, product line, etc.
- Global parameters: Set values that affect multiple metrics
Example
Metric Filters
Metric filters apply specifically to the metric being queried and can be used for:- Row-level security (RLS): Restrict data based on client permissions
- Additional filtering: Apply metric-specific conditions
- Client isolation: Ensure multi-tenant data separation
Example
Use Cases
Export Dashboard Data
Real-time Data Refresh
Multi-Tenant Data Access
Best Practices
- Cache responses - Cache query results when appropriate to reduce API calls and improve performance
- Use filters efficiently - Apply filters at the query level rather than filtering data client-side
- Handle pagination - For large datasets, implement pagination or limit results
- Error handling - Implement robust error handling and retry logic
- Rate limiting - Respect rate limits and implement exponential backoff
- Security - Never expose API keys in client-side code; proxy requests through your backend
Performance Tips
- Minimize filter complexity - Complex filters can slow down queries
- Request only needed columns - If possible, select only required columns
- Use date ranges - Limit queries to specific time periods
- Cache when possible - Cache frequently accessed data
- Batch requests - When querying multiple metrics, consider batching requests
Quick Start Guide
1
Get embed and metric IDs
First, get your embed ID and metric ID from your DataBrain dashboard or via the List APIs:
2
Fetch available metrics
Use the Fetch Metrics by Embed endpoint to get a list of available metrics:
3
Make your first query
Query a metric with minimal parameters:
4
Add filters for specific data
Include filters to narrow down your results:
5
Process the results
Use the returned data in your application:

