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.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.
Prerequisites
Before you begin, make sure you have the following:- A account.
- Valid API credentials for API access.
- An access token with the required privileges (refer to Authentication and Get the access token).
Step 1: Get the Project ID
Retrieve the list of projects using the Project API. Base URL:GET /v1/projects
Example response:
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:
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:
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:
Execute a published pipeline using a specific artifact version
You can optionally specify aversionName 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:
Execute a published pipeline while preventing concurrent executions
The API supports an optionalexecutionTag 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:
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:
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:
