Assign a Role to a User
Assign a role to a user. Note that both the role being assigned and the user the role is being assigned to must already exist. Refer to the documentation to create a user and create a role for help.
caution
This endpoint has been deprecated and will be phased out at the end of 2023. Please update any existing usages of it to use the Create Warrant endpoint instead.
Endpoint
POST /v1/users/:userId/roles/:roleId
Parameters
Parameter | Description | Type | Required |
---|---|---|---|
userId | The userId of the user you want to assign a role to. | URL param | yes |
roleId | The roleId of the role you want to assign to a user. | URL param | yes |
Request
- cURL
- Go
- Java
- Node.js
- Python
- Ruby
- PHP
- CLI
curl "https://api.warrant.dev/v1/users/28da7gjs923lg/roles/admin" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY"
assignedRole, err := role.AssignRoleToUser("admin", "28da7gjs923lg")
if err != nil {
// handle error
}
try {
client.assignRoleToUser("admin", "28da7gjs923lg");
} catch (WarrantException e) {
// Handle error
}
// Class method
await warrantClient.Role.assignRoleToUser("28da7gjs923lg", "admin");
// Instance method
const user = await warrantClient.User.get("28da7gjs923lg");
await user.assignRole("admin");
# Class method
warrant.Role.assign_to_user("28da7gjs923lg", "admin")
# Instance method
user = warrant.User.get("28da7gjs923lg")
user.assign_role("admin")
# Class method
Warrant::Role.assign_to_user("28da7gjs923lg", "admin")
# Instance method
user = Warrant::User.get("28da7gjs923lg")
user.assign_role("admin")
$role = $warrant->assignRoleToUser("28da7gjs923lg", "admin");
warrant assign role:admin user:28da7gjs923lg
Response
{
"roleId": "admin"
}