---
title: "Update Environment"
method: PUT
path: "/agents/{namespace_slug}/{agent_name}/environments/{env_name}"
tags: ["Environments"]
---

# Update Environment

`PUT /agents/{namespace_slug}/{agent_name}/environments/{env_name}`

Update an existing environment.

    All fields are optional - only provided fields will be updated.

    **Production Environment Constraints:**
    - branch_rules must be exactly one literal string (no wildcards)
    - is_prod cannot be changed via API

## Path parameters

- `namespace_slug` string, required
- `agent_name` string, required
- `env_name` string, required

## Request body

- UpdateEnvRequest — Request to update an environment (partial update).
  - `branch_rules` string[], nullable — Branch patterns for matching

## Response `200`

Successful Response

- EnvResponse — Full environment details.
  - `agent_id` string, required — Parent agent ID
  - `branch_rules` string[], required — Branch patterns for matching (e.g., ['main'], ['feature/*'])
  - `created_at` string, date-time, nullable — Creation timestamp
  - `id` string, required — Unique identifier
  - `is_prod` boolean, required — Whether this is the production environment (protected)
  - `name` string, required — Environment name (e.g., 'production', 'staging')
  - `updated_at` string, date-time, nullable — Last update timestamp

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/terminaluse/apis/sb0-api.md) · [All operations](https://skmtc.dev/terminaluse/apis/sb0-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/terminaluse/sb0-api/revisions/f24a474dc415/schema)
