Analytics
Ask Analytics
Query your billing data using natural language questions.
POST
/
v1
/
analytics
/
ask
Ask a natural-language analytics question
curl --request POST \
--url https://billing.example.com/v1/analytics/ask \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"question": "What was my MRR growth over the last 3 months?"
}
'import requests
url = "https://billing.example.com/v1/analytics/ask"
payload = { "question": "What was my MRR growth over the last 3 months?" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({question: 'What was my MRR growth over the last 3 months?'})
};
fetch('https://billing.example.com/v1/analytics/ask', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/analytics/ask",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'question' => 'What was my MRR growth over the last 3 months?'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/analytics/ask"
payload := strings.NewReader("{\n \"question\": \"What was my MRR growth over the last 3 months?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/analytics/ask")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"question\": \"What was my MRR growth over the last 3 months?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/analytics/ask")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"question\": \"What was my MRR growth over the last 3 months?\"\n}"
response = http.request(request)
puts response.read_body{
"data": "<unknown>",
"query": "<string>"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
question | string | Yes | A natural language question about your billing data. For example: “What was the MRR growth last quarter?” or “Which plans have the highest churn rate?” |
Example Request
curl -X POST https://api.recurso.dev/v1/analytics/ask \
-H "Authorization: Bearer rsk_live_7f3a9b2c1d4e8f0a" \
-H "Content-Type: application/json" \
-d '{
"question": "What is our monthly recurring revenue trend for the last 6 months?"
}'
Response
{
"answer": "Your MRR has grown from $42,350 to $58,920 over the last 6 months, representing a 39.1% increase. The strongest growth occurred in March 2026 with a 12.3% month-over-month increase driven by 47 new subscriptions on the Pro plan.",
"data": {
"series": [
{ "month": "2026-01", "mrr": 42350 },
{ "month": "2026-02", "mrr": 44780 },
{ "month": "2026-03", "mrr": 50290 },
{ "month": "2026-04", "mrr": 53100 },
{ "month": "2026-05", "mrr": 56440 },
{ "month": "2026-06", "mrr": 58920 }
],
"total_growth_pct": 39.1,
"avg_monthly_growth_pct": 5.7
},
"query": "SELECT DATE_TRUNC('month', period_start) AS month, SUM(amount) AS mrr FROM invoices WHERE status = 'paid' AND period_start >= NOW() - INTERVAL '6 months' GROUP BY 1 ORDER BY 1"
}
Notes
- The AI engine translates your natural language question into a structured query against your billing database.
- The
queryfield in the response shows the generated SQL for transparency and debugging. - Complex questions may take up to 10 seconds to process.
- Results are scoped to your organization’s data and respect role-based access controls.
The
query field is provided for informational purposes only. Do not execute it directly against your database.Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Body
application/json
Example:
"What was my MRR growth over the last 3 months?"
⌘I
Ask a natural-language analytics question
curl --request POST \
--url https://billing.example.com/v1/analytics/ask \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"question": "What was my MRR growth over the last 3 months?"
}
'import requests
url = "https://billing.example.com/v1/analytics/ask"
payload = { "question": "What was my MRR growth over the last 3 months?" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({question: 'What was my MRR growth over the last 3 months?'})
};
fetch('https://billing.example.com/v1/analytics/ask', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/analytics/ask",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'question' => 'What was my MRR growth over the last 3 months?'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/analytics/ask"
payload := strings.NewReader("{\n \"question\": \"What was my MRR growth over the last 3 months?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/analytics/ask")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"question\": \"What was my MRR growth over the last 3 months?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/analytics/ask")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"question\": \"What was my MRR growth over the last 3 months?\"\n}"
response = http.request(request)
puts response.read_body{
"data": "<unknown>",
"query": "<string>"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}