---
title: "Create retention rule"
method: POST
path: "/v1/private/retention/rules"
tags: ["Retention Rules"]
---

# Create retention rule

`POST /v1/private/retention/rules`

Create a new retention rule. Auto-deactivates any existing active rule for the same scope.

## Request body

- RetentionRuleWrite
  - `project_id` string, uuid
  - `organization_level` boolean — Set to true to create an organization-level rule
  - `retention` 'short_14d' | 'base_60d' | 'extended_400d' | 'unlimited', required
  - `apply_to_past` boolean

## Response `201`

Created

- RetentionRulePublic
  - `id` string, uuid
  - `workspace_id` string
  - `project_id` string, uuid
  - `level` 'organization' | 'workspace' | 'project' — Computed from projectId and organizationLevel
  - `retention` 'short_14d' | 'base_60d' | 'extended_400d' | 'unlimited', required
  - `apply_to_past` boolean
  - `enabled` boolean
  - `created_by` string
  - `created_at` string, date-time
  - `last_updated_by` string
  - `last_updated_at` string, date-time
  - `catch_up_cursor` string, uuid — Current position of historical data cleanup
  - `catch_up_done` boolean — Whether historical catch-up is complete

---

[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)
