# Rules Lists # Lists ## Get lists `rules.lists.list(ListListParams**kwargs) -> SyncSinglePage[ListsList]` **get** `/accounts/{account_id}/rules/lists` Fetches all lists in the account. ### Parameters - `account_id: str` The Account ID for this resource. ### Returns - `class ListsList: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.rules.lists.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.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" } } ], "result": [ { "id": "2c0fc9fa937b11eaa1b71c4d701ab86e", "created_on": "2020-01-01T08:00:00Z", "kind": "ip", "modified_on": "2020-01-10T14:00:00Z", "name": "list1", "num_items": 10, "num_referencing_filters": 2, "description": "This is a note" } ], "success": true } ``` ## Get a list `rules.lists.get(strlist_id, ListGetParams**kwargs) -> ListGetResponse` **get** `/accounts/{account_id}/rules/lists/{list_id}` Fetches the details of a list. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. ### Returns - `class ListGetResponse: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) list = client.rules.lists.get( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(list.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" } } ], "result": { "id": "2c0fc9fa937b11eaa1b71c4d701ab86e", "created_on": "2020-01-01T08:00:00Z", "kind": "ip", "modified_on": "2020-01-10T14:00:00Z", "name": "list1", "num_items": 10, "num_referencing_filters": 2, "description": "This is a note" }, "success": true } ``` ## Create a list `rules.lists.create(ListCreateParams**kwargs) -> ListCreateResponse` **post** `/accounts/{account_id}/rules/lists` Creates a new list of the specified kind. ### Parameters - `account_id: str` The Account ID for this resource. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `description: Optional[str]` An informative summary of the list. ### Returns - `class ListCreateResponse: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) list = client.rules.lists.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", kind="ip", name="list1", ) print(list.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" } } ], "result": { "id": "2c0fc9fa937b11eaa1b71c4d701ab86e", "created_on": "2020-01-01T08:00:00Z", "kind": "ip", "modified_on": "2020-01-10T14:00:00Z", "name": "list1", "num_items": 10, "num_referencing_filters": 2, "description": "This is a note" }, "success": true } ``` ## Update a list `rules.lists.update(strlist_id, ListUpdateParams**kwargs) -> ListUpdateResponse` **put** `/accounts/{account_id}/rules/lists/{list_id}` Updates the description of a list. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. - `description: Optional[str]` An informative summary of the list. ### Returns - `class ListUpdateResponse: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) list = client.rules.lists.update( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(list.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" } } ], "result": { "id": "2c0fc9fa937b11eaa1b71c4d701ab86e", "created_on": "2020-01-01T08:00:00Z", "kind": "ip", "modified_on": "2020-01-10T14:00:00Z", "name": "list1", "num_items": 10, "num_referencing_filters": 2, "description": "This is a note" }, "success": true } ``` ## Delete a list `rules.lists.delete(strlist_id, ListDeleteParams**kwargs) -> ListDeleteResponse` **delete** `/accounts/{account_id}/rules/lists/{list_id}` Deletes a specific list and all its items. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. ### Returns - `class ListDeleteResponse: …` - `id: str` The unique ID of the list. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) list = client.rules.lists.delete( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(list.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" } } ], "result": { "id": "2c0fc9fa937b11eaa1b71c4d701ab86e" }, "success": true } ``` ## Domain Types ### Hostname - `class Hostname: …` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. ### Lists List - `class ListsList: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### Redirect - `class Redirect: …` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` ### List Get Response - `class ListGetResponse: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### List Create Response - `class ListCreateResponse: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### List Update Response - `class ListUpdateResponse: …` - `id: str` The unique ID of the list. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `kind: Literal["ip", "redirect", "hostname", "asn"]` The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects). - `"ip"` - `"redirect"` - `"hostname"` - `"asn"` - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `name: str` An informative name for the list. Use this name in filter and rule expressions. - `num_items: float` The number of items in the list. - `num_referencing_filters: float` The number of [filters](/api/resources/filters/) referencing the list. - `description: Optional[str]` An informative summary of the list. ### List Delete Response - `class ListDeleteResponse: …` - `id: str` The unique ID of the list. # Bulk Operations ## Get bulk operation status `rules.lists.bulk_operations.get(stroperation_id, BulkOperationGetParams**kwargs) -> BulkOperationGetResponse` **get** `/accounts/{account_id}/rules/lists/bulk_operations/{operation_id}` Gets the current status of an asynchronous operation on a list. The `status` property can have one of the following values: `pending`, `running`, `completed`, or `failed`. If the status is `failed`, the `error` property will contain a message describing the error. ### Parameters - `account_id: str` The Account ID for this resource. - `operation_id: str` The unique operation ID of the asynchronous action. ### Returns - `BulkOperationGetResponse` - `class ListsBulkOperationPendingOrRunning: …` - `id: str` The unique operation ID of the asynchronous action. - `status: Literal["pending", "running"]` The current status of the asynchronous operation. - `"pending"` - `"running"` - `class ListsBulkOperationCompleted: …` - `id: str` The unique operation ID of the asynchronous action. - `completed: str` The RFC 3339 timestamp of when the operation was completed. - `status: Literal["completed"]` The current status of the asynchronous operation. - `"completed"` - `class ListsBulkOperationFailed: …` - `id: str` The unique operation ID of the asynchronous action. - `completed: str` The RFC 3339 timestamp of when the operation was completed. - `error: str` A message describing the error when the status is `failed`. - `status: Literal["failed"]` The current status of the asynchronous operation. - `"failed"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) bulk_operation = client.rules.lists.bulk_operations.get( operation_id="4da8780eeb215e6cb7f48dd981c4ea02", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(bulk_operation) ``` #### 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": "4da8780eeb215e6cb7f48dd981c4ea02", "status": "pending" }, "success": true } ``` ## Domain Types ### Bulk Operation Get Response - `BulkOperationGetResponse` - `class ListsBulkOperationPendingOrRunning: …` - `id: str` The unique operation ID of the asynchronous action. - `status: Literal["pending", "running"]` The current status of the asynchronous operation. - `"pending"` - `"running"` - `class ListsBulkOperationCompleted: …` - `id: str` The unique operation ID of the asynchronous action. - `completed: str` The RFC 3339 timestamp of when the operation was completed. - `status: Literal["completed"]` The current status of the asynchronous operation. - `"completed"` - `class ListsBulkOperationFailed: …` - `id: str` The unique operation ID of the asynchronous action. - `completed: str` The RFC 3339 timestamp of when the operation was completed. - `error: str` A message describing the error when the status is `failed`. - `status: Literal["failed"]` The current status of the asynchronous operation. - `"failed"` # Items ## Get list items `rules.lists.items.list(strlist_id, ItemListParams**kwargs) -> SyncCursorPaginationAfter[ItemListResponse]` **get** `/accounts/{account_id}/rules/lists/{list_id}/items` Fetches all the items in the list. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. - `cursor: Optional[str]` The pagination cursor. An opaque string token indicating the position from which to continue when requesting the next/previous set of records. Cursor values are provided under `result_info.cursors` in the response. You should make no assumptions about a cursor's content or length. - `per_page: Optional[int]` Amount of results to include in each paginated response. A non-negative 32 bit integer. - `search: Optional[str]` A search query to filter returned items. Its meaning depends on the list type: IP addresses must start with the provided string, hostnames and bulk redirects must contain the string, and ASNs must match the string exactly. ### Returns - `ItemListResponse` - `class ListsListItemIPFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `ip: str` An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemHostnameFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `hostname: Hostname` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemRedirectFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `redirect: Redirect` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemASNFull: …` - `id: str` Defines the unique ID of the item in the List. - `asn: int` Defines a non-negative 32 bit integer. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.rules.lists.items.list( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page) ``` #### 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": "34b12448945f11eaa1b71c4d701ab86e", "created_on": "2020-01-01T08:00:00Z", "ip": "10.0.0.1", "modified_on": "2020-01-10T14:00:00Z", "comment": "Private IP address" } ], "success": true, "result_info": { "cursors": { "after": "yyy", "before": "xxx" } } } ``` ## Get a list item `rules.lists.items.get(stritem_id, ItemGetParams**kwargs) -> ItemGetResponse` **get** `/accounts/{account_id}/rules/lists/{list_id}/items/{item_id}` Fetches a list item in the list. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. - `item_id: str` Defines the unique ID of the item in the List. ### Returns - `ItemGetResponse` - `class ListsListItemIPFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `ip: str` An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemHostnameFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `hostname: Hostname` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemRedirectFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `redirect: Redirect` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemASNFull: …` - `id: str` Defines the unique ID of the item in the List. - `asn: int` Defines a non-negative 32 bit integer. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) item = client.rules.lists.items.get( item_id="34b12448945f11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", ) print(item) ``` #### 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": "34b12448945f11eaa1b71c4d701ab86e", "created_on": "2020-01-01T08:00:00Z", "ip": "10.0.0.1", "modified_on": "2020-01-10T14:00:00Z", "comment": "Private IP address" }, "success": true } ``` ## Create list items `rules.lists.items.create(strlist_id, ItemCreateParams**kwargs) -> ItemCreateResponse` **post** `/accounts/{account_id}/rules/lists/{list_id}/items` Appends new items to the list. This operation is asynchronous. To get current the operation status, invoke the `Get bulk operation status` endpoint with the returned `operation_id`. There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. - `body: Iterable[Body]` - `class BodyListsListItemIPComment: …` - `ip: str` An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR. - `comment: Optional[str]` Defines an informative summary of the list item. - `class BodyListsListItemRedirectComment: …` - `redirect: RedirectParam` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` - `comment: Optional[str]` Defines an informative summary of the list item. - `class BodyListsListItemHostnameComment: …` - `hostname: HostnameParam` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. - `comment: Optional[str]` Defines an informative summary of the list item. - `class BodyListsListItemASNComment: …` - `asn: int` Defines a non-negative 32 bit integer. - `comment: Optional[str]` Defines an informative summary of the list item. ### Returns - `class ItemCreateResponse: …` - `operation_id: str` The unique operation ID of the asynchronous action. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) item = client.rules.lists.items.create( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", body=[{ "ip": "10.0.0.1" }], ) print(item.operation_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" } } ], "result": { "operation_id": "4da8780eeb215e6cb7f48dd981c4ea02" }, "success": true } ``` ## Update all list items `rules.lists.items.update(strlist_id, ItemUpdateParams**kwargs) -> ItemUpdateResponse` **put** `/accounts/{account_id}/rules/lists/{list_id}/items` Removes all existing items from the list and adds the provided items to the list. This operation is asynchronous. To get current the operation status, invoke the `Get bulk operation status` endpoint with the returned `operation_id`. There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. - `body: Iterable[Body]` - `class BodyListsListItemIPComment: …` - `ip: str` An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR. - `comment: Optional[str]` Defines an informative summary of the list item. - `class BodyListsListItemRedirectComment: …` - `redirect: RedirectParam` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` - `comment: Optional[str]` Defines an informative summary of the list item. - `class BodyListsListItemHostnameComment: …` - `hostname: HostnameParam` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. - `comment: Optional[str]` Defines an informative summary of the list item. - `class BodyListsListItemASNComment: …` - `asn: int` Defines a non-negative 32 bit integer. - `comment: Optional[str]` Defines an informative summary of the list item. ### Returns - `class ItemUpdateResponse: …` - `operation_id: str` The unique operation ID of the asynchronous action. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) item = client.rules.lists.items.update( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", body=[{ "ip": "10.0.0.1" }], ) print(item.operation_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" } } ], "result": { "operation_id": "4da8780eeb215e6cb7f48dd981c4ea02" }, "success": true } ``` ## Delete list items `rules.lists.items.delete(strlist_id, ItemDeleteParams**kwargs) -> ItemDeleteResponse` **delete** `/accounts/{account_id}/rules/lists/{list_id}/items` Removes one or more items from a list. This operation is asynchronous. To get current the operation status, invoke the `Get bulk operation status` endpoint with the returned `operation_id`. There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected. ### Parameters - `account_id: str` The Account ID for this resource. - `list_id: str` The unique ID of the list. - `items: Optional[Iterable[Item]]` - `id: str` Defines the unique ID of the item in the List. ### Returns - `class ItemDeleteResponse: …` - `operation_id: str` The unique operation ID of the asynchronous action. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) item = client.rules.lists.items.delete( list_id="2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(item.operation_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" } } ], "result": { "operation_id": "4da8780eeb215e6cb7f48dd981c4ea02" }, "success": true } ``` ## Domain Types ### List Cursor - `class ListCursor: …` - `after: Optional[str]` - `before: Optional[str]` ### List Item - `class ListItem: …` - `operation_id: str` The unique operation ID of the asynchronous action. ### Item List Response - `ItemListResponse` - `class ListsListItemIPFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `ip: str` An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemHostnameFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `hostname: Hostname` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemRedirectFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `redirect: Redirect` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemASNFull: …` - `id: str` Defines the unique ID of the item in the List. - `asn: int` Defines a non-negative 32 bit integer. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. ### Item Get Response - `ItemGetResponse` - `class ListsListItemIPFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `ip: str` An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemHostnameFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `hostname: Hostname` Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-). - `url_hostname: str` - `exclude_exact_hostname: Optional[bool]` Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemRedirectFull: …` - `id: str` Defines the unique ID of the item in the List. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `redirect: Redirect` The definition of the redirect. - `source_url: str` - `target_url: str` - `include_subdomains: Optional[bool]` - `preserve_path_suffix: Optional[bool]` - `preserve_query_string: Optional[bool]` - `status_code: Optional[Literal[301, 302, 307, 308]]` - `301` - `302` - `307` - `308` - `subpath_matching: Optional[bool]` - `comment: Optional[str]` Defines an informative summary of the list item. - `class ListsListItemASNFull: …` - `id: str` Defines the unique ID of the item in the List. - `asn: int` Defines a non-negative 32 bit integer. - `created_on: str` The RFC 3339 timestamp of when the list was created. - `modified_on: str` The RFC 3339 timestamp of when the list was last modified. - `comment: Optional[str]` Defines an informative summary of the list item. ### Item Create Response - `class ItemCreateResponse: …` - `operation_id: str` The unique operation ID of the asynchronous action. ### Item Update Response - `class ItemUpdateResponse: …` - `operation_id: str` The unique operation ID of the asynchronous action. ### Item Delete Response - `class ItemDeleteResponse: …` - `operation_id: str` The unique operation ID of the asynchronous action.