# Rules ## List rules in Web Analytics ruleset `client.rum.rules.list(stringrulesetId, RuleListParamsparams, RequestOptionsoptions?): RuleListResponse` **get** `/accounts/{account_id}/rum/v2/{ruleset_id}/rules` Lists all the rules in a Web Analytics ruleset. ### Parameters - `rulesetId: string` The Web Analytics ruleset identifier. - `params: RuleListParams` - `account_id: string` Identifier. ### Returns - `RuleListResponse` - `rules?: Array` A list of rules. - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` - `ruleset?: Ruleset` - `id?: string` The Web Analytics ruleset identifier. - `enabled?: boolean` Whether the ruleset is enabled. - `zone_name?: string` - `zone_tag?: string` The zone identifier. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const rules = await client.rum.rules.list('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(rules.rules); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "rules": [ { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "created": "2014-01-01T05:20:00.12345Z", "host": "example.com", "inclusive": true, "is_paused": false, "paths": [ "*" ], "priority": 1000 } ], "ruleset": { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "enabled": true, "zone_name": "example.com", "zone_tag": "023e105f4ecef8ad9ca31a8372d0c353" } } } ``` ## Create a Web Analytics rule `client.rum.rules.create(stringrulesetId, RuleCreateParamsparams, RequestOptionsoptions?): RUMRule` **post** `/accounts/{account_id}/rum/v2/{ruleset_id}/rule` Creates a new rule in a Web Analytics ruleset. ### Parameters - `rulesetId: string` The Web Analytics ruleset identifier. - `params: RuleCreateParams` - `account_id: string` Path param: Identifier. - `host?: string` Body param - `inclusive?: boolean` Body param: Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Body param: Whether the rule is paused or not. - `paths?: Array` Body param ### Returns - `RUMRule` - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const rumRule = await client.rum.rules.create('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(rumRule.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "created": "2014-01-01T05:20:00.12345Z", "host": "example.com", "inclusive": true, "is_paused": false, "paths": [ "*" ], "priority": 1000 } } ``` ## Update a Web Analytics rule `client.rum.rules.update(stringrulesetId, stringruleId, RuleUpdateParamsparams, RequestOptionsoptions?): RUMRule` **put** `/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}` Updates a rule in a Web Analytics ruleset. ### Parameters - `rulesetId: string` The Web Analytics ruleset identifier. - `ruleId: string` The Web Analytics rule identifier. - `params: RuleUpdateParams` - `account_id: string` Path param: Identifier. - `host?: string` Body param - `inclusive?: boolean` Body param: Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Body param: Whether the rule is paused or not. - `paths?: Array` Body param ### Returns - `RUMRule` - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const rumRule = await client.rum.rules.update( 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(rumRule.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "created": "2014-01-01T05:20:00.12345Z", "host": "example.com", "inclusive": true, "is_paused": false, "paths": [ "*" ], "priority": 1000 } } ``` ## Delete a Web Analytics rule `client.rum.rules.delete(stringrulesetId, stringruleId, RuleDeleteParamsparams, RequestOptionsoptions?): RuleDeleteResponse` **delete** `/accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}` Deletes an existing rule from a Web Analytics ruleset. ### Parameters - `rulesetId: string` The Web Analytics ruleset identifier. - `ruleId: string` The Web Analytics rule identifier. - `params: RuleDeleteParams` - `account_id: string` Identifier. ### Returns - `RuleDeleteResponse` - `id?: string` The Web Analytics rule identifier. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const rule = await client.rum.rules.delete( 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(rule.id); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415" } } ``` ## Update Web Analytics rules `client.rum.rules.bulkCreate(stringrulesetId, RuleBulkCreateParamsparams, RequestOptionsoptions?): RuleBulkCreateResponse` **post** `/accounts/{account_id}/rum/v2/{ruleset_id}/rules` Modifies one or more rules in a Web Analytics ruleset with a single request. ### Parameters - `rulesetId: string` The Web Analytics ruleset identifier. - `params: RuleBulkCreateParams` - `account_id: string` Path param: Identifier. - `delete_rules?: Array` Body param: A list of rule identifiers to delete. - `rules?: Array` Body param: A list of rules to create or update. - `id?: string` The Web Analytics rule identifier. - `host?: string` - `inclusive?: boolean` - `is_paused?: boolean` - `paths?: Array` ### Returns - `RuleBulkCreateResponse` - `rules?: Array` A list of rules. - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` - `ruleset?: Ruleset` - `id?: string` The Web Analytics ruleset identifier. - `enabled?: boolean` Whether the ruleset is enabled. - `zone_name?: string` - `zone_tag?: string` The zone identifier. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.rum.rules.bulkCreate('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(response.rules); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "rules": [ { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "created": "2014-01-01T05:20:00.12345Z", "host": "example.com", "inclusive": true, "is_paused": false, "paths": [ "*" ], "priority": 1000 } ], "ruleset": { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "enabled": true, "zone_name": "example.com", "zone_tag": "023e105f4ecef8ad9ca31a8372d0c353" } } } ``` ## Domain Types ### RUM Rule - `RUMRule` - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` ### Rule List Response - `RuleListResponse` - `rules?: Array` A list of rules. - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` - `ruleset?: Ruleset` - `id?: string` The Web Analytics ruleset identifier. - `enabled?: boolean` Whether the ruleset is enabled. - `zone_name?: string` - `zone_tag?: string` The zone identifier. ### Rule Delete Response - `RuleDeleteResponse` - `id?: string` The Web Analytics rule identifier. ### Rule Bulk Create Response - `RuleBulkCreateResponse` - `rules?: Array` A list of rules. - `id?: string` The Web Analytics rule identifier. - `created?: string` - `host?: string` The hostname the rule will be applied to. - `inclusive?: boolean` Whether the rule includes or excludes traffic from being measured. - `is_paused?: boolean` Whether the rule is paused or not. - `paths?: Array` The paths the rule will be applied to. - `priority?: number` - `ruleset?: Ruleset` - `id?: string` The Web Analytics ruleset identifier. - `enabled?: boolean` Whether the ruleset is enabled. - `zone_name?: string` - `zone_tag?: string` The zone identifier.