---
title: "Set prompt version environment"
method: PATCH
path: "/v1/private/prompts/versions/{versionId}/environments"
tags: ["Prompts"]
---

# Set prompt version environment

`PATCH /v1/private/prompts/versions/{versionId}/environments`

Set or clear the environment owned by a prompt version.
Setting a non-null environment moves ownership atomically: any previous owner of that
environment for the same prompt has its environment cleared in the same transaction.
Setting null clears the environment from the version.
The environment must already exist in the workspace registry; unknown names return 404.

## Path parameters

- `versionId` string, uuid, required

## Request body

- PromptVersionEnvironmentUpdate — Replace the full set of environments assigned to a prompt version. The provided set becomes the new complete set of environments for this version. - Non-empty set: assigns each environment to this version; if another version of the same prompt currently owns any of those environments, ownership is moved atomically. - Empty set: clears all environments from this version. All environments must already exist in the workspace registry; unknown names return 404.
  - `environments` string[], required

## Response `204`

No Content

## Other responses

- `400` — Bad Request
- `404` — Not Found

---

[API](https://skmtc.net/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.net/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/versions/4ed2fbc97cc3/schema)
