# Filters ## List filters **get** `/zones/{zone_id}/filters` Fetches filters in a zone. You can filter the results using several optional parameters. ### Path Parameters - `zone_id: string` Defines an identifier. ### Query Parameters - `id: optional string` The unique identifier of the filter. - `description: optional string` A case-insensitive string to find in the description. - `expression: optional string` A case-insensitive string to find in the expression. - `page: optional number` Page number of paginated results. - `paused: optional boolean` When true, indicates that the filter is currently paused. - `per_page: optional number` Number of filters per page. - `ref: optional string` The filter ref (a short reference tag) to search for. Must be an exact match. ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: array of FirewallFilter` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. - `success: true` Defines whether the API call was successful. - `true` - `result_info: optional { count, page, per_page, total_count }` - `count: optional number` Defines the total number of results for the requested service. - `page: optional number` Defines the current page within paginated list of results. - `per_page: optional number` Defines the number of results per page of results. - `total_count: optional number` Defines the total results available without any search parameters. ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" } } ], "result": [ { "id": "372e67954025e0ba6aaa6d586b9e0b61", "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get a filter **get** `/zones/{zone_id}/filters/{filter_id}` Fetches the details of a filter. ### Path Parameters - `zone_id: string` Defines an identifier. - `filter_id: string` The unique identifier of the filter. ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: FirewallFilter` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. - `success: true` Defines whether the API call was successful. - `true` ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters/$FILTER_ID \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" } } ], "result": { "id": "372e67954025e0ba6aaa6d586b9e0b61", "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" }, "success": true } ``` ## Create filters **post** `/zones/{zone_id}/filters` Creates one or more filters. ### Path Parameters - `zone_id: string` Defines an identifier. ### Body Parameters - `body: array of FirewallFilter` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: array of FirewallFilter` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. - `success: true` Defines whether the API call was successful. - `true` - `result_info: optional { count, page, per_page, total_count }` - `count: optional number` Defines the total number of results for the requested service. - `page: optional number` Defines the current page within paginated list of results. - `per_page: optional number` Defines the number of results per page of results. - `total_count: optional number` Defines the total results available without any search parameters. ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '[ { "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \\".*wp-login.php\\" or http.request.uri.path ~ \\".*xmlrpc.php\\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" } ]' ``` #### 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" } } ], "result": [ { "id": "372e67954025e0ba6aaa6d586b9e0b61", "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Update a filter **put** `/zones/{zone_id}/filters/{filter_id}` Updates an existing filter. ### Path Parameters - `zone_id: string` Defines an identifier. - `filter_id: string` The unique identifier of the filter. ### Body Parameters - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: FirewallFilter` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. - `success: true` Defines whether the API call was successful. - `true` ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters/$FILTER_ID \ -X PUT \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '{ "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \\".*wp-login.php\\" or http.request.uri.path ~ \\".*xmlrpc.php\\") and ip.addr ne 172.16.22.155", "ref": "FIL-100" }' ``` #### 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" } } ], "result": { "id": "372e67954025e0ba6aaa6d586b9e0b61", "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" }, "success": true } ``` ## Delete a filter **delete** `/zones/{zone_id}/filters/{filter_id}` Deletes an existing filter. ### Path Parameters - `zone_id: string` Defines an identifier. - `filter_id: string` The unique identifier of the filter. ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: { id }` - `id: string` The unique identifier of the filter. - `success: true` Defines whether the API call was successful. - `true` ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters/$FILTER_ID \ -X DELETE \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" } } ], "result": { "id": "372e67954025e0ba6aaa6d586b9e0b61" }, "success": true } ``` ## Update filters **put** `/zones/{zone_id}/filters` Updates one or more existing filters. ### Path Parameters - `zone_id: string` Defines an identifier. ### Body Parameters - `body: array of { id, description, expression, 2 more }` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: array of FirewallFilter` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. - `success: true` Defines whether the API call was successful. - `true` - `result_info: optional { count, page, per_page, total_count }` - `count: optional number` Defines the total number of results for the requested service. - `page: optional number` Defines the current page within paginated list of results. - `per_page: optional number` Defines the number of results per page of results. - `total_count: optional number` Defines the total results available without any search parameters. ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters \ -X PUT \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '[ { "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \\".*wp-login.php\\" or http.request.uri.path ~ \\".*xmlrpc.php\\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" } ]' ``` #### 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" } } ], "result": [ { "id": "372e67954025e0ba6aaa6d586b9e0b61", "description": "Restrict access from these browsers on this address range.", "expression": "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.addr ne 172.16.22.155", "paused": false, "ref": "FIL-100" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Delete filters **delete** `/zones/{zone_id}/filters` Deletes one or more existing filters. ### Path Parameters - `zone_id: string` Defines an identifier. ### Query Parameters - `id: array of string` ### Returns - `errors: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `pointer: optional string` - `messages: array of ResponseInfo` - `code: number` - `message: string` - `documentation_url: optional string` - `source: optional { pointer }` - `result: array of { id }` - `id: optional string` The unique identifier of the filter. - `success: true` Defines whether the API call was successful. - `true` - `result_info: optional { count, page, per_page, total_count }` - `count: optional number` Defines the total number of results for the requested service. - `page: optional number` Defines the current page within paginated list of results. - `per_page: optional number` Defines the number of results per page of results. - `total_count: optional number` Defines the total results available without any search parameters. ### Example ```http curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/filters \ -X DELETE \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" } } ], "result": [ { "id": "372e67954025e0ba6aaa6d586b9e0b61" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### Firewall Filter - `FirewallFilter { id, description, expression, 2 more }` - `id: optional string` The unique identifier of the filter. - `description: optional string` An informative summary of the filter. - `expression: optional string` The filter expression. For more information, refer to [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - `paused: optional boolean` When true, indicates that the filter is currently paused. - `ref: optional string` A short reference tag. Allows you to select related filters. ### Filter Delete Response - `FilterDeleteResponse { id }` - `id: string` The unique identifier of the filter. ### Filter Bulk Delete Response - `FilterBulkDeleteResponse = array of { id }` - `id: optional string` The unique identifier of the filter.