> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Use the Management API from within Rules

> Call the Auth0 Management API from within a Rule using the restricted `auth0 ManagementClient` object, or require a newer `node-auth0` version for additional endpoints and scopes.

> [!WARNING]
>
> **Rules will reach end of life (EOL) on January 31, 2028.**
>
> * As of October 16, 2023, Rules are no longer available in newly created tenants.
> * As of November 18, 2024, Rules are read-only. Active Rules still run, and you can enable or disable them and change their configuration values and secrets. You can't edit their code in the Dashboard, the Management API, or tools that use it, such as the Auth0 CLI, Deploy CLI, Terraform, and Agent Skills.
> * **After January 31, 2028, Rules stop running and are removed.**

**Use Actions to extend Auth0:**

* To learn more about Actions, read [Understand How Auth0 Actions Work](/docs/docs/customize/actions/actions-overview).
* To migrate, read [Migrate from Rules to Actions](/docs/docs/customize/actions/migrate/migrate-from-rules-to-actions).

From within any [Auth0 Rule](/docs/docs/customize/rules) you write, you can update a user's `app_metadata` or `user_metadata` using the `auth0` object, which is a specially-restricted instance of `ManagementClient` (defined in the [node-auth0](https://github.com/auth0/node-auth0) Node.js client library) and provides limited access to the [Auth0 Management API](/docs/docs/api/management/v2).

To access additional Management API (Management API: A product to allow customers to perform administrative tasks.) endpoints from inside Rules, you have to use another version of the library.

The Access Token for the Management API, which is available through `auth0.accessToken`, is limited to the `read:users` and `update:users` scopes. If you require a broader range of scopes, you can request a token using the Client Credentials Flow. See [Get Management API Access Tokens for Production](/docs/docs/secure/tokens/access-tokens/management-api-access-tokens/get-management-api-access-tokens-for-production).

## Access a newer version of the library

You can load a newer version of the Auth0 Node.js client library by requiring the specific version of the library. For up-to-date version information, check the [Auth0 Node repository](https://github.com/auth0/node-auth0) in Github.

In this example, we load version `2.9.1` of the library, then query the list of users and logs the users to the console (to be inspected with [Actions Real-time Logs](/docs/docs/customize/actions/actions-real-time-logs)).

> [!WARNING]
>
> [Searching for users](/docs/docs/manage-users/user-search/user-search-best-practices) from inside Rules may affect the performance of your logins; we advise against it.

```javascript lines theme={null}
function (user, context, callback) {
  var ManagementClient = require('auth0@2.9.1').ManagementClient;
  var management = new ManagementClient({
    token: auth0.accessToken,
    domain: auth0.domain
  });

  management.getUsers(function (err, users) {
    console.log(users);
    callback(null, user, context);
  });
}
```

For a filtered list of available libraries that can be set as required, check the [available library versions](https://auth0-extensions.github.io/canirequire/#auth0).
