Auth API reference

Auth API · Consumer-Admin

patch/{app_slug}/v1/admin/users/{user_id}/roleAuth

Assign an end-user a role

Sets `app_membership.role_id` for the target user. For M2M callers the assignable role is bounded by the token's scopes (the guard already enforced `role.assign`); the role's own permission set is NOT additionally narrowed against the M2M scopes because M2M scopes are typically broader than per-user role perms by design (a backend cron with `user.list` + `role.assign` SHOULD be able to promote a user into a role carrying any per-app perm). EndUser admins are bounded by their own role's perms transitively — they couldn't authenticate as an admin without holding the perm.

Path parameters

app_slug*string

Slug of the app.

user_id*string

Id of the user.

Request body

role_name*string

Target role name (must already exist in this app).

Example: "member"

Response · 200 Membership updated.

user_id*string

Account UUID of the end-user whose role changed.

role_name*string

Role name now bound to the app membership.

Example: "admin"

Example

Request

PATCH https://api.auth.productcraft.co/{app_slug}/v1/admin/users/{user_id}/role
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "role_name": "member"
}

Response

{
  "user_id": "string",
  "role_name": "admin"
}