Execute Harbor Saved Query

Beta
Submits the current published Harbor saved query for asynchronous reader-only execution. Use a Harbor-bound scoped credential with query access to the Harbor's backing Connection. Administrator credentials cannot submit executions here. Saved queries require a Polytomic-managed Harbor. Polytomic selects the current published revision while processing your request. The response identifies that exact immutable revision. Selection happens before Polytomic accepts the execution. Drafts, unpublished queries, and archived queries are unavailable for selection. You cannot select a historical revision or supply SQL through this endpoint. > ⚠️ Concurrent publication changes > > Publishing, unpublishing, or archiving a saved query after selection does not > change the selected revision. An in-flight request may still be accepted and > execute that revision. Unpublishing or archiving does not cancel in-flight > requests or queued executions. Query access is checked again before execution > and result retrieval. Parameter values are bound separately from SQL. Omitted parameters use the published `default_value`, never draft validation values. An omitted optional parameter without a default binds SQL `NULL`. Required parameters allow omission when a default exists, but reject explicit `null` even with a default. Missing required values without defaults, explicit `null` for required parameters, unknown parameter names, and invalid scalar types return `422 Unprocessable Entity` without accepting an execution. Execution requires reader credentials and never falls back to writer credentials. For report windows, define parameters with `required: true` and a `default_value`, such as `7` for a `days` parameter. This allows omission while preventing explicit `null` from turning a time filter into a SQL `NULL` comparison. To archive a saved query through REST, use [`DELETE /api/harbors/{harbor_id}/saved-queries/{saved_query_id}`](../../../../../../api-reference/harbors/delete-saved-query). Unpublish is available only through the GraphQL `unpublishHarborSavedQuery` mutation, not a REST endpoint. ## Results The response returns a task ID with status `created`, not result rows. Poll [`GET /api/queries/{id}`](../../../../../../api-reference/query-runner/get-query) using a credential from the same Harbor profile. Query access is checked again before execution and result retrieval. Stop polling at `done`, `failed`, or `unknown`; `unknown` means execution started but no durable terminal result is available. Results and detailed failure information expire after 24 hours. Use the `expires` field and follow `links.next` to retrieve additional result pages. ## Harbor Activity Send a new nonzero UUID in `X-Polytomic-Activity-Request-ID`. Missing or invalid IDs return `400 Bad Request`. Reusing a consumed ID returns `409 Conflict` and does not create another execution. You may omit `X-Polytomic-Harbor-Session` for direct REST requests. If supplied, the session must be active and bound to your credential and Harbor. Polytomic records `query.submitted` atomically with acceptance. The event identifies the saved query, immutable revision, published version, and bounded name snapshot. SQL, parameter values and defaults, column names, and result rows remain outside Activity metadata. If Activity persistence is unavailable, the request returns `503 Service Unavailable` without accepting an execution. `query.started` records provider invocation. `query.succeeded` means results are available for authorized retrieval, not that you have consumed them.

Authentication

AuthorizationBearer
Bearer user API key
OR
AuthorizationBasic

Basic organization-scoped API key

Path parameters

harbor_idstringRequiredformat: "uuid"
Unique identifier of the Harbor.
saved_query_idstringRequiredformat: "uuid"
Unique stable identifier of the saved query.

Headers

X-Polytomic-VersionstringOptional
X-Polytomic-Harbor-SessionstringOptional
X-Polytomic-Activity-Request-IDstringOptional

Request

This endpoint expects an object.
parametersmap from strings to anyOptional

Named JSON scalar overrides for declared parameters. Omission uses published default_value, or SQL NULL for optional parameters without a default. Required parameters reject explicit null even with a default; without a default they also reject omission. Unknown names and invalid types are rejected.

Response

OK
dataobjectOptional

Errors

400
Bad Request Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
422
Unprocessable Entity Error
500
Internal Server Error
503
Service Unavailable Error