Passer au contenu principal
POST
/
hooks
TypeScript
import { ManagementClient } from "auth0";

async function main() {
    const client = new ManagementClient({
        token: "<token>",
    });
    await client.hooks.create({
        name: "name",
        script: "script",
        triggerId: "credentials-exchange",
    });
}
main();
{
  "triggerId": "<string>",
  "id": "00001",
  "name": "hook",
  "enabled": true,
  "script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
  "dependencies": {}
}

Autorisations

Authorization
string
header
requis

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Corps

name
string
défaut:my-hook
requis

Name of this hook.

Pattern: ^[a-zA-Z0-9]([ \-a-zA-Z0-9]*[a-zA-Z0-9])?$
script
string
défaut:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
requis

Code to be executed when this hook runs.

Minimum string length: 1
triggerId
enum<string>
requis

Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message.

Options disponibles:
credentials-exchange,
pre-user-registration,
post-user-registration,
post-change-password,
send-phone-message
enabled
boolean
défaut:false

Whether this hook will be executed (true) or ignored (false).

dependencies
object

Dependencies of this hook used by webtask server.

Réponse

Hook successfully created.

triggerId
string

Trigger ID

id
string
défaut:00001

ID of this hook.

name
string
défaut:hook

Name of this hook.

enabled
boolean
défaut:true

Whether this hook will be executed (true) or ignored (false).

script
string
défaut:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };

Code to be executed when this hook runs.

dependencies
object

Dependencies of this hook used by webtask server.