> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cube.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Orchestration API

> Trigger pre-aggregation refreshes from Airflow, Dagster, or Prefect instead of relying on Cube's scheduled refresh.

Orchestration API enables Cube to work with data orchestration tools and let
them *push* changes from upstream data sources to Cube, as opposed to letting
Cube *pull* changes from upstream data sources via the
[`scheduledRefresh`][ref-scheduled-refresh] configration option of
pre-aggregations.

```mermaid actions={false} theme={"dark"}
flowchart TB
  accTitle: Cube in the data stack
  accDescr: Data sources feed data replication, which loads the data warehouse. The warehouse feeds the semantic layer, Cube, which serves data applications. Data orchestration follows data replication, runs data transformation, which loads the warehouse, and pushes changes to the semantic layer.
  S["<b>Data sources</b>"]:::tile
  R["<b>Data replication</b>"]:::tile
  W["<b>Data warehouse</b>"]:::tile
  L["<img class=on-light src='https://static.cube.dev/icons/cube-icon-light.svg' /><img class=on-dark src='https://static.cube.dev/icons/cube-icon-dark.svg' /><b>Semantic layer</b><br/>Cube"]:::hub
  A["<b>Data applications</b>"]:::tile
  O["<b>Data orchestration</b>"]:::tile
  T["<b>Data transformation</b>"]:::tile
  S --> R --> W --> L --> A
  R --> O
  O --> T --> W
  O --> L
```

Orchestration API can be used to implement both [embedded analytics][cube-ea]
and internal or self-serve [business intelligence][cube-issbi] use cases. When
implementing [real-time analytics][cube-rta], consider pulling data from
upstream data sources with [lambda pre-aggregations][ref-lambda-pre-aggs].

Under the hood, the Orchestration API is exposed via the
[`/v1/pre-aggregations/jobs`][ref-ref-jobs-endpoint] endpoint of the
[REST (JSON) API][ref-rest-api].

## Supported tools

Orchestration API has integration packages to work with popular data
orchestration tools. Check the following guides to get tool-specific
instructions:

> [card] [Apache Airflow](https://docs.cube.dev/reference/orchestration-api/airflow.md)
>
> Trigger pre-aggregation builds from Apache Airflow DAGs.

> [card] [Dagster](https://docs.cube.dev/reference/orchestration-api/dagster.md)
>
> Trigger pre-aggregation builds from Dagster assets and jobs.

> [card] [Prefect](https://docs.cube.dev/reference/orchestration-api/prefect.md)
>
> Trigger pre-aggregation builds from Prefect flows.

## Configuration

Orchestration API is enabled by default but inaccessible due to the default [API
scopes][ref-api-scopes] configuration. To allow access to the Orchestration API,
enable the `jobs` scope, e.g., by setting the [`CUBEJS_DEFAULT_API_SCOPES`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_default_api_scopes)
environment variable to `meta,data,graphql,jobs`.

## Building pre-aggregations

Orchestration API allows to trigger pre-aggregation builds programmatically. It
can be useful for data orchestration tools to push changes from upstream data
sources to Cube or for any third parties to invalidate and rebuild
pre-aggregations on demand.

You can trigger pre-aggregation builds and check build statuses using the
[`/v1/pre-aggregations/jobs`][ref-ref-jobs-endpoint] endpoint. It is possible to
rebuild all pre-aggregations or specify the ones to be rebuilt:

* Particular pre-aggregations.
* Pre-aggregations that reference particular cubes.
* Pre-aggregations that reference cubes from particular data sources.
* For [partitioned pre-aggregations][ref-pre-agg-partitions], only partitions that contain
  data from a particular date range.

[ref-scheduled-refresh]: https://docs.cube.dev/reference/data-modeling/pre-aggregations.md#scheduled_refresh

[cube-ea]: https://cube.dev/use-cases/embedded-analytics

[cube-issbi]: https://cube.dev/use-cases/semantic-layer

[cube-rta]: https://cube.dev/use-cases/real-time-analytics

[ref-lambda-pre-aggs]: https://docs.cube.dev/docs/pre-aggregations/lambda-pre-aggregations.md

[ref-rest-api]: https://docs.cube.dev/reference/core-data-apis/rest-api

[ref-api-scopes]: https://docs.cube.dev/reference/core-data-apis/rest-api#configuration-api-scopes

[ref-ref-jobs-endpoint]: https://docs.cube.dev/reference/core-data-apis/rest-api/reference.md#base_path/v1/pre-aggregations/jobs

[ref-pre-agg-partitions]: https://docs.cube.dev/docs/pre-aggregations/using-pre-aggregations.md#partitioning


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.