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

# Retention Policies

> Read and replace scope retention windows, or remove an override to restore inheritance. A window sets how long data is kept. The retention expiry job of the data plane that hosts the data deletes what a window no longer keeps, where that job is enabled, and deleted data cannot be recovered. max_age_days expires a session with all of its events, by the start of the session. experiment_max_age_days expires an experiment run with its sessions, by the creation of the run. Two kinds of session are kept whatever the windows are: a session of an experiment run whose record was deleted, and a session that has no session event.

## Schema introspection

Every command below with arguments supports two read-only flags for tooling and AI agents:

* `--show-file-schema`: print the JSON Schema for the full request object (the format `--filename` accepts).
* `--show-argument-schema <flag-name>`: print the JSON Schema for one argument's value. Pass the kebab flag name **without** the leading `--` (e.g. `org-id`, not `--org-id`).

Both write pure JSON to stdout and never call the API. They cannot be combined with any other command-specific flag.

## `get-org`

Get an org retention policy

Requires org.retention\_policy.get at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Returns the explicit policy, if present, and the effective policy with its source scope.
The nearest current policy supplies both windows. Fields are not merged across scopes.
When no scope in the lineage has a current policy, effective\_policy is null and data is
retained indefinitely.

### Usage

```sh theme={null}
honeyhive retention-policies get-org [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--org-id` | string | yes | The org whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `replace-org`

Replace an org retention policy

Requires org.retention\_policy.put at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Replaces both windows. Both fields are required. Null retains data indefinitely.
A shorter window makes older data expire. Runs of the retention expiry job delete it, and a
large amount of expired data can take more than one run. Deleted data cannot be recovered.
An explicit policy overrides inherited windows, including when both values are null.
Creates a new policy version and preserves the previous version for audit.

### Usage

```sh theme={null}
honeyhive retention-policies replace-org [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--experiment-max-age-days` | number | yes | Days to keep an experiment run, counted from the creation of the run. A run expires as a whole, with its sessions and their events. From 1 to 3650. null keeps experiment runs indefinitely. |
| `--max-age-days` | number | yes | Days to keep a session that belongs to no experiment run, counted from the start of the session. A session expires as a whole, with all of its events, also while it still receives events. A session of an experiment run whose record was deleted, and a session that has no session event, are kept whatever this value is. From 1 to 3650. null keeps these sessions indefinitely. |
| `--org-id` | string | yes | The org whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `delete-org`

Delete an org retention policy

Requires org.retention\_policy.delete at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Retires this scope's current override and returns the inherited effective policy.
Preserves prior policy values and records the retiring actor, time, and cleared reason.
Repeated deletion is safe when no override exists.

### Usage

```sh theme={null}
honeyhive retention-policies delete-org [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--org-id` | string | yes | The org whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `get-workspace`

Get a workspace retention policy

Requires workspace.retention\_policy.get at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Returns the explicit policy, if present, and the effective policy with its source scope.
The nearest current policy supplies both windows. Fields are not merged across scopes.
When no scope in the lineage has a current policy, effective\_policy is null and data is
retained indefinitely.

### Usage

```sh theme={null}
honeyhive retention-policies get-workspace [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--workspace-id` | string | yes | The workspace whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `replace-workspace`

Replace a workspace retention policy

Requires workspace.retention\_policy.put at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Replaces both windows. Both fields are required. Null retains data indefinitely.
A shorter window makes older data expire. Runs of the retention expiry job delete it, and a
large amount of expired data can take more than one run. Deleted data cannot be recovered.
An explicit policy overrides inherited windows, including when both values are null.
Creates a new policy version and preserves the previous version for audit.

### Usage

```sh theme={null}
honeyhive retention-policies replace-workspace [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--experiment-max-age-days` | number | yes | Days to keep an experiment run, counted from the creation of the run. A run expires as a whole, with its sessions and their events. From 1 to 3650. null keeps experiment runs indefinitely. |
| `--max-age-days` | number | yes | Days to keep a session that belongs to no experiment run, counted from the start of the session. A session expires as a whole, with all of its events, also while it still receives events. A session of an experiment run whose record was deleted, and a session that has no session event, are kept whatever this value is. From 1 to 3650. null keeps these sessions indefinitely. |
| `--workspace-id` | string | yes | The workspace whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `delete-workspace`

Delete a workspace retention policy

Requires workspace.retention\_policy.delete at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Retires this scope's current override and returns the inherited effective policy.
Preserves prior policy values and records the retiring actor, time, and cleared reason.
Repeated deletion is safe when no override exists.

### Usage

```sh theme={null}
honeyhive retention-policies delete-workspace [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--workspace-id` | string | yes | The workspace whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `get-project`

Get a project retention policy

Requires project.retention\_policy.get at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Returns the explicit policy, if present, and the effective policy with its source scope.
The nearest current policy supplies both windows. Fields are not merged across scopes.
When no scope in the lineage has a current policy, effective\_policy is null and data is
retained indefinitely.

### Usage

```sh theme={null}
honeyhive retention-policies get-project [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--project-id` | string | yes | The project whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `replace-project`

Replace a project retention policy

Requires project.retention\_policy.put at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Replaces both windows. Both fields are required. Null retains data indefinitely.
A shorter window makes older data expire. Runs of the retention expiry job delete it, and a
large amount of expired data can take more than one run. Deleted data cannot be recovered.
An explicit policy overrides inherited windows, including when both values are null.
Creates a new policy version and preserves the previous version for audit.

### Usage

```sh theme={null}
honeyhive retention-policies replace-project [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--experiment-max-age-days` | number | yes | Days to keep an experiment run, counted from the creation of the run. A run expires as a whole, with its sessions and their events. From 1 to 3650. null keeps experiment runs indefinitely. |
| `--max-age-days` | number | yes | Days to keep a session that belongs to no experiment run, counted from the start of the session. A session expires as a whole, with all of its events, also while it still receives events. A session of an experiment run whose record was deleted, and a session that has no session event, are kept whatever this value is. From 1 to 3650. null keeps these sessions indefinitely. |
| `--project-id` | string | yes | The project whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.

## `delete-project`

Delete a project retention policy

Requires project.retention\_policy.delete at the scope in the URL.
The key must cover that scope. Scope headers do not select the target.
Retires this scope's current override and returns the inherited effective policy.
Preserves prior policy values and records the retiring actor, time, and cleared reason.
Repeated deletion is safe when no override exists.

### Usage

```sh theme={null}
honeyhive retention-policies delete-project [options]
```

**Accepted keys:** [Control plane fine-grained API key](https://docs.honeyhive.ai/v2/workspace/api-keys.md#key-types)

### Options

| Flag | Type | Required | Description |
| - | - | - | - |
| `--project-id` | string | yes | The project whose retention policy is requested. |

Also supports `--show-file-schema`, `--show-argument-schema <flag-name>`, and `--filename`. See [Schema introspection](#schema-introspection) for details.


## Related topics

- [Retention Policies Methods](https://docs.honeyhive.ai/v2/control-plane-sdk-reference/typescript/ref/retention-policies/index.md)
- [Get a workspace retention policy](https://docs.honeyhive.ai/v2/control-plane-api-reference-autogen/retention-policies/get-a-workspace-retention-policy.md)
- [Get a project retention policy](https://docs.honeyhive.ai/v2/control-plane-api-reference-autogen/retention-policies/get-a-project-retention-policy.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.