---
title: "Prune expired audit and OAuth token rows in bounded batches"
method: POST
path: "/internal/audit/retention/prune"
tags: ["Internal"]
---

# Prune expired audit and OAuth token rows in bounded batches

`POST /internal/audit/retention/prune`

## Request

- Base URL: `https://api.openworklabs.com`
- URL: `https://api.openworklabs.com/internal/audit/retention/prune`
- Auth: HTTP bearer

Runs bounded, indexed batch deletion for expired platform_audit_event rows, delete_oldest organization audit operations beyond retention/allowance, and expired oauthAccessToken rows. Supports dryRun=true to preview candidates without deleting. Answers 404 when DEN_MAINTENANCE_TOKEN is not configured.

## Response `200`

Retention prune batch finished.

- object
  - `dryRun` boolean, required
  - `durationMs` integer, required
  - `platform` object, nullable, required
    - `deleted` integer, required
    - `batches` integer, required
    - `hasMore` boolean, required
    - `cutoff` string, date-time, required
    - `dryRun` boolean, required
  - `organization` object, nullable, required
    - `operationsDeleted` integer, required
    - `eventsDeleted` integer, required
    - `resourcesDeleted` integer, required
    - `batches` integer, required
    - `organizationsTouched` integer, required
    - `hasMore` boolean, required
    - `cutoff` string, date-time, nullable, required
    - `dryRun` boolean, required
  - `oauthAccessTokens` object, nullable, required
    - `deleted` integer, required
    - `scanned` integer, required
    - `batches` integer, required
    - `hasMore` boolean, required
    - `cutoff` string, date-time, required
    - `dryRun` boolean, required

## Other responses

- `400`: Invalid prune options.
- `401`: Missing or wrong maintenance token.
- `404`: Maintenance endpoints are not configured on this deployment.
- `500`: The prune failed; remaining rows are retried on the next run.

## Changes

- **2026-12-01** `9e0e1784e377`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/openworklabs/apis/den-api/changes/internal/audit/retention/prune/post.md)

---

[API](https://skmtc.dev/openworklabs/apis/den-api.md) - [All operations](https://skmtc.dev/openworklabs/apis/den-api/llms.txt) - [OpenAPI document](https://skmtc.dev/openworklabs/apis/den-api/revisions/84fb0f99fb95?raw)
