---
title: "CreateTask"
method: POST
path: "/gitpod.v1.EnvironmentAutomationService/CreateTask"
tags: ["gitpod.v1.EnvironmentAutomationService"]
---

# CreateTask

`POST /gitpod.v1.EnvironmentAutomationService/CreateTask`

Creates a new automation task.

 Use this method to:
 - Define one-off or scheduled tasks
 - Set up build or test automation
 - Configure task dependencies
 - Specify execution environments

 ### Examples

 - Create basic task:

   Creates a simple build task.

   ```yaml
   environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
   metadata:
     reference: "build"
     name: "Build Project"
     description: "Builds the project artifacts"
     triggeredBy:
       - postEnvironmentStart: true
   spec:
     command: "npm run build"
   ```

 - Create task with dependencies:

   Creates a task that depends on other services.

   ```yaml
   environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
   metadata:
     reference: "test"
     name: "Run Tests"
     description: "Runs the test suite"
   spec:
     command: "npm test"
   dependsOn: ["d2c94c27-3b76-4a42-b88c-95a85e392c68"]
   ```

## Request body

- GitpodV1CreateTaskRequest
  - `dependsOn` string[]
  - `environmentId` string, uuid
  - `metadata` GitpodV1TaskMetadata — unresolved $ref
  - `spec` GitpodV1TaskSpec — unresolved $ref

## Response `200`

Success

- GitpodV1CreateTaskResponse
  - `task` GitpodV1Task, required
    - `dependsOn` string[] — dependencies specifies the IDs of the automations this task depends on.
    - `environmentId` string, uuid
    - `id` string, uuid, required
    - `metadata` GitpodV1TaskMetadata — unresolved $ref
    - `spec` GitpodV1TaskSpec — unresolved $ref

## Other responses

- `default` — Error

## Changes

- **2026-01-21** `2423c089f280` — 2 breaking, 4 info
  - removed `subschema #1, subschema #2, subschema #3, subschema #4, subschema #5` from the `metadata/triggeredBy/items/` request property `oneOf` list
  - added `subschema #1, subschema #2, subschema #3, subschema #4, subschema #5, subschema #6` to the `task/metadata/triggeredBy/items/` response property `oneOf` list for the response status `200`
  - added the new optional request property `metadata/triggeredBy/items/beforeSnapshot`
  - added `subschema #1, subschema #2, subschema #3, subschema #4, subschema #5, subschema #6` to the `metadata/triggeredBy/items/` request property `oneOf` list
  - …2 more
- **2025-12-15** `d62ef4b9187c` — 5 breaking, 1 warning, 13 info
  - removed `subschema #1` from the `spec/runsOn` request property `oneOf` list
  - removed `subschema #1, subschema #2, subschema #3` from the `metadata/triggeredBy/items/` request property `oneOf` list
  - the `metadata/creator/id` request property type/format changed from `string`/`` to `string`/`uuid`
  - added `subschema #1, subschema #2` to the `task/spec/runsOn` response property `oneOf` list for the response status `200`
  - …15 more
- **2025-06-10** `ca9a49ac7fbb` — 1 warning, 1 info
  - added the new `PRINCIPAL_RUNNER_MANAGER` enum value to the `task/metadata/creator/principal` response property for the response status `200`
  - added the new `PRINCIPAL_RUNNER_MANAGER` enum value to the request property `metadata/creator/principal`
- …earlier changes not shown

[Full history](https://skmtc.dev/gitpod-io/apis/gitpod-v1/changes/gitpod.v1.EnvironmentAutomationService/CreateTask/post.md)

---

[API](https://skmtc.dev/gitpod-io/apis/gitpod-v1.md) · [All operations](https://skmtc.dev/gitpod-io/apis/gitpod-v1/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/gitpod-io/gitpod-v1/revisions/2423c089f280/schema)
