Skip to main content
Opik Documentation

Search documentation

Type to search this documentation.

Create retention rule

POST/v1/private/retention/rulesCreate retention rule

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

Request body

application/json
objectRetentionRule_Write
apply_to_pastboolean
organization_levelboolean

Set to true to create an organization-level rule

project_idstring · uuid
retentionstringrequired

one of "short_14d", "base_60d", "extended_400d", "unlimited"

Example request
{
  "apply_to_past": true,
  "organization_level": true,
  "project_id": "00000000-0000-0000-0000-000000000000",
  "retention": "base_60d"
}

Responses

201Createdapplication/json

Headers

Location
objectRetentionRule_Public
apply_to_pastboolean
catch_up_cursorstring · uuid

Current position of historical data cleanup

catch_up_doneboolean

Whether historical catch-up is complete

created_atstring · date-time
created_bystring
enabledboolean
idstring · uuid
last_updated_atstring · date-time
last_updated_bystring
levelstring

Computed from projectId and organizationLevel

one of "organization", "workspace", "project"

project_idstring · uuid
retentionstringrequired

one of "short_14d", "base_60d", "extended_400d", "unlimited"

workspace_idstring
Example response
{
  "apply_to_past": true,
  "catch_up_cursor": "00000000-0000-0000-0000-000000000000",
  "catch_up_done": true,
  "created_at": "2026-06-09T00:00:00Z",
  "created_by": "string",
  "enabled": true,
  "id": "00000000-0000-0000-0000-000000000000",
  "last_updated_at": "2026-06-09T00:00:00Z",
  "last_updated_by": "string",
  "level": "organization",
  "project_id": "00000000-0000-0000-0000-000000000000",
  "retention": "base_60d",
  "workspace_id": "string"
}
Documentation menu