The Operations REST API (BAW 20.0.0.1+, context root /ops, Swagger at /ops/docs) is the administration API: it covers what Process Admin and the Process Center console do - containers (process apps / toolkits), versions (snapshots), servers, instance and task housekeeping, event manager, users / teams synchronisation, indexing, and asynchronous operation queues. It needs the Workflow administrator role and the CSRF token on every call.
# CSRF token
TOKEN=$(curl -sk -u admin:pw -X POST "$BAW/ops/system/login" -H "Content-Type: application/json" -d '{"refresh_groups":false,"requested_lifetime":7200}' | jq -r .csrf_token)
H=(-H "BPMCSRFToken: $TOKEN" -u admin:pw)
# 1. delete finished instances of a container older than 90 days (asynchronous: returns a queue id)
curl -sk "${H[@]}" -X DELETE "$BAW/ops/std/bpm/processes?states=finished&container=ORD&ended_before=$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%SZ)"
# -> { "id": "op-123", "status": "running" } ; poll: GET $BAW/ops/system/queue/op-123
# count first: GET $BAW/ops/std/bpm/processes/count?states=finished&container=ORD&ended_before=…
# 2. snapshots: list, deactivate, archive
curl -sk "${H[@]}" "$BAW/ops/std/bpm/containers/ORD?optional_parts=versions"
curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/containers/ORD/versions/2.1/deactivate"
curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/containers/ORD/versions/2.1/archive"
# 3. event manager: pause during maintenance, resume after
curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/event_manager/pause"; curl -sk "${H[@]}" "$BAW/ops/std/bpm/event_manager/monitor"; curl -sk "${H[@]}" -X POST "$BAW/ops/std/bpm/event_manager/resume"
# 4. other housekeeping: completed tasks, durable messages, EPV history, PDW prune, saved-search acceleration
DELETE /ops/std/bpm/tasks?task_type=USER_TASK&task_status=ALL_COMPLETED&ended_before=…
DELETE /ops/std/bpm/durable_messages?ended_before=… DELETE /ops/std/bpm/epvs/history?container=ORD&version=2.1
POST /ops/std/bpm/pdw/prune?days=180 POST /ops/std/bpm/saved_search_acceleration/optimizeRules: long operations are asynchronous - always poll the queue and log its result; run deletions in batches by date window on big databases; pause the event manager only briefly (timers queue up); on CP4BA the same API sits behind the Zen front door (ZenApiKey instead of basic auth). Parameter names differ slightly between 20.x, 22.x and 24.x - generate your scripts from the /ops/docs Swagger of the target level.
References