APG PayAPG Paydocs

Reporting

Create report query plans

POST/report-query-plans

Explain a question: its SQL, plan and estimated cost. Nothing is run and nothing is stored.

Permissions

Required permission
reports:query

Requires the `query` action on `reports` for the supplied runtime context

Request body

This body is a tagged shape: type is always "RqplanCmdExplain". Send it; more variants can be added, and a caller that switches on it keeps working when they are.

Discriminated by type
type = "RqplanCmdExplain"

Ask a dataset a question. With measures, the answer is one row per combination of the dimensions and time buckets; with none, it is one row per record, in the dataset's row columns.

curl -X POST https://api.tst.au.apgpay.dev/report-query-plans \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "RqplanCmdExplain",
  "question": {
    "type": "RqryCmdRun",
    "reportDatasetId": "string",
    "measures": [
      "string"
    ],
    "dimensions": [
      "string"
    ],
    "time": {
      "type": "RqryTimeSliceAttributes",
      "grain": "string",
      "range": {
        "type": "RqryRangeBetween",
        "from": "2026-08-19",
        "to": "2026-08-19"
      },
      "compare": "PreviousPeriod"
    },
    "filters": [
      {
        "type": "RqryFilterAbove",
        "dimension": "string",
        "value": "string"
      }
    ],
    "sort": [
      {
        "type": "RqrySortDimension",
        "dimension": "string",
        "ascending": true
      }
    ],
    "limit": 25,
    "page": "string",
    "segments": [
      "string"
    ],
    "measureFilters": [
      {
        "type": "RqryMeasureFilterAbove",
        "measure": "string",
        "value": "string"
      }
    ],
    "top": {
      "type": "RqryTopAttributes",
      "dimension": "string",
      "count": 42,
      "measure": "string"
    },
    "narrowTo": {
      "type": "RqryNarrowCustomers",
      "customerIds": [
        "cust_9f2Kd8QpLzXw"
      ]
    },
    "asAt": "2026-08-19T04:21:07Z",
    "pivot": {
      "type": "RqryPivotAttributes",
      "rows": [
        "string"
      ],
      "columns": [
        "string"
      ],
      "subtotals": true
    },
    "timezone": "string"
  }
}'

Responses

The response is a tagged shape: type is always "RqplanCreateRspAttributes". Switch on it; subtypes can be added, and a client that already reads it will not break.

Discriminated by type
type = "RqplanCreateRspAttributes"

The resource that was created.

Example
{
  "type": "RqplanCreateRspAttributes",
  "created": {
    "type": "RqplanAttributes",
    "sql": "string",
    "plan": "string",
    "estimatedCost": 12.5,
    "sources": [
      "string"
    ],
    "timezone": "string",
    "rollup": {
      "type": "RqplanRollupAttributes",
      "relation": "string",
      "grain": "string",
      "timezone": "string"
    },
    "resolvedSql": "string",
    "withoutCube": {
      "type": "RqplanWithoutCubeExplained",
      "sql": "string",
      "resolvedSql": "string",
      "estimatedCost": 12.5,
      "sources": [
        "string"
      ]
    }
  }
}

Error responses