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.UpdateHookRequestContent{}
client.Hooks.Update(
context.TODO(),
"id",
request,
)
}import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.update("id", {});
}
main();import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.update("id", {});
}
main();curl --request PATCH \
--url https://{tenantDomain}/api/v2/hooks/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"enabled": false,
"dependencies": {}
}
'import requests
url = "https://{tenantDomain}/api/v2/hooks/{id}"
payload = {
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"enabled": False,
"dependencies": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/hooks/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'my-hook',
'script' => 'module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };',
'enabled' => false,
'dependencies' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://{tenantDomain}/api/v2/hooks/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"enabled\": false,\n \"dependencies\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenantDomain}/api/v2/hooks/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"enabled\": false,\n \"dependencies\": {}\n}"
response = http.request(request)
puts response.read_body{
"triggerId": "<string>",
"id": "00001",
"name": "hook",
"enabled": true,
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {}
}Update a hook
Update an existing hook.
PATCH
https://{tenantDomain}/api/v2
/
hooks
/
{id}
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.UpdateHookRequestContent{}
client.Hooks.Update(
context.TODO(),
"id",
request,
)
}import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.update("id", {});
}
main();import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.update("id", {});
}
main();curl --request PATCH \
--url https://{tenantDomain}/api/v2/hooks/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"enabled": false,
"dependencies": {}
}
'import requests
url = "https://{tenantDomain}/api/v2/hooks/{id}"
payload = {
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"enabled": False,
"dependencies": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/hooks/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'my-hook',
'script' => 'module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };',
'enabled' => false,
'dependencies' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.patch("https://{tenantDomain}/api/v2/hooks/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"enabled\": false,\n \"dependencies\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenantDomain}/api/v2/hooks/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"enabled\": false,\n \"dependencies\": {}\n}"
response = http.request(request)
puts response.read_body{
"triggerId": "<string>",
"id": "00001",
"name": "hook",
"enabled": true,
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {}
}Authorizations
bearerAuthoAuth2ClientCredentials
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
ID of the hook to update.
Body
application/jsonapplication/x-www-form-urlencoded
Name of this hook.
Pattern:
^[a-zA-Z0-9]([ \-a-zA-Z0-9]*[a-zA-Z0-9])?$script
string
default:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
Code to be executed when this hook runs.
Minimum string length:
1Whether this hook will be executed (true) or ignored (false).
Dependencies of this hook used by webtask server.
Show child attributes
Show child attributes
Response
Hook successfully created.
Trigger ID
ID of this hook.
Name of this hook.
Whether this hook will be executed (true) or ignored (false).
script
string
default:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
Code to be executed when this hook runs.
Dependencies of this hook used by webtask server.
Show child attributes
Show child attributes
Was this page helpful?
⌘I