Remove a hand-made org unit
DELETE/api/public/v1/org-units/{unit_id}
Manual, non-root units only. Children and every agent accountable to the unit reparent to its parent in one transaction, and the unit is tombstoned rather than removed so the path's history stays honest. A zone the unit carries retires with it, exactly as DELETE /zones/{id} does: its ratified policies are deleted with it, each with its history and audit event (or moved to the nearest zone above with move_policies=true; a same-layer Optimize conflict there answers 409 SAME_LAYER_CONFLICT, a layer the policy would loosen 409 LOOSENS_LAYER), and agents assigned to it by hand are re-pointed to the nearest zone above and stay assigned by hand. dry_run=true answers the impact and writes nothing.
curl --fail-with-body -X DELETE 'https://app.openlatch.ai/api/public/v1/org-units/<unit_id>' \ -H "Authorization: Bearer $OPENLATCH_API_KEY"import jsonimport osimport urllib.request
request = urllib.request.Request( 'https://app.openlatch.ai/api/public/v1/org-units/<unit_id>', method='DELETE', headers={ 'Authorization': 'Bearer ' + os.environ['OPENLATCH_API_KEY'], },)with urllib.request.urlopen(request) as response: text = response.read().decode() print(json.dumps(json.loads(text), indent=2) if text else response.status)#!/usr/bin/env bashset -euo pipefail
curl -sS --fail-with-body -X DELETE 'https://app.openlatch.ai/api/public/v1/org-units/<unit_id>' \ -H "Authorization: Bearer $OPENLATCH_API_KEY" | jq .$headers = @{ Authorization = "Bearer $env:OPENLATCH_API_KEY"}Invoke-RestMethod -Method DELETE -Uri 'https://app.openlatch.ai/api/public/v1/org-units/<unit_id>' -Headers $headers | ConvertTo-Json -Depth 20Authorization
Section titled “Authorization”| Role in the organization | This endpoint |
|---|---|
owner | Allowed |
admin | Allowed |
editor | Not allowed |
viewer | Not allowed |
A key carries the role its owner holds in the organization. See Authentication.
API key scope: org:write
Path parameters
Section titled “Path parameters”| Parameter | Type | Description |
|---|---|---|
unit_id | string (uuid) | Required. |
Query parameters
Section titled “Query parameters”| Parameter | Type | Description |
|---|---|---|
move_policies | boolean | Move the zone's policies to the nearest zone above instead of deleting them. |
dry_run | boolean | Answer the impact and change nothing. |
Header parameters
Section titled “Header parameters”| Parameter | Type | Description |
|---|---|---|
Idempotency-Key | string or null | Optional. Makes the request safe to retry: the same key and the same request, within 24 hours, returns the stored response with Idempotent-Replayed: true and runs once. |
Response
Section titled “Response”- 200 OK — the call succeeded.
- 401 Unauthorized —
UNAUTHORIZED - 402 Payment Required —
license_expired - 403 Forbidden —
FEATURE_DISABLED,FORBIDDEN,INSUFFICIENT_SCOPE - 404 Not Found —
NOT_FOUND,ZONE_NOT_FOUND - 409 Conflict —
DIRECTORY_OWNED,IDEMPOTENCY_IN_PROGRESS,LOOSENS_LAYER,ROOT_UNIT,ROOT_ZONE,SAME_LAYER_CONFLICT,UNIT_CYCLE,UNIT_EXISTS - 422 Unprocessable Content —
DEPTH_EXCEEDED,IDEMPOTENCY_KEY_REUSED,INVALID_ID,INVALID_NAME,VALIDATION_ERROR - 429 Too Many Requests —
TOO_MANY_REQUESTS - 500 Internal Server Error —
INTERNAL_SERVER_ERROR,tenant_isolation_violation - 503 Service Unavailable —
ENGINE_UNAVAILABLE,FEATURE_STATE_UNAVAILABLE,PROOF_UNAVAILABLE,SERVICE_UNAVAILABLE
Example response
Section titled “Example response”{ "detached_policies": 0, "moved_agents": 3, "moved_policies": 0, "moved_units": 3, "repointed_by_hand": 0, "retired_policies": 3, "stricter_on_target": 0, "unattached_after": 0}