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

Base URL: `https://www.comet.com/opik/api`

Tags: `Prompts`

## Authorization

This operation requires no authorization.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `versionId` | `string` (uuid) | Yes | — |

## Request body

Optional. Media type: `application/json`

### Example request body

```json
{
  "environments": [
    "string"
  ]
}
```

## Responses

| Status | Description | Media type |
| --- | --- | --- |
| `204` | No Content | — |
| `400` | Bad Request | `application/json` |
| `404` | Not Found | `application/json` |

### Example response: 400 — Bad Request

```json
{
  "code": 0,
  "details": "string",
  "message": "string"
}
```

### Example response: 404 — Not Found

```json
{
  "code": 0,
  "details": "string",
  "message": "string"
}
```

## Related pages

- [Activate a pairing session](./activatepairingsession.md)
- [Add blueprint to existing config](./updateagentconfig.md)
- [Add items to annotation queue](./additemstoannotationqueue.md)
- [Add span comment](./addspancomment.md)
- [Add span feedback score](./addspanfeedbackscore.md)
- [Add thread comment](./addthreadcomment.md)
- [Add trace comment](./addtracecomment.md)
- [Add trace feedback score](./addtracefeedbackscore.md)
- [Agent Configs](./tags/agent-configs.md)
- [Agent Insights](./tags/agent-insights.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
