Assign a Permission to a Role
Assign a permission to a role. Note that both the permission being assigned and the role the permission is being assigned to must already exist. Refer to the documentation to create a role 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/roles/:roleId/permissions/:permissionId
Parameters
Parameter | Description | Type | Required |
---|---|---|---|
roleId | The roleId of the role 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/roles/admin/permissions/create-report" \
-X POST \
-H "Authorization: ApiKey YOUR_KEY"
permission, err := permission.AssignPermissionToRole("create-report", "admin")
client.assignPermissionToRole("create-report", "admin");
// Class method
await warrantClient.Permission.assignPermissionToRole("admin", "create-report");
// Instance method
const role = await warrantClient.Role.get("admin");
await role.assignPermission("create-report");
# Class method
warrant.Permission.assign_to_role("admin", "create-report")
# Instance method
role = warrant.Role.get("admin")
role.assign_permission("create-report")
# Class method
Warrant::Permission.assign_to_role("admin", "create-report")
# Instance method
role = Warrant::Role.get("admin")
role.assign_permission("create-report")
$permission = $warrant->assignPermissionToRole("admin", "create-report");
warrant assign permission:create-report role:admin
Response
{
"permissionId": "create-report"
}