Skip to main content

Create Retention Rule

Create a new retention rule in a repository. If you provide cron, the rule will be enabled on creation.

Allowed Roles: Workspace Admin or System Admin • Authentication Required • Local repositories only

Notes: If retention rules are disabled on the server, this endpoint returns 403. The server can also enforce a maximum number of rules per repository.

POST https://api.repoflow.io/1/workspaces/<workspace-ref>/repositories/<repository-ref>/retention-rules

Path Parameters

workspace-refstringRequired

Workspace ID or name.

repository-refstringRequired

Repository ID or name.

Body

namestringRequired

Retention rule name.

descriptionstringOptional

Retention rule description (defaults to empty string).

targetType"package" | "version" | "file"Required

What this rule targets. Note: file rules can be disabled by server configuration.

ruleJsonobjectRequired

Retention rule JSON (conditions + keepRules). The exact allowed fields depend on targetType.

cronstringOptional

Optional cron expression. When provided, the rule is enabled immediately (server enforces min/max schedule frequency).