Prerequisites
- An API key — either a Partner API Key or a Project API Key created for the project. See Authentication for the difference.
- Your Project ID.
The examples below use the US zone base URL
https://partner.peaka.studio/api/v1. If your organization is in the EU zone, use https://eu.partner.peaka.studio/api/v1 instead. See Servers for details.How materialization works
Before calling the API, it helps to know five things:- A materialized query is a separate query object with
queryType: "MATERIALIZED". When you materialize an existing query, the original query is left untouched — you get a new query alongside it. - The first materialization runs immediately. Creating a materialized query executes it right away and stores the result; you do not need to trigger the first run yourself.
- The result lives in the
mtqueryschema. A materialized query namedsamplequeryis queryable as"peaka"."mtquery"."samplequery". - A schedule keeps it fresh. Attach a
scheduleobject to refresh at regular intervals or on a cron expression. Without a schedule, the data stays as of the last (manual) refresh. - Materializing by reference takes a snapshot. When you pass
inputQueryRefId, Peaka resolves the referenced query’s SQL at that moment and stores it as the new query’s owninputQuery. Later edits to the source query do not propagate automatically — see Keep it in sync with the source.
Materialize an existing query
This is the API equivalent of the Advanced → Materialize flow in Peaka Studio. Call Create Query withqueryType: "MATERIALIZED" and the id of the source query in inputQueryRefId. You do not need to send inputQuery — the SQL is taken from the source query.
The example below materializes an existing query and refreshes it twice a day:
inputQuery holds the snapshot of the source query’s SQL that was resolved at create time, and that inputQueryRefId is not part of the response — the reference is consumed, not stored:
inputQuery with the SQL instead of inputQueryRefId:
Convert a query in place
If you want to turn an existingPLAIN query into a materialized one — rather than creating a new query next to it — call Update Query on the query itself with queryType: "MATERIALIZED":
cURL
PLAIN query anymore.
Schedule refreshes
Theschedule object supports three types:
type | Fields | Behavior |
|---|---|---|
interval | repeatDuration (ISO-8601 duration) | Refreshes at a fixed interval, e.g. every 6 hours. |
cron | cronExpression, optional timezone | Refreshes on a cron schedule, evaluated in the given timezone. |
none | — | No automatic refresh. Equivalent to omitting schedule. |
repeatDuration is an ISO-8601 duration. Common values:
| Value | Meaning |
|---|---|
PT1H | Every hour |
PT6H | Every 6 hours |
PT12H | Twice a day |
P1D | Once a day |
cronExpression is a UNIX cron expression (minute hour day-of-month month day-of-week), and timezone is an IANA timezone name (defaults to UTC):
schedule object (or { "type": "none" } to stop automatic refreshes).
Query the materialized data
The materialized result is exposed in themtquery schema of the peaka catalog, under the query’s name (the normalized form of displayName returned in the response):
"peaka"."query"."<name>" addresses a query’s logical definition, while "peaka"."mtquery"."<name>" addresses the stored, materialized result.Keep it in sync with the source
Materializing by reference takes a snapshot of the source query’s SQL. Scheduled and manual refreshes re-run that snapshot against live data — so the data stays fresh — but if you later edit the SQL of the source query, the materialized query keeps computing the old SQL. To re-sync the materialized query with its source, send the reference again with Update Query:cURL
Monitor, refresh, and cancel
Materialized queries have dedicated endpoints for operating on refreshes:- List Materialized Query Statuses — refresh status, schedule, and next execution time for all materialized queries in a project.
- Read Materialized Query Status — the same information for a single query.
- Refresh Materialized Query — trigger an immediate refresh, regardless of the schedule.
- Cancel Materialized Query Refresh — cancel an in-progress refresh.
cURL