Set roles for users
curl --request POST \ --url "$UNEEQ_API_URL/external/v1/organization/$UNEEQ_ORG_ID/users/roles/assign" \ --header "Authorization: Bearer $UNEEQ_API_KEY" \ --header "Content-Type: application/json" \ --data '{ "user_ids": [ "3fa85f64-5717-4562-b3fc-2c963f66afa6" ], "roles": [ "MANAGER", "USER" ]}'const url = `${process.env.UNEEQ_API_URL}/external/v1/organization/${process.env.UNEEQ_ORG_ID}/users/roles/assign`;const response = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${process.env.UNEEQ_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "user_ids": [ "3fa85f64-5717-4562-b3fc-2c963f66afa6" ], "roles": [ "MANAGER", "USER" ] }),});console.log(response.status, await response.text());Sets the organization roles of one or more users. Roles are replaced, not added: after the call each
listed user holds exactly the roles in roles in this organization. Sending an empty roles array removes
all of their roles, which also removes them from the user list.
All users are updated in a single transaction: if any user fails, no user is changed. The UNEEQ_ADMIN
role passes validation but can never be granted through the API (403 role_not_permitted). An empty
user_ids array succeeds without changing anything. Unknown fields in the body are ignored.
Every user must be a member of this organization, with any status (active, inactive, invited or expired). If any ID is not a member, or does not exist, the call returns 400 and nothing is changed. Add people with the add-users endpoint first.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”ID of the organization the API key belongs to, for example org_HYPCX67vaupjhdTn.
Example
org_HYPCX67vaupjhdTnRequest Bodyrequired
Section titled “Request Bodyrequired”object
IDs of the users to update, in lowercase hyphenated form as returned by the API. Other UUID spellings (upper case, no hyphens, braces) pass validation but match no member and fail with 400. An empty array changes nothing.
The roles each user will hold in this organization. Replaces their current roles; an empty array removes all of them.
Example
{ "user_ids": [ "3fa85f64-5717-4562-b3fc-2c963f66afa6" ], "roles": [ "MANAGER", "USER" ]}Responses
Section titled “Responses”Roles were updated. No body.
user_ids or roles is missing or null, user_ids contains a value that is not a UUID, or roles
contains an unknown role (message “invalid request”). Also returned when one or more users are not members of
this organization (message “invalid user_ids”). No error_code.
The body of an error returned by an endpoint.
object
Human-readable explanation of what went wrong.
Stable machine-readable cause. Present only for errors that have one.
Example generated
{ "message": "example", "error_code": "example"}The Authorization header is missing, or the API key is not valid for this organization. A key check that fails on the server is also reported as 401.
The body of an error returned before the request reaches an endpoint (authentication and rate limiting).
object
Human-readable explanation of what went wrong.
Example generated
{ "error": "example"}roles includes a role the API may not grant (UNEEQ_ADMIN). error_code is role_not_permitted;
nothing was changed.
The body of an error returned by an endpoint.
object
Human-readable explanation of what went wrong.
Stable machine-readable cause. Present only for errors that have one.
Example generated
{ "message": "example", "error_code": "example"}The API key has sent too many requests. Wait for the number of seconds in Retry-After, then retry.
The body of an error returned before the request reaches an endpoint (authentication and rate limiting).
object
Human-readable explanation of what went wrong.
Example generated
{ "error": "example"}Headers
Section titled “Headers”Seconds to wait before retrying.
The body is not valid JSON or has a field of the wrong type (“unable to decode request body”), the membership check failed (“unable to get user status for the requested organization”), or the roles could not be stored (“unable to assign role to a requested user”, or “unable to assign users to a requested organization” when the final save fails). Nothing was changed.
The body of an error returned by an endpoint.
object
Human-readable explanation of what went wrong.
Stable machine-readable cause. Present only for errors that have one.
Example generated
{ "message": "example", "error_code": "example"}
