# Rules ## List Waiting Room Rules `client.waitingRooms.rules.get(stringwaitingRoomId, RuleGetParamsparams, RequestOptionsoptions?): SinglePage` **get** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Lists rules for a waiting room. ### Parameters - `waitingRoomId: string` - `params: RuleGetParams` - `zone_id: string` Identifier. ### Returns - `WaitingRoomRule` - `id?: string` The ID of the rule. - `action?: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. - `expression?: string` Criteria defining when there is a match for the current rule. - `last_updated?: string` - `version?: string` The version of the rule. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const waitingRoomRule of client.waitingRooms.rules.get( '699d98642c564d2e855e9661899b7252', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, )) { console.log(waitingRoomRule.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": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Create Waiting Room Rule `client.waitingRooms.rules.create(stringwaitingRoomId, RuleCreateParamsparams, RequestOptionsoptions?): SinglePage` **post** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Only available for the Waiting Room Advanced subscription. Creates a rule for a waiting room. ### Parameters - `waitingRoomId: string` - `params: RuleCreateParams` - `zone_id: string` Path param: Identifier. - `rules: Rules` Body param - `action: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `expression: string` Criteria defining when there is a match for the current rule. - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. ### Returns - `WaitingRoomRule` - `id?: string` The ID of the rule. - `action?: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. - `expression?: string` Criteria defining when there is a match for the current rule. - `last_updated?: string` - `version?: string` The version of the rule. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const waitingRoomRule of client.waitingRooms.rules.create( '699d98642c564d2e855e9661899b7252', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', rules: { action: 'bypass_waiting_room', expression: 'ip.src in {10.20.30.40}' }, }, )) { console.log(waitingRoomRule.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": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Replace Waiting Room Rules `client.waitingRooms.rules.update(stringwaitingRoomId, RuleUpdateParamsparams, RequestOptionsoptions?): SinglePage` **put** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Only available for the Waiting Room Advanced subscription. Replaces all rules for a waiting room. ### Parameters - `waitingRoomId: string` - `params: RuleUpdateParams` - `zone_id: string` Path param: Identifier. - `rules: Array` Body param - `action: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `expression: string` Criteria defining when there is a match for the current rule. - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. ### Returns - `WaitingRoomRule` - `id?: string` The ID of the rule. - `action?: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. - `expression?: string` Criteria defining when there is a match for the current rule. - `last_updated?: string` - `version?: string` The version of the rule. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const waitingRoomRule of client.waitingRooms.rules.update( '699d98642c564d2e855e9661899b7252', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', rules: [{ action: 'bypass_waiting_room', expression: 'ip.src in {10.20.30.40}' }], }, )) { console.log(waitingRoomRule.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": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Patch Waiting Room Rule `client.waitingRooms.rules.edit(stringwaitingRoomId, stringruleId, RuleEditParamsparams, RequestOptionsoptions?): SinglePage` **patch** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}` Patches a rule for a waiting room. ### Parameters - `waitingRoomId: string` - `ruleId: string` The ID of the rule. - `params: RuleEditParams` - `zone_id: string` Path param: Identifier. - `action: "bypass_waiting_room"` Body param: The action to take when the expression matches. - `"bypass_waiting_room"` - `expression: string` Body param: Criteria defining when there is a match for the current rule. - `description?: string` Body param: The description of the rule. - `enabled?: boolean` Body param: When set to true, the rule is enabled. - `position?: Index | Before | After` Body param: Reorder the position of a rule - `Index` - `index?: number` Places the rule in the exact position specified by the integer number . Position numbers start with 1. Existing rules in the ruleset from the specified position number onward are shifted one position (no rule is overwritten). - `Before` - `before?: string` Places the rule before rule . Use this argument with an empty rule ID value ("") to set the rule as the first rule in the ruleset. - `After` - `after?: string` Places the rule after rule . Use this argument with an empty rule ID value ("") to set the rule as the last rule in the ruleset. ### Returns - `WaitingRoomRule` - `id?: string` The ID of the rule. - `action?: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. - `expression?: string` Criteria defining when there is a match for the current rule. - `last_updated?: string` - `version?: string` The version of the rule. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const waitingRoomRule of client.waitingRooms.rules.edit( '699d98642c564d2e855e9661899b7252', '25756b2dfe6e378a06b033b670413757', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', action: 'bypass_waiting_room', expression: 'ip.src in {10.20.30.40}', }, )) { console.log(waitingRoomRule.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": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Delete Waiting Room Rule `client.waitingRooms.rules.delete(stringwaitingRoomId, stringruleId, RuleDeleteParamsparams, RequestOptionsoptions?): SinglePage` **delete** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}` Deletes a rule for a waiting room. ### Parameters - `waitingRoomId: string` - `ruleId: string` The ID of the rule. - `params: RuleDeleteParams` - `zone_id: string` Identifier. ### Returns - `WaitingRoomRule` - `id?: string` The ID of the rule. - `action?: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. - `expression?: string` Criteria defining when there is a match for the current rule. - `last_updated?: string` - `version?: string` The version of the rule. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const waitingRoomRule of client.waitingRooms.rules.delete( '699d98642c564d2e855e9661899b7252', '25756b2dfe6e378a06b033b670413757', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, )) { console.log(waitingRoomRule.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": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### Waiting Room Rule - `WaitingRoomRule` - `id?: string` The ID of the rule. - `action?: "bypass_waiting_room"` The action to take when the expression matches. - `"bypass_waiting_room"` - `description?: string` The description of the rule. - `enabled?: boolean` When set to true, the rule is enabled. - `expression?: string` Criteria defining when there is a match for the current rule. - `last_updated?: string` - `version?: string` The version of the rule.