Data -- Queries

Create Query

Creates a new query under the given project. Supports plain and materialized query types. Optionally accepts a path to place the query in a folder hierarchy. A MATERIALIZED query is materialized immediately on create and its result is queryable as "peaka"."mtquery"."<name>"; an optional schedule keeps it refreshed. To materialize an existing query, send inputQueryRefId with the source query's id instead of inputQuery: a snapshot of the source SQL is taken at create time and stored as the new query's own inputQuery (the source query is left untouched, and later changes to it do not propagate).

post/data/projects/{projectId}/queries

Request

  • Base URL: https://partner.peaka.studio/api/v1
  • URL: https://partner.peaka.studio/api/v1/data/projects/{projectId}/queries
  • Auth: HTTP bearer

Path parameters

projectIdstring required

ID of the Project

Query parameters

checkSchemaExistsboolean

Request body

displayNamestring

The display name of the query.

inputQuerystring nullable

The SQL query. Required unless inputQueryRefId is provided.

queryType'PLAIN' | 'MATERIALIZED'

The type of the query. Defaults to PLAIN.

inputQueryRefIdstring nullable

The id of an existing query to materialize. Valid only if the query type is MATERIALIZED. When set, the materialized query is built from the referenced query's SQL and inputQuery is not required. The reference is resolved when the request is processed: a snapshot of the referenced query's SQL is stored as this query's inputQuery. The reference id itself is not persisted and is not returned in responses; later changes to the referenced query do not propagate. Send the reference again on an update to re-resolve from the source.

pathstring nullable

The folder path to place this query in. Intermediate folders are created automatically. If omitted, the query is placed at the root level.

Example request

{
  "displayName": "sampleQuery",
  "schedule": {
    "type": "cron",
    "cronExpression": "0 0 * * *",
    "timezone": "UTC"
  },
  "inputQueryRefId": "709922802836177297",
  "path": "/reports/monthly"
}

Response

Query created

idstring

The ID of the query.

displayNamestring

The display name of the query.

namestring

The name of the query used in SQL, e.g. SELECT * FROM "peaka"."query"."<name>". For a MATERIALIZED query the materialized result is queryable as "peaka"."mtquery"."<name>".

inputQuerystring

The SQL query. For a materialized query created from an existing query (via inputQueryRefId), this holds the snapshot of the source query's SQL resolved when the query was created or last updated with the reference.

queryType'PLAIN' | 'MATERIALIZED'

The type of the query.

pathstring nullable

The folder path of the query (e.g. "/analytics/dashboards"). Null if not in any folder.

folderIdstring nullable

The ID of the folder containing this query. Null if not in any folder.

Example response

{
  "schedule": {
    "type": "cron",
    "cronExpression": "0 0 * * *",
    "timezone": "UTC"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.