Assign a Permission to a User
Assign a permission to a user. Note that both the permission being assigned and the user the permission is being assigned to must already exist. Refer to the documentation to create a user and create a permission 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/permissions/:permissionId
Parameters
Parameter | Description | Type | Required |
---|---|---|---|
userId | The userId of the user you want to assign a permission to. | URL param | yes |
permissionId | The permissionId of the permission you want to assign to a role. | URL param | yes |
Request
- cURL
- Go
- Java
- Node.js
- Python
- Ruby
- PHP
- CLI
curl "https://api.warrant.dev/v1/users/d89sm4o9723/permissions/create-report" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY"
permission, err := permission.AssignPermissionToUser("create-report", "d89sm4o9723")
if err != nil {
// handle error
}
try {
client.assignPermissionToUser("create-report", "d89sm4o9723");
} catch (WarrantException e) {
// Handle error
}
// Class method
await warrantClient.Permission.assignPermissionToUser(
"d89sm4o9723",
"create-report"
);
// Instance method
const user = await warrantClient.User.get("d89sm4o9723");
await user.assignPermission("create-report");
# Class method
warrant.Permission.assign_to_user("d89sm4o9723", "create-report")
# Instance method
user = warrant.User.get("d89sm4o9723")
user.assign_permission("create-report")
# Class method
Warrant::Permission.assign_to_user("d89sm4o9723", "create-report")
# Instance method
user = Warrant::User.get("d89sm4o9723")
user.assign_permission("create-report")
$permission = $warrant->assignPermissionToUser("d89sm4o9723", "create-report");
warrant assign permission:create-report user:d89sm4o9723
Response
{
"permissionId": "create-report"
}