Passer au contenu principal
PATCH
https://{tenantDomain}/api/v2
/
rules
/
{id}
C#
using Auth0.ManagementApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new ManagementClient(
            token: "<token>"
        );

        await client.Rules.UpdateAsync(
            id: "id",
            request: new UpdateRuleRequestContent()
        );
    }

}
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.UpdateRuleRequestContent{}
client.Rules.Update(
context.TODO(),
"id",
request,
)
}
package com.example.usage;

import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.resources.rules.requests.UpdateRuleRequestContent;

public class Example {
public static void main(String[] args) {
ManagementApi client = ManagementApi
.builder()
.token("<token>")
.build();

client.rules().update(
"id",
UpdateRuleRequestContent
.builder()
.build()
);
}
}
<?php

namespace Example;

use Auth0\SDK\API\Management\Management;
use Auth0\SDK\API\Management\Rules\Requests\UpdateRuleRequestContent;

$client = new Management(
token: '<token>',
);
$client->rules->update(
'id',
new UpdateRuleRequestContent([]),
);
from auth0.management import ManagementClient

client = ManagementClient(
token="<token>",
)

client.rules.update(
id="id",
)
require "auth0"

client = Auth0::Management.new(token: "<token>")

client.rules.update(id: "id")
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.rules.update("id", {});
}
main();
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.rules.update("id", {});
}
main();
curl --request PATCH \
--url https://{tenantDomain}/api/v2/rules/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"script": "function (user, context, callback) {\n callback(null, user, context);\n}",
"name": "my-rule",
"order": 2,
"enabled": true
}
'
{
  "name": "rule_1",
  "id": "con_0000000000000001",
  "enabled": true,
  "script": "function (user, context, callback) {\n  callback(null, user, context);\n}",
  "order": 1,
  "stage": "login_success"
}

Autorisations

Authorization
string
header
requis

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

Paramètres de chemin

id
string
requis

ID of the rule to retrieve.

Corps

script
string
défaut:function (user, context, callback) { callback(null, user, context); }

Code to be executed when this rule runs.

Minimum string length: 1
name
string
défaut:my-rule

Name of this rule.

Pattern: ^[a-zA-Z0-9]([ \-a-zA-Z0-9]*[a-zA-Z0-9])?$
order
number
défaut:2

Order that this rule should execute in relative to other rules. Lower-valued rules execute first.

Plage requise: x >= 0
enabled
boolean
défaut:true

Whether the rule is enabled (true), or disabled (false).

Réponse

Rule successfully updated.

name
string
défaut:rule_1

Name of this rule.

id
string
défaut:con_0000000000000001

ID of this rule.

enabled
boolean
défaut:true

Whether the rule is enabled (true), or disabled (false).

script
string
défaut:function (user, context, callback) { callback(null, user, context); }

Code to be executed when this rule runs.

order
number
défaut:1

Order that this rule should execute in relative to other rules. Lower-valued rules execute first.

stage
string
défaut:login_success

Execution stage of this rule. Can be login_success, login_failure, or pre_authorize.