You are here

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

Create a new Rule. Required scope: "create:rules"

@link https://auth0.com/docs/api/management/v2#!/Rules/post_rules @link https://auth0.com/docs/rules/current#create-rules-with-the-management-api

Parameters

array $data Dictionary array of keys and values to create a Rule.:

Return value

mixed

Throws

CoreException Thrown when required "script" or "name" fields are missing or empty.

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

File

vendor/auth0/auth0-php/src/API/Management/Rules.php, line 138

Class

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

Namespace

Auth0\SDK\API\Management

Code

public function create(array $data) {
  if (empty($data['name'])) {
    throw new CoreException('Missing required "name" field.');
  }
  if (empty($data['script'])) {
    throw new CoreException('Missing required "script" field.');
  }
  return $this->apiClient
    ->method('post')
    ->addPath('rules')
    ->withBody(json_encode($data))
    ->call();
}