v1
latestOpenAPI 3.1.02026-08-04170116.0 KBData Out
Execute Custom SQL Query
Run custom SQL queries for structured data retrieval. The response returns the query results in a JSON format.
post/orcabase/api/sql
Request body
Example request
{
"shopId": "example.myshopify.com",
"query": "SELECT SUM(spend) AS spend, channel FROM ads_table a WHERE event_date BETWEEN @startDate AND @endDate GROUP BY channel",
"currency": "USD",
"period": {
"startDate": "2025-07-01",
"endDate": "2025-07-31"
}
}Response
The SQL query was executed successfully, and the response contains the query results in a JSON format grouped by channel and event_date.
Example response
{
"success": true,
"message": "The query was executed successfully.",
"data": [
{
"channel": "facebook-ads",
"event_date": "2024-12-01",
"spend": 345,
"clicks": 1250
},
{
"channel": "google-ads",
"event_date": "2024-12-02",
"spend": 412.75,
"clicks": 900
},
{
"channel": "twitter-ads",
"event_date": "2024-12-03",
"spend": 210.25,
"clicks": 640
}
]
}