---
title: "Create Retention Policy Endpoint"
method: POST
path: "/admin/retention-policies"
tags: ["Retention"]
---

# Create Retention Policy Endpoint

`POST /admin/retention-policies`

## Request

- Base URL: `https://api.pharia.example.com`
- URL: `https://api.pharia.example.com/admin/retention-policies`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/aleph-alpha/apis/stateful-responses/docs/admin/retention-policies/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a retention policy for the caller's (or target) application-id.

## Request body

- RetentionPolicyCreateRequest: Request body for creating a retention policy via the admin API.
  - `application_id` string, nullable
  - `retention_period` string, required
  - `expiry_action` 'soft-delete' | 'hard-delete': What happens to a record when its retention period elapses.
  - `grace_period` string
  - `hard_delete_after_grace` boolean
  - `schedule` string

## Response `201`

Successful Response

- unknown

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `413`: Content Too Large
- `422`: Validation errors are returned as 400, not 422. This entry exists because FastAPI generates it automatically.
- `425`: Too Early
- `500`: Internal Server Error
- `501`: Not Implemented
- `502`: Bad Gateway
- `504`: Gateway Timeout

---

[API](https://skmtc.dev/aleph-alpha/apis/stateful-responses.md) - [All operations](https://skmtc.dev/aleph-alpha/apis/stateful-responses/llms.txt) - [OpenAPI document](https://skmtc.dev/aleph-alpha/apis/stateful-responses/revisions/2747297acb54?raw)
