Delete role (structured body)
/role/{id}/delete
The same operation as `DELETE /role/{id}` — same authorization, same guards, same atomic transaction — with a JSON body instead of a query parameter, so a caller can also move SPECIFIC holders onto a role of their own choosing before the rest fall back to `reassign_to`. `reassignments` is capped at 200 entries; past it the call answers `400` naming the ceiling. Each entry's `role_id` is checked against the same grant ceiling as `reassign_to` (never the role being deleted), and each `user_id` must currently hold the role — one that no longer does answers `409` (`role_holder_changed`), so the caller can refresh and retry. `reassign_to` becomes optional once every holder is covered by `reassignments` AND no pending invite is for the role (invites are never individually overridden, and always fall back to `reassign_to`); short of that it is still required, exactly as on the plain DELETE form. The response adds `reassigned_by_role`: one row per DISTINCT target role actually used, bounded by how many roles the caller named.
Path Parameters
Role id (role_…) being deleted.
Request Body
Same as DELETE /role/{id}'s reassign_to query parameter — the default target.
Per-member overrides. Bounded, and never a substitute for reassign_to on invites.
Role id (role_…) to move that one member onto.
User id (usr_…) of a current holder of id.
Response Body
One row per distinct target role that received at least one member.
curl -X POST 'https://api.elaichi.ai/role/<id>/delete' \
-H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"reassign_to":"your_reassign_to","reassignments":[]}'const body = {
"reassign_to": "your_reassign_to",
"reassignments": []
};
const response = await fetch('https://api.elaichi.ai/role/<id>/delete', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + process.env.ELAICHI_API_TOKEN,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
const data = await response.json();
console.log(data);import os
import requests
url = "https://api.elaichi.ai/role/<id>/delete"
headers = {
"Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
"Content-Type": "application/json",
}
payload = {
"reassign_to": "your_reassign_to",
"reassignments": []
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())