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.
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"
}