---
title: "Trigger Consent Request Cleanup"
method: POST
path: "/api/agreement/v1/consent-requests/cleanup"
tags: ["Consent Requests"]
---

# Trigger Consent Request Cleanup

`POST /api/agreement/v1/consent-requests/cleanup`

## Request

- The document declares no server URL.
- Auth: OpenID Connect (`http://localhost:6999/realms/agate/.well-known/openid-configuration`, scopes: `agridata.ch.Agridata_Admin`)

Triggers the consent request cleanup that otherwise runs as a scheduled daily job, and waits for it to finish. Only accessible to administrators. The run is guarded by the same cluster-wide advisory lock as the scheduled job, so a conflict is reported if a cleanup is already running. By default, the same two-day window as the scheduled job is used; an explicit window can be passed to catch up on days that were missed, e.g. after an outage.

## Query parameters

- `fromInclusive` string, date
- `toInclusive` string, date

## Response `200`

OK

- ConsentRequestCleanupResultDto: Data transfer object representing the result of a consent request cleanup run
  - `fromInclusive` string, date
  - `toInclusive` string, date
  - `terminatedConsentRequestCount` integer: Number of consent requests that were terminated during this run
  - `durationMs` integer: Duration of the cleanup run in milliseconds

## Other responses

- `401`: Not Authorized
- `403`: Not Allowed
- `404`: The resource or element was not found
- `500`: Internal server error: unexpected error

## Changes

- **2026-10-19** `75957f6bdc66`: 4 warning
  - added the new `EXPORT_CAPACITY_EXHAUSTED` enum value to the `type` response property for the response status `404`
  - added the new `EXPORT_CAPACITY_EXHAUSTED` enum value to the `type` response property for the response status `500`
  - added the new `EXPORT_LIMIT_EXCEEDED` enum value to the `type` response property for the response status `404`
  - added the new `EXPORT_LIMIT_EXCEEDED` enum value to the `type` response property for the response status `500`
- **2026-09-24** `1aa7b6ad5bcc`: 2 warning
  - added the new `UID_CLAIM_MISSING` enum value to the `type` response property for the response status `404`
  - added the new `UID_CLAIM_MISSING` enum value to the `type` response property for the response status `500`
- **2026-09-08** `78f342f31c68`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/agridata/apis/agridata-ch-api/changes/api/agreement/v1/consent-requests/cleanup/post.md)

---

[API](https://skmtc.dev/agridata/apis/agridata-ch-api.md) - [All operations](https://skmtc.dev/agridata/apis/agridata-ch-api/llms.txt) - [OpenAPI document](https://skmtc.dev/agridata/apis/agridata-ch-api/revisions/48ab7e1541c3?raw)
