Skip to content
Start here

Get a payment rule

monetization.rules.get_rule(strrule_id, RuleGetRuleParams**kwargs) -> MonetizationRule
GET/zones/{zone_id}/monetization/rules/{rule_id}

Returns a single Payment Required rule identified by its ID.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
ParametersExpand Collapse
zone_id: str

The unique ID of the zone.

rule_id: str
maxLength32
ReturnsExpand Collapse
Union[MonetizationRulesMonetizationRuleInputFixedPrice, MonetizationRulesMonetizationRuleInputOriginControlled]
One of the following:
class MonetizationRulesMonetizationRuleInputFixedPrice: …

Payment rule with a fixed price set at configuration time.

id: str

The server-assigned unique ID of the payment rule. Stable across full-ruleset replacements.

maxLength32
class MonetizationRulesMonetizationRuleInputOriginControlled: …

Payment rule whose price the origin server sets dynamically. The rule carries no price and the price field must be omitted — any provided value, including “0”, is rejected because it would not be enforced.

id: str

The server-assigned unique ID of the payment rule. Stable across full-ruleset replacements.

maxLength32

Get a payment rule

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
monetization_rule = client.monetization.rules.get_rule(
    rule_id="023e105f4ecef8ad9ca31a8372d0c353",
    zone_id="9f1839b6152d298aca64c4e906b6d074",
)
print(monetization_rule)
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "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": {
    "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
}