Create a New Rule

You can create new Rules from the Dashboard or using the Auth0 Management API.

From the Dashboard

To create a new Rule from the Dashboard, go to Rules > New Rule. You can pick the empty Rule template to start from scratch, or use a pre-made Rule template adjust it to suit your needs.

With the Management API

Rules can also be created with a POST request to /api/v2/rules using the Management APIv2.

This creates a new Rule according to the following input parameters:

Parameter Type Description
name string The name of the Rule. It can only contain alphanumeric characters, spaces, and hypens (-). The name cannot start or end with hyphens or spaces.
script string Τhe script that contains the Rule's code. This is the same as what you would enter when creating a new Rule using the Dashboard.
order number (optional) This number represents the Rule's order in relation to other Rules. A Rule with a lower order than another Rule executes first. If no order is provided, it will automatically be one greater than the current maximum.
enabled boolean (optional) If set to true, the Rule is enabled. If false, the Rule is disabled.

Example of a body schema:

Use this to create the POST request: