API
Read cost, anomalies, inventory, budgets, and tickets from your own scripts with an OpsLyft access key.
The OpsLyft API gives your scripts the same data you see in the app: cost broken down any way you like, anomalies, your Atlas inventory, budgets, and tickets. Use it to feed a data warehouse, post a weekly cost report to chat, or build your own dashboard.
It's a GraphQL API. You send one POST request with a query that names the fields you want, and get JSON back in the same shape.
Endpoint
POST https://v2.opslyft.com/api/apiEvery request goes to this one address. Settings → MCP & Access Keys → API shows it with a Copy button.
Authenticate
Create an access key, then send it on every request:
Authorization: Bearer olt_1a2b3c4d_…
Content-Type: application/jsonThe key decides what you can read. A key scoped to one AWS account only ever returns cost for that account.
Your first request
Ask the API what your key can do. This works with any key. The examples read the key from an environment variable called API_KEY.
curl https://v2.opslyft.com/api/api \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "{ myAccess { customerId modules keys } }"}'Response:
{
"data": {
"myAccess": {
"customerId": "a1b2c3d4e5",
"modules": ["atlas", "budget", "cost", "monitor"],
"keys": ["atlas.view", "budget.view", "cost.view", "monitor.view"]
}
}
}modulesare the parts of OpsLyft your organisation has turned on. An operation in a module that isn't listed returnsMODULE_NOT_ENABLED.keysare the permissions your key holds. Each operation in the API reference says which one it needs.
Send variables
Put values in variables rather than in the query text. It avoids escaping problems.
{
"query": "query Cost($req: CostQueryInput!) { costQuery(request: $req) { rows total } }",
"variables": {
"req": {
"providers": ["aws"],
"dateRange": { "from": "2026-09-01", "to": "2026-10-01" },
"groupBy": ["service_name"]
}
}
}Conventions
- Dates are
YYYY-MM-DD. In cost queries the end of a range is exclusive: September is{ "from": "2026-09-01", "to": "2026-10-01" }. - Timestamps are ISO 8601 in UTC.
- Money is in your organisation's reporting currency (Settings → General Settings). Cost amounts come back as plain numbers; anomalies, Atlas, and tickets also return the currency itself. Parse an amount as a number even if it arrives as a string.
- Providers are lowercase keys:
aws,azure,gcp,oracle,snowflake,databricks,openai. You get data only for the ones your organisation has connected. - Bill delay: cost data usually runs a day behind the cloud bill. See Data freshness.
- Pagination differs by operation. Each one in the reference says how it pages.
Errors
Errors come back in the standard GraphQL errors array, each with a code:
{
"errors": [
{
"message": "Missing permission cost.view",
"extensions": { "code": "MISSING_PERMISSION", "http": 403, "key": "cost.view" }
}
],
"data": null
}Always check for errors before reading data: most errors, including a missing or wrong key, still come back with HTTP 200. Only a query that isn't valid GraphQL gets HTTP 400. See Errors and limits for every code and what to do about it.
What the API covers
| Area | Read with a key | Change with a key |
|---|---|---|
| Your key's access | Yes | — |
| Cost, including cost by an allocation | Yes | — |
| Anomalies | Yes | No |
| Atlas inventory and change history | Yes | — |
| Budgets | Yes | No |
| Tickets | Yes, if your organisation uses Tickets | No |
| Canvas figures | Yes, with the canvas data API | — |
| Canvas settings, datasets, saved views, Dimension Studio rules | No | No |
"No" means a signed-in person has to do it in the app. See what keys can't do yet.
Operations not listed in the API reference are internal to the OpsLyft app and can change without notice. Don't build on them.
No schema download
Introspection is turned off, so GraphQL tools can't download the schema. The API reference lists every type you need.
Tips
- Request only the fields you need. Smaller queries return faster.
- Set a long timeout. Large cost queries can take up to two minutes. OpsLyft stops a query that runs longer.
- Cache results. Cost for past days rarely changes, so a nightly pull is usually enough.
- Use one key per integration, with the smallest role that works. Viewer on All spend can call every operation in the reference. A key can't hold more than the person who creates it, so if your own role is narrower, give the key your role instead.
Related
- API reference
- Canvas data, to read a whole canvas's figures in one request
- Access keys
- Errors and limits
- MCP, if you want an AI client to ask the questions for you