> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging-actions-triggers-prototype.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Learn how to use the Management API from within rules.

# Use the Management API from within Rules

<Warning>
  The End of Life (EOL) date of Rules and Hooks will be **November 18, 2026**, and they are no longer available to new tenants created as of **October 16, 2023**. Existing tenants with active Hooks will retain Hooks product access through end of life.

  We highly recommend that you use Actions to extend Auth0. With Actions, you have access to rich type information, inline documentation, and public `npm` packages, and can connect external integrations that enhance your overall extensibility experience. To learn more about what Actions offer, read [Understand How Auth0 Actions Work](/docs/customize/actions/actions-overview).

  To help with your migration, we offer guides that will help you [migrate from Rules to Actions](/docs/customize/actions/migrate/migrate-from-rules-to-actions) and [migrate from Hooks to Actions](/docs/customize/actions/migrate/migrate-from-hooks-to-actions). We also have a dedicated [Move to Actions](https://auth0.com/platform/extensibility/movetoactions) page that highlights feature comparisons, [an Actions demo](https://www.youtube.com/watch?v=UesFSY1klrI), and other resources to help you on your migration journey.

  To read more about the Rules and Hooks deprecation, read our blog post: [Preparing for Rules and Hooks End of Life](https://auth0.com/blog/preparing-for-rules-and-hooks-end-of-life/).
</Warning>

From within any [Auth0 Rule](/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](https://auth0.com/docs/api/management/v2).

To access additional <Tooltip tip="Management API: A product to allow customers to perform administrative tasks." cta="View Glossary" href="/docs/glossary?term=Management+API">Management API</Tooltip> endpoints from inside Rules, you have to use another version of the library.

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  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/secure/tokens/access-tokens/management-api-access-tokens/get-management-api-access-tokens-for-production).
</Callout>

## 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/customize/actions/actions-real-time-logs)).

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

```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);
  });
}
```

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  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).
</Callout>
