Skip to content
UneeqUneeqUneeq Docs

Set roles for users

POST
/external/v1/organization/{organizationID}/users/roles/assign
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"
]
}'

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.

organizationID
required
string

ID of the organization the API key belongs to, for example org_HYPCX67vaupjhdTn.

Example

org_HYPCX67vaupjhdTn
Media typeapplication/json
object
user_ids
required

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.

Array<string>
roles
required

The roles each user will hold in this organization. Replaces their current roles; an empty array removes all of them.

Array<string>
Allowed values: UNEEQ_ADMIN ORG_ADMIN TEAM_ADMIN AUTHOR MANAGER USER

Example

{
"user_ids": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"roles": [
"MANAGER",
"USER"
]
}

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.

Media typeapplication/json

The body of an error returned by an endpoint.

object
message
required

Human-readable explanation of what went wrong.

string
error_code

Stable machine-readable cause. Present only for errors that have one.

string

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.

Media typeapplication/json

The body of an error returned before the request reaches an endpoint (authentication and rate limiting).

object
error
required

Human-readable explanation of what went wrong.

string

Example generated

{
"error": "example"
}

roles includes a role the API may not grant (UNEEQ_ADMIN). error_code is role_not_permitted; nothing was changed.

Media typeapplication/json

The body of an error returned by an endpoint.

object
message
required

Human-readable explanation of what went wrong.

string
error_code

Stable machine-readable cause. Present only for errors that have one.

string

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.

Media typeapplication/json

The body of an error returned before the request reaches an endpoint (authentication and rate limiting).

object
error
required

Human-readable explanation of what went wrong.

string

Example generated

{
"error": "example"
}
Retry-After
integer
>= 1

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.

Media typeapplication/json

The body of an error returned by an endpoint.

object
message
required

Human-readable explanation of what went wrong.

string
error_code

Stable machine-readable cause. Present only for errors that have one.

string

Example generated

{
"message": "example",
"error_code": "example"
}