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

# Get Task

> Gets details about a specific automation task.

`Unary` · [`Environment Automations`](/docs/api-reference/generated/environment-automation/overview)

Gets details about a specific automation task.

Use this method to:

* Check task configuration
* View task dependencies
* Monitor task status

### Examples

* Get task details:

  Retrieves information about a specific task.

  ```yaml theme={null}
  id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  ```

## Endpoint

```text theme={null}
POST /api/gitpod.v1.EnvironmentAutomationService/GetTask
```

Send a Bearer token as described in [Authentication](/docs/api-reference#authenticate-requests). If your organization uses a custom management-plane domain, replace `https://app.ona.com` with that domain.

## Request example

<CodeGroup>
  ```bash cURL theme={null}
  export ONA_HOST=https://app.ona.com
  export ONA_API_KEY=<your-token>

  curl --request POST \
    --url "$ONA_HOST/api/gitpod.v1.EnvironmentAutomationService/GetTask" \
    --header "Authorization: Bearer $ONA_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
    "id": "<id>"
  }'
  ```

  ```python Python theme={null}
  import gitpod.v1.environment_automation_pb2 as environment_automation_pb2
  from ona_sdk import create_client_from_env

  ona = create_client_from_env()
  request = environment_automation_pb2.GetTaskRequest(
      id="<id>",
  )
  response = ona.services.environment_automation.get_task(request)
  print(response)
  ```

  ```typescript TypeScript theme={null}
  import { create } from "@bufbuild/protobuf";
  import { createClientFromEnv } from "@gitpod/sdk";
  import { GetTaskRequestSchema } from "@gitpod/sdk/gitpod/v1/environment_automation_pb";

  async function main() {
    const ona = createClientFromEnv();
    const request = create(GetTaskRequestSchema, {
      id: "<id>",
    });
    const response = await ona.services.environmentAutomation.getTask(request);
    console.log(response);
  }

  main().catch(console.error);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	"connectrpc.com/connect"
  	"github.com/gitpod-io/gitpod-sdk-go/sdk"
  	gitpodpb "github.com/gitpod-io/gitpod-sdk-go/v1"
  )

  func main() {
  	ona, err := sdk.NewFromEnv()
  	if err != nil {
  		log.Fatal(err)
  	}

  	request := connect.NewRequest(&gitpodpb.GetTaskRequest{
  		Id: "<id>",
  	})
  	response, err := ona.Services.EnvironmentAutomation.GetTask(context.Background(), request)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(response.Msg)
  }
  ```

  ```json Request body theme={null}
  {
    "id": "<id>"
  }
  ```
</CodeGroup>

## Request

`gitpod.v1.GetTaskRequest`

| Field | Type   | Required | Description                      |
| ----- | ------ | -------- | -------------------------------- |
| `id`  | string | No       | Constraints: `string.uuid=true`. |

## Response

`gitpod.v1.GetTaskResponse`

| Field  | Type                         | Required | Description                   |
| ------ | ---------------------------- | -------- | ----------------------------- |
| `task` | [Task](#type-gitpod-v1-task) | Yes      | Constraints: `required=true`. |

## Related types

<a id="type-gitpod-v1-task" />

<Accordion title="Task">
  `gitpod.v1.Task`

  | Field           | Type                                          | Required | Description                                                                                                             |
  | --------------- | --------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
  | `id`            | string                                        | No       | Constraints: `string.uuid=true`.                                                                                        |
  | `environmentId` | string                                        | No       | Constraints: `string.uuid=true`.                                                                                        |
  | `metadata`      | [TaskMetadata](#type-gitpod-v1-task-metadata) | No       |                                                                                                                         |
  | `spec`          | [TaskSpec](#type-gitpod-v1-task-spec)         | No       |                                                                                                                         |
  | `dependsOn`     | array of string                               | No       | dependencies specifies the IDs of the automations this task depends on. Constraints: `repeated.items.string.uuid=true`. |
</Accordion>

<a id="type-gitpod-v1-task-metadata" />

<Accordion title="TaskMetadata">
  `gitpod.v1.TaskMetadata`

  | Field         | Type                       | Required | Description                                                                                                                                                                                                                                                                 |
  | ------------- | -------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `reference`   | string                     | No       | reference is a user-facing identifier for the task which must be unique on the environment. It is used to express dependencies between tasks, and to identify the task in user interactions (e.g. the CLI). Constraints: `string.pattern=^[a-zA-Z0-9_-]&#123;1,128&#125;$`. |
  | `name`        | string                     | No       | name is a user-facing name for the task. Unlike the reference, this field is not unique, and not referenced by the system. This is a short descriptive name for the task. Constraints: `string.min_len=1`.                                                                  |
  | `description` | string                     | No       | description is a user-facing description for the task. It can be used to provide context and documentation for the task.                                                                                                                                                    |
  | `createdAt`   | RFC 3339 timestamp         | No       | created\_at is the time the task was created.                                                                                                                                                                                                                               |
  | `creator`     | Subject                    | No       | creator describes the principal who created the task.                                                                                                                                                                                                                       |
  | `triggeredBy` | array of AutomationTrigger | No       | triggered\_by is a list of trigger that start the task.                                                                                                                                                                                                                     |
</Accordion>

<a id="type-gitpod-v1-task-spec" />

<Accordion title="TaskSpec">
  `gitpod.v1.TaskSpec`

  | Field                     | Type                             | Required | Description                                                                                                                                                                                                                                                                                                                                                                                              |
  | ------------------------- | -------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `command`                 | string                           | No       | command contains the command the task should execute                                                                                                                                                                                                                                                                                                                                                     |
  | `runsOn`                  | RunsOn                           | No       | runs\_on specifies the environment the task should run on.                                                                                                                                                                                                                                                                                                                                               |
  | `env`                     | array of EnvironmentVariableItem | No       | env specifies environment variables for the task.                                                                                                                                                                                                                                                                                                                                                        |
  | `prebuildRequiresSuccess` | boolean                          | No       | prebuild\_requires\_success controls whether a non-successful outcome of this task should fail the prebuild. When true and the task is triggered by a prebuild or before\_snapshot trigger, any terminal phase other than SUCCEEDED (i.e. FAILED or STOPPED) will cause the prebuild to fail instead of recording a warning. Defaults to false (existing behavior: task failures produce warnings only). |
</Accordion>
