---
title: "Grant or revoke the platform admin role"
method: PATCH
path: "/stats/users/{id}/role"
tags: ["Stats"]
---

# Grant or revoke the platform admin role

`PATCH /stats/users/{id}/role`

## Request

- Base URL: `https://api.nippy.host`
- URL: `https://api.nippy.host/stats/users/{id}/role`
- Auth: `bearer` (a scheme the document does not define)

Admin-only. Sets the target user’s platform role and records a `user.role_changed` activity attributed to the acting admin. Self-demotion is rejected (another admin must revoke you). Note the `ADMIN_EMAILS` allowlist is grant-only and re-promotes on sign-in — to permanently revoke an allowlisted admin, also remove them from the allowlist.

## Path parameters

- `id` string, required

## Request body

- UpdateUserRoleDto
  - `role` 'user' | 'admin', required: Platform role to set. `admin` grants access to the admin panel; `user` revokes it.

## Response `200`

- APIAdminUserRole
  - `id` string, required: User id (UUID).
  - `role` 'user' | 'admin', required: The role now in effect.

## Other responses

- `400`: Attempted to revoke your own role
- `403`: Admin access required
- `404`: User not found

---

[API](https://skmtc.dev/nippy/apis/nippy-backend-api.md) · [All operations](https://skmtc.dev/nippy/apis/nippy-backend-api/llms.txt) · [OpenAPI document](https://skmtc.dev/nippy/apis/nippy-backend-api/revisions/7ab23f040a55?raw)
