Skip to content
Docs
API 1.0.0 · 22 Nov 2026

Search the docs

    Română

    Run a question and read the result

    Create a saved question, execute it and reconcile its grouped rows.

    Choose metricId, period, optional company and department, grouping dimension, sort direction and presentation. A presentation changes how the rows are displayed, not which invoices contribute.

    curl

    curl -X POST "$RDC_BASE_URL/reports/v1/questions" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "41800000-0000-4000-8000-000000000127",
      "expectedRevision": 0,
      "id": "revenue-by-product",
      "metricId": "net-revenue",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      },
      "dimension": "productLine",
      "direction": "asc",
      "presentation": "table"
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/questions`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "41800000-0000-4000-8000-000000000127",
        "expectedRevision": 0,
        "id": "revenue-by-product",
        "metricId": "net-revenue",
        "filters": {
          "period": "2026-10",
          "companyId": null,
          "department": null
        },
        "dimension": "productLine",
        "direction": "asc",
        "presentation": "table"
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/reports/v1/questions',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': '41800000-0000-4000-8000-000000000127',
            'expectedRevision': 0,
            'id': 'revenue-by-product',
            'metricId': 'net-revenue',
            'filters': {
                'period': '2026-10',
                'companyId': None,
                'department': None,
            },
            'dimension': 'productLine',
            'direction': 'asc',
            'presentation': 'table',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "41800000-0000-4000-8000-000000000127",
      "expectedRevision": 0,
      "id": "revenue-by-product",
      "metricId": "net-revenue",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      },
      "dimension": "productLine",
      "direction": "asc",
      "presentation": "table"
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/questions');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
            'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS => $body,
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/questions");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "41800000-0000-4000-8000-000000000127",
      "expectedRevision": 0,
      "id": "revenue-by-product",
      "metricId": "net-revenue",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      },
      "dimension": "productLine",
      "direction": "asc",
      "presentation": "table"
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 202

    {
      "operationId": "41800000-0000-4000-8000-000000000127",
      "status": "accepted",
      "aggregateRevision": 1
    }

    curl

    curl "$RDC_BASE_URL/reports/v1/questions/revenue-by-product" \
      -H "Authorization: Bearer $RDC_TOKEN"

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/questions/revenue-by-product`, {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
      },
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'GET',
        f'{os.environ["RDC_BASE_URL"]}/reports/v1/questions/revenue-by-product',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/questions/revenue-by-product');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'GET',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        ],
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/questions/revenue-by-product");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 200

    {
      "id": "revenue-by-product",
      "revision": 1,
      "metricId": "net-revenue",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      },
      "dimension": "productLine",
      "direction": "asc",
      "presentation": "table"
    }

    After the create operation completes, use the current question revision and a new runId to execute it. Reuse the same operationId and body after a network timeout. A different body with the same operationId is refused.

    curl

    curl -X POST "$RDC_BASE_URL/reports/v1/questions/revenue-by-product/runs" \
      -H "Authorization: Bearer $RDC_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
      "operationId": "41800000-0000-4000-8000-000000000001",
      "expectedRevision": 1,
      "runId": "41800000-0000-4000-8000-000000000002",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      }
    }'

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/questions/revenue-by-product/runs`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        "operationId": "41800000-0000-4000-8000-000000000001",
        "expectedRevision": 1,
        "runId": "41800000-0000-4000-8000-000000000002",
        "filters": {
          "period": "2026-10",
          "companyId": null,
          "department": null
        }
      }),
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'POST',
        f'{os.environ["RDC_BASE_URL"]}/reports/v1/questions/revenue-by-product/runs',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
        json={
            'operationId': '41800000-0000-4000-8000-000000000001',
            'expectedRevision': 1,
            'runId': '41800000-0000-4000-8000-000000000002',
            'filters': {
                'period': '2026-10',
                'companyId': None,
                'department': None,
            },
        },
    )
    result = response.json()

    PHP

    <?php
    
    $body = <<<'JSON'
    {
      "operationId": "41800000-0000-4000-8000-000000000001",
      "expectedRevision": 1,
      "runId": "41800000-0000-4000-8000-000000000002",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      }
    }
    JSON;
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/questions/revenue-by-product/runs');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
            'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS => $body,
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/questions/revenue-by-product/runs");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    request.Content = new StringContent("""
    {
      "operationId": "41800000-0000-4000-8000-000000000001",
      "expectedRevision": 1,
      "runId": "41800000-0000-4000-8000-000000000002",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      }
    }
    """, System.Text.Encoding.UTF8, "application/json");
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 202

    {
      "operationId": "41800000-0000-4000-8000-000000000001",
      "status": "accepted",
      "aggregateRevision": 1
    }

    curl

    curl "$RDC_BASE_URL/reports/v1/runs/41800000-0000-4000-8000-000000000002" \
      -H "Authorization: Bearer $RDC_TOKEN"

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/reports/v1/runs/41800000-0000-4000-8000-000000000002`, {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
      },
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'GET',
        f'{os.environ["RDC_BASE_URL"]}/reports/v1/runs/41800000-0000-4000-8000-000000000002',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/reports/v1/runs/41800000-0000-4000-8000-000000000002');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'GET',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        ],
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/reports/v1/runs/41800000-0000-4000-8000-000000000002");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 200

    {
      "id": "41800000-0000-4000-8000-000000000002",
      "revision": 1,
      "questionId": "revenue-by-product",
      "questionRevision": 1,
      "status": "completed",
      "filters": {
        "period": "2026-10",
        "companyId": null,
        "department": null
      },
      "sourceRevision": 1,
      "refreshedAt": "2026-11-22T06:00:00Z",
      "rows": [
        {
          "key": "food",
          "netRevenue": "142063.00",
          "invoiceIds": [
            "FCT-2026-00418",
            "BRR-2026-00127"
          ]
        },
        {
          "key": "household",
          "netRevenue": "60735.50",
          "invoiceIds": [
            "FCT-2026-00436"
          ]
        }
      ],
      "errorCode": null
    }

    On completed, sum netRevenue across the rows and inspect invoiceIds for reconciliation. A weekly split groups by the Monday date of each invoice week. Empty rows with completed mean no matching invoices; failed is a different state and carries errorCode.