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.To help with your migration, we offer guides that will help you migrate from Rules to Actions and migrate from Hooks to Actions. We also have a dedicated Move to Actions page that highlights feature comparisons, an Actions demo, 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.Because we plan to remove Rules and Hooks functions in 2026, you should create new Rules or Hooks only in your Development environment and only to test migration to Actions.To learn how to migrate your Rules to Actions, read Migrate from Rules to Actions. To learn how to migrate your Hooks to Actions, read Migrate from Hooks to Actions.
Although you may create multiple hooks for any given extensibility point, each extensibility point may have only one enabled hook at a time. Any subsequent hooks you create for that extensibility point are automatically disabled, so you must explicitly enable them. The enabled hook will be executed for all applications and APIs.
Prerequisites
Before beginning this tutorial, you must:- Register your API with Auth0
-
Register the M2M Application with Auth0.
- Select an Application Type of Machine to Machine Applications.
- Choose your previously-registered API.
- Authorize the M2M Application to call your API.
Steps
- Create Hook: Create a hook that will customize your token.
- Test Hook: Test your new hook by running a Client Credentials Flow and decoding the access token.
Create a Hook
In this example, you will:- add an arbitrary claim (
https://foo.com/claim
) to the Access Token - add an extra permission to your configured API
Client Credentials Exchange
, and add the following code in the editor:
Auth0 returns profile information in a structured claim format as defined by the OpenID Connect (OIDC) specification. This means that custom claims added to ID tokens or access tokens must conform to guidelines and restrictions to avoid possible collisions.
Test your Hook
To test the hook you just created you need to run a Client Credentials exchange, get the , decode it, and review its contents.Get token
To get a token, make aPOST
call to the Client Credentials Flow endpoint. Be sure to replace CLIENT_ID, CLIENT_SECRET, and API_IDENTIFIER placeholder values with your application’s , your application’s , and your API’s Identifier, respectively. You can find the Client ID and Client Secret in your Application settings and the API Identifier in your API settings.
- an
access_token
, - its expiration time in seconds (
expires_in
), - the token’s type set as
Bearer
(token_type
), and - an
extra
permission (scope
) (which was added by your Hook)
Decode token
The easiest way to decode the access token and review its contents is to use the JWT.io Debugger. Copy your access token and paste it into the editor. The is decoded automatically and its contents are displayed. Note that the last two items of the Payload have both been set by your hook:"scope": "extra"
"https://foo.com/claim": "bar"