> ## 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.

# Update Service

> Updates an automation service configuration.

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

Updates an automation service configuration.

Use this method to:

* Modify service commands
* Update triggers
* Change runtime settings
* Adjust dependencies

### Examples

* Update commands:

  Changes service start and ready commands.

  ```yaml theme={null}
  id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  spec:
    commands:
      start: "npm run start:dev"
      ready: "curl -s http://localhost:8080"
  ```

* Update triggers:

  Modifies when the service starts.

  ```yaml theme={null}
  id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  metadata:
    triggeredBy:
      trigger:
        - postDevcontainerStart: true
        - manual: true
  ```

## Endpoint

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

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/UpdateService" \
    --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.UpdateServiceRequest(
      id="<id>",
  )
  response = ona.services.environment_automation.update_service(request)
  print(response)
  ```

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

  async function main() {
    const ona = createClientFromEnv();
    const request = create(UpdateServiceRequestSchema, {
      id: "<id>",
    });
    const response = await ona.services.environmentAutomation.updateService(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.UpdateServiceRequest{
  		Id: "<id>",
  	})
  	response, err := ona.Services.EnvironmentAutomation.UpdateService(context.Background(), request)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(response.Msg)
  }
  ```

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

## Request

`gitpod.v1.UpdateServiceRequest`

| Field      | Type                                                                       | Required | Description                                                                                                                                                                                                                  |
| ---------- | -------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`       | string                                                                     | No       | Constraints: `string.uuid=true`.                                                                                                                                                                                             |
| `metadata` | [ServiceMetadata](#type-gitpod-v1-update-service-request-service-metadata) | No       |                                                                                                                                                                                                                              |
| `spec`     | [ServiceSpec](#type-gitpod-v1-update-service-request-service-spec)         | No       | Changing the spec of a service is a complex operation. The spec of a service can only be updated if the service is in a stopped state. If the service is running, it must be stopped first.                                  |
| `status`   | [ServiceStatus](#type-gitpod-v1-update-service-request-service-status)     | No       | Service status updates are only expected from the executing environment. As a client of this API you are not expected to provide this field. Updating this field requires the `environmentservice:update_status` permission. |

## Response

`gitpod.v1.UpdateServiceResponse`

This message has no fields.

## Related types

<a id="type-gitpod-v1-environment-variable-item" />

<Accordion title="EnvironmentVariableItem">
  EnvironmentVariableItem represents an environment variable that can be set
  either from a literal value or from a secret reference.

  `gitpod.v1.EnvironmentVariableItem`

  | Field       | Type                      | Required | Description                                                             |
  | ----------- | ------------------------- | -------- | ----------------------------------------------------------------------- |
  | `name`      | string                    | No       | name is the environment variable name. Constraints: `string.min_len=1`. |
  | `value`     | string                    | No       | value is a literal string value.                                        |
  | `valueFrom` | EnvironmentVariableSource | No       | value\_from specifies a source for the value.                           |
</Accordion>

<a id="type-gitpod-v1-runs-on" />

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

  | Field     | Type    | Required | Description |
  | --------- | ------- | -------- | ----------- |
  | `docker`  | Docker  | No       |             |
  | `machine` | Machine | No       |             |
</Accordion>

<a id="type-gitpod-v1-update-service-request-automation-trigger-update" />

<Accordion title="AutomationTriggerUpdate">
  `gitpod.v1.UpdateServiceRequest.AutomationTriggerUpdate`

  | Field     | Type                       | Required | Description |
  | --------- | -------------------------- | -------- | ----------- |
  | `trigger` | array of AutomationTrigger | No       |             |
</Accordion>

<a id="type-gitpod-v1-update-service-request-service-metadata" />

<Accordion title="ServiceMetadata">
  `gitpod.v1.UpdateServiceRequest.ServiceMetadata`

  | Field         | Type                                                                                        | Required | Description                      |
  | ------------- | ------------------------------------------------------------------------------------------- | -------- | -------------------------------- |
  | `name`        | string                                                                                      | No       | Constraints: `string.min_len=1`. |
  | `description` | string                                                                                      | No       |                                  |
  | `triggeredBy` | [AutomationTriggerUpdate](#type-gitpod-v1-update-service-request-automation-trigger-update) | No       |                                  |
  | `role`        | [ServiceRole](#enum-gitpod-v1-service-role)                                                 | No       |                                  |
</Accordion>

<a id="type-gitpod-v1-update-service-request-service-spec" />

<Accordion title="ServiceSpec">
  `gitpod.v1.UpdateServiceRequest.ServiceSpec`

  | Field              | Type                                                                          | Required | Description                                |
  | ------------------ | ----------------------------------------------------------------------------- | -------- | ------------------------------------------ |
  | `commands`         | [Commands](#type-gitpod-v1-update-service-request-service-spec-commands)      | No       |                                            |
  | `runsOn`           | [RunsOn](#type-gitpod-v1-runs-on)                                             | No       |                                            |
  | `env`              | array of [EnvironmentVariableItem](#type-gitpod-v1-environment-variable-item) | No       |                                            |
  | `readinessTimeout` | duration string                                                               | No       | Constraints: `duration.lte.seconds=86400`. |
</Accordion>

<a id="type-gitpod-v1-update-service-request-service-spec-commands" />

<Accordion title="Commands">
  `gitpod.v1.UpdateServiceRequest.ServiceSpec.Commands`

  | Field   | Type   | Required | Description |
  | ------- | ------ | -------- | ----------- |
  | `start` | string | No       |             |
  | `ready` | string | No       |             |
  | `stop`  | string | No       |             |
</Accordion>

<a id="type-gitpod-v1-update-service-request-service-status" />

<Accordion title="ServiceStatus">
  `gitpod.v1.UpdateServiceRequest.ServiceStatus`

  | Field            | Type                                          | Required | Description                                            |
  | ---------------- | --------------------------------------------- | -------- | ------------------------------------------------------ |
  | `phase`          | [ServicePhase](#enum-gitpod-v1-service-phase) | No       | Constraints: `enum.defined_only=true`.                 |
  | `failureMessage` | string                                        | No       |                                                        |
  | `logUrl`         | string                                        | No       |                                                        |
  | `session`        | string                                        | No       |                                                        |
  | `output`         | map of string to string                       | No       | setting an output field to empty string will unset it. |
</Accordion>

<a id="enum-gitpod-v1-service-phase" />

<Accordion title="ServicePhase">
  | Value                       | Number | Description |
  | --------------------------- | -----: | ----------- |
  | `SERVICE_PHASE_UNSPECIFIED` |      0 |             |
  | `SERVICE_PHASE_STARTING`    |      1 |             |
  | `SERVICE_PHASE_RUNNING`     |      2 |             |
  | `SERVICE_PHASE_STOPPING`    |      3 |             |
  | `SERVICE_PHASE_STOPPED`     |      4 |             |
  | `SERVICE_PHASE_FAILED`      |      5 |             |
  | `SERVICE_PHASE_DELETED`     |      6 |             |
</Accordion>

<a id="enum-gitpod-v1-service-role" />

<Accordion title="ServiceRole">
  | Value                         | Number | Description |
  | ----------------------------- | -----: | ----------- |
  | `SERVICE_ROLE_UNSPECIFIED`    |      0 |             |
  | `SERVICE_ROLE_DEFAULT`        |      1 |             |
  | `SERVICE_ROLE_EDITOR`         |      2 |             |
  | `SERVICE_ROLE_AI_AGENT`       |      3 |             |
  | `SERVICE_ROLE_SECURITY_AGENT` |      4 |             |
</Accordion>
