API reference
Ask in plain language
Resolves a question into a metrics query and returns the rows plus the interpretation used, so a caller can show how the question was read. No model is called: the parser is deterministic and the fetch is SQL.
/v1/querycurl -X POST "https://api.cresva.ai/v1/query" \ -H "Authorization: Bearer $CRESVA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"question":"What was my Meta ROAS last week?","brand_id":"brd_8Kq2mR4xVn"}'Illustrative values. The parameter names, types and defaults are the ones the endpoint enforces.
Authorization
AuthorizationAuthorization: Bearer cresva_sk_live_.... A key beginning cresva_sk_test_ returns simulated data from this endpoint instead.Body parameters
Sent as a JSON object. Content-Type must be application/json.
questionstringrequiredmin length 1 · max length 500
brand_idstringoptionalBrand to query. Required when the account has more than one brand.
When brand_id is required
/v1/brands to see which ids a key can address.Response
Returns 200 with the fields below. Every successful response also carries meta.request_id, which identifies the call in a support conversation, and meta.simulated, which is true when a test key was used.
questionstringrequiredbrand_idstringrequiredinterpretationobjectrequiredintentstring or nullrequiredmetricsarray of string or nullrequiredlevelstring or nullrequiredtimeobject or nullrequired
dataarray of objectrequiredmetaobjectrequiredPresent on every successful response.
request_idstringrequiredsimulatedbooleanrequiredTrue when a cresva_sk_test_ key was used and the data is simulated.
{ "question": "string", "brand_id": "brd_8Kq2mR4xVn", "interpretation": { "intent": "metric_lookup", "metrics": [ "string" ], "level": "campaign", "time": { "...": "provider shaped" } }, "data": [ { "...": "provider shaped" } ], "meta": { "request_id": "req_01JQ8Z3M6WT4", "simulated": false }}Shape generated from the response schema. The values are illustrative.
Errors
Failures use one envelope: { "error": { "code", "message" } }. The codes this endpoint can return:
400 invalid_request401 unauthorized403 forbidden429 rate_limited500 internal_error