API Reference
REST API for managing optimizations, models, warehouse connections, and metrics programmatically.
The Levered API manages optimizations, models, warehouse connections, and metrics. Every operation available in the dashboard is also available through the API. Use the API for automation, CI/CD pipelines, and AI agent workflows.
Base URL
https://api.levered.devAll endpoint paths in this reference are relative to the base URL. For example, GET /api/v2/optimizations means GET https://api.levered.dev/api/v2/optimizations.
Authentication
Protected endpoints require a Clerk OAuth bearer token in the Authorization header:
curl https://api.levered.dev/api/v2/optimizations \
-H "Authorization: Bearer <token>"Tokens are issued by Clerk and scoped to your organization. If the token is missing or invalid, the API returns 401 Unauthorized.
The posterior query also accepts a Levered API key, as Authorization: Bearer lvk_... or in the X-API-Key header.
Public endpoints
The following endpoint does not require authentication:
POST /api/v2/optimizations/:id/servereturns one variant selected for a user
This endpoint is intended for client-side and edge code, which cannot keep a secret.
Rate limiting
| Scope | Limit |
|---|---|
| Global (all endpoints) | 500 requests/min per IP |
| Serve endpoints (public) | 500 requests/min per IP |
If a client exceeds the limit, the API returns 429 Too Many Requests with a Retry-After header.
Response format
The posterior query response has no meta object. All other responses include a meta object with a unique request ID and the resolved organization:
{
"...": "...",
"meta": {
"request_id": "req_abc123",
"organization_id": "org_xyz"
}
}Response fields are at the top level, next to meta. The response has no data wrapper.
Error format
Errors use standard HTTP status codes with a JSON body whose error field is a message string:
{
"error": "Optimization not found"
}Some errors also carry a statusCode field, and request validation errors can carry error as an array of validation issues. Error responses have no meta object.
| Status | Meaning |
|---|---|
400 | Bad request. The body is malformed or a parameter is invalid. |
401 | Unauthorized. The token is missing or invalid. |
403 | Forbidden. The token is valid but has insufficient permissions. |
404 | Not found |
406 | The design has more than 100 variants. |
409 | Conflict with the current state, for example a duplicate design or a metric still used by a guardrail. |
422 | The request is well-formed but cannot be processed, for example an invalid guardrail or training data. |
429 | Rate limit exceeded |
500 | Internal server error |
502 | Your warehouse or the model service returned an error. |
MCP Integration
https://api.levered.dev/mcp serves an MCP (Model Context Protocol) server for AI agents. Clients sign in with OAuth. The server has two tools:
| Tool | Description |
|---|---|
list_prompt_documents | Lists the prompt documents that Levered provides. |
get_prompt_document | Returns one prompt document by its slug. |
The MCP server has no tools that read or change optimizations. Agents use the CLI or the REST API for optimizations, results and the posterior.
Endpoints
- Optimizations: create, update, serve variants, and view results
- Models: train models
- Posterior: query the posterior, the source of every model figure
- Warehouse: manage data warehouse connections and tables
- Metrics: define reward and assignment metrics