Skip to content
POST /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

idstring
required·

Role id (role_…) being deleted.

Request Body

reassign_tostring

Same as DELETE /role/{id}'s reassign_to query parameter — the default target.

reassignmentsobject[]

Per-member overrides. Bounded, and never a substitute for reassign_to on invites.

role_idstring

Role id (role_…) to move that one member onto.

user_idstring

User id (usr_…) of a current holder of id.

Response Body

reassigned_by_roleobject[]

One row per distinct target role that received at least one member.

countinteger
role_idstring
role_namestring
reassigned_invite_countinteger
reassigned_member_countinteger
successboolean
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())