You are here

public function Roles::create in Auth0 Single Sign On 8.2

Create a new Role. Required scope: "create:roles"

@link https://auth0.com/docs/api/management/v2#!/Roles/post_roles

Parameters

string $name Role name.:

array $data Additional fields to add, like description.:

Return value

mixed

Throws

EmptyOrInvalidParameterException Thrown if the name parameter is empty or is not a string.

\Exception Thrown by the HTTP client when there is a problem with the API call.

File

vendor/auth0/auth0-php/src/API/Management/Roles.php, line 51

Class

Roles
Class Roles. Handles requests to the Roles endpoint of the v2 Management API.

Namespace

Auth0\SDK\API\Management

Code

public function create($name, array $data = []) {
  $this
    ->checkEmptyOrInvalidString($name, 'name');
  $data['name'] = $name;
  return $this->apiClient
    ->method('post')
    ->addPath('roles')
    ->withBody(json_encode($data))
    ->call();
}