メインコンテンツへスキップ
POST
https://{tenantDomain}/api/v2
/
hooks
Go
package example

import (
    context "context"

    management "github.com/auth0/go-auth0/management/management"
    client "github.com/auth0/go-auth0/management/management/client"
    option "github.com/auth0/go-auth0/management/management/option"
)

func do() {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    request := &management.CreateHookRequestContent{
        Name: "name",
        Script: "script",
        TriggerId: management.HookTriggerIdEnumCredentialsExchange,
    }
    client.Hooks.Create(
        context.TODO(),
        request,
    )
}
{
  "dependencies": {},
  "enabled": true,
  "id": "00001",
  "name": "hook",
  "script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
  "triggerId": "<string>"
}

承認

Authorization
string
header
必須

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

ボディ

name
string
デフォルト:my-hook
必須

この Hook の名前。

Pattern: ^[a-zA-Z0-9]([ \-a-zA-Z0-9]*[a-zA-Z0-9])?$
script
string
デフォルト:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
必須

この Hook の実行時に実行されるコード。

Minimum string length: 1
triggerId
enum<string>
必須

この Rule の実行ステージ。credentials-exchangepre-user-registrationpost-user-registrationpost-change-password、または send-phone-message を指定できます。

利用可能なオプション:
credentials-exchange,
pre-user-registration,
post-user-registration,
post-change-password,
send-phone-message
dependencies
object

webtaskサーバーで使用される、このHookの依存関係。

enabled
boolean
デフォルト:false

この Hook を実行するか(true)、無視するか(false)を示します。

レスポンス

Hook が正常に作成されました。

dependencies
object

webtaskサーバーで使用される、このHookの依存関係。

enabled
boolean
デフォルト:true

この Hook を実行するか(true)、無視するか(false)を示します。

id
string
デフォルト:00001

この Hook の ID。

name
string
デフォルト:hook

この Hook の名前。

script
string
デフォルト:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };

この Hook の実行時に実行されるコード。

triggerId
string

トリガー ID