Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.maia.ai/llms.txt

Use this file to discover all available pages before exploring further.

In this guide, you will learn how to execute a published pipeline, check its status, and terminate a running pipeline using the Maia API. Additionally, you’ll discover how to obtain the necessary Project ID and Environment Name for pipeline execution. To execute and manage a pipeline using the API, the pipeline must be published. Unpublished pipelines cannot be executed or managed using the API. To publish a pipeline, perform the Push local changes Git action in , and select the Publish checkbox.

Prerequisites

Before you begin, make sure you have the following:

Step 1: Get the Project ID

Retrieve the list of projects using the Project API. Base URL: GET /v1/projects Example response:
{
  "page": 0,
  "results": [
    {
      "description": "project-1",
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "name": "Test-project"
    }
  ],
  "size": 0,
  "total": 0
}
Make a note of the projects and their respective IDs, as you’ll need these IDs when executing pipelines.

Step 2: Get the environment details

Once you have the project ID, use the Environment API to obtain details about the environment in which the project is running. Base URL: GET /v1/projects/{projectId}/environments Example Response:
{
  "page": 0,
  "results": [
    {
      "defaultAgentId": "3fa85f64-5717-4562-b3fc-2c963f66afaf",
      "defaultAgentName": "Dev Agent",
      "name": "Environment-1"
    }
  ],
  "size": 0,
  "total": 0
}
This includes the environment name (name), as well as the associated ‘s name (defaultAgentName) and ID (defaultAgentID).

Step 3: Get the list of published pipelines

Retrieve the list of published pipelines using the Pipeline API. Base URL: GET /v1/projects/{projectId}/published-pipelines Example response:
{
  "page": 0,
  "results": [
    {
      "name": "My pipeline",
      "publishedTime": "2023-11-24T10:39:02.182Z"
    }
  ],
  "size": 0,
  "total": 0
}
Review the available pipelines before execution.

Step 4: Execute published pipeline

To execute a published pipeline, send a POST request with the project ID, environment name, and pipeline name. Base URL: POST /v1/projects/{projectId}/pipeline-executions Example request body:
{
  "pipelineName": "Pipeline 1",
  "environmentName": "Dev Environment"
}
Upon successful execution, you’ll receive a pipeline execution ID needed for subsequent steps. Example response:
{
  "pipelineExecutionId": "1398aa31-af57-4a6a-9752-27c2e8556c3f"
}

Execute a published pipeline using a specific artifact version

You can optionally specify a versionName in the request body to execute the pipeline in a specific published artifact. If you don’t include versionName, the execution defaults to the latest artifact published to the environment. Example request body with versionName:
{
  "pipelineName": "Dev Pipeline",
  "environmentName": "Dev Environment",
  "versionName": "1.1.1"
}

Execute a published pipeline while preventing concurrent executions

The API supports an optional executionTag parameter, which helps prevent concurrent executions of the same API call. If the executionTag parameter is supplied, the pipeline will run with this tag. However, if another request is made with the same tag while the previous execution is still running, the request will fail with a 409 conflict response. This feature is particularly useful for external schedulers to prevent duplicate executions. Example request body with executionTag:
{
  "pipelineName": "Pipeline 1",
  "environmentName": "Dev Environment",
  "executionTag": "nightly-run"
}
Example 409 conflict response if a duplicate execution is attempted:
{
  "error": "A pipeline execution with this tag is already running.",
  "status": 409
}

Step 5: Check pipeline status

Optionally, check the pipeline status using the Pipeline status API with the project ID and pipeline execution ID. Base URL: GET /v1/projects/{projectId}/pipeline-executions/{pipelineExecutionId} Example response:
{
  "result": {
    "finishedAt": "2023-11-24T10:47:46.944Z",
    "message": "\"Rewrite Table\": Success",
    "startedAt": "2023-11-24T10:47:46.944Z",
    "status": "RUNNING"
  }
}
Possible values for status are RUNNING, SUCCESS, FAILED, CANCELLING, CANCELLED, SKIPPED, and FORBIDDEN. A pipeline execution has a FORBIDDEN status if the restricted ‘s allow list no longer permits this project/environment combination. For more information, read Restrict a Maia runner. You can also list pipeline executions and filter by status using the List pipeline executions endpoint, including status=FORBIDDEN to list only forbidden runs: Base URL: GET /v1/pipeline-executions?status=FORBIDDEN

Step 6: Terminate pipeline

To cancel a running pipeline, use the PATCH endpoint. Provide a request body with the force update and status details. Base URL: PATCH /v1/projects/{projectId}/pipeline-executions/{pipelineExecutionId} Example request body:

{
  "forceUpdate": true,
  "status": "My pipeline"
}
Upon successful termination, you’ll receive a response along with the pipeline execution ID.
{
  "pipelineExecutionId": "1398aa31-af57-4a6a-9752-27c2e8556c3f"
}