Update a payment rule
client.monetization.rules.editRule(stringruleID, RuleEditRuleParams { zone_id, address, description, 4 more } params, RequestOptionsoptions?): MonetizationRuleCollection { rules }
PATCH/zones/{zone_id}/monetization/rules/{rule_id}
Applies a partial update to a single Payment Required rule. Only the fields present in the request body are changed; omitted fields keep their current values. Returns the full resulting rule collection.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Update a payment rule
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const monetizationRuleCollection = await client.monetization.rules.editRule(
'023e105f4ecef8ad9ca31a8372d0c353',
{ zone_id: '9f1839b6152d298aca64c4e906b6d074' },
);
console.log(monetizationRuleCollection.rules);{
"errors": [
{
"code": 0,
"message": "message"
}
],
"messages": [
{
"code": 0,
"message": "message"
}
],
"result": {
"rules": [
{
"address": "0x1234567890abcdef1234567890abcdef12345678===",
"expression": "(http.request.uri.path eq \"/premium\" and http.request.method in {\"GET\" \"POST\"})",
"price": "250000",
"scheme": "exact",
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"description": "Premium API endpoint",
"enabled": true
}
]
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 0,
"message": "message"
}
],
"messages": [
{
"code": 0,
"message": "message"
}
],
"result": {
"rules": [
{
"address": "0x1234567890abcdef1234567890abcdef12345678===",
"expression": "(http.request.uri.path eq \"/premium\" and http.request.method in {\"GET\" \"POST\"})",
"price": "250000",
"scheme": "exact",
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"description": "Premium API endpoint",
"enabled": true
}
]
},
"success": true
}