Skip to content

Create role

Request to create a new role:

POST /api/v2/roles.json

The request body contains the role object. name is required. When tenant_id is omitted, the role is created in the tenant of the API user. Permissions that are not listed are not granted.

For example:

{
    "role": {
        "name": "Supervisor",
        "tenant_id": "e00a4822-f288-11e4-b559-e03f497dbdff",
        "access_level": "managed_groups",
        "permissions": {
            "users": ["view"],
            "calls": ["view", "playback", "categorize", "on_demand_trigger"],
            "call_notes": ["view", "pin"]
        }
    }
}

Response contains HTTP status code as shown in the following table.

Response Description
201 Created

The role has been successfully created. The Location header and the response body contain the URL of the new role:

HTTP/1.1 201 Created
Location: /api/v2/roles/e011c408-f288-11e4-9b73-e03f497dbdff.json

{"url": "/api/v2/roles/e011c408-f288-11e4-9b73-e03f497dbdff.json"} | | 400 Bad Request |

The request cannot be completed because the supplied JSON object has invalid data, for example a permission that is not allowed for the access scope.

The response contains a detailed description of the error, like:

{"error": "InvalidRecord", "explanation": "Record Validation errors", "details": {"name": "Role with such name exists already"}}
| | 403 Forbidden | The request cannot be completed because API user has no permission to create roles |