List Zero Trust Gateway rules
List Zero Trust Gateway rules for an account.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Query Parameters
Filter the returned rules by one or more field:value pairs. Repeat the
parameter to combine filters with logical AND.
Supported fields are name, id, action, enabled, source_account,
is_shared, filters, and expression (max 1024 bytes). The source_account
value is matched as a normalized UUID substring. The filters value must
be one of the rule filter names and matches a member of the rule’s filters
array. The expression filter performs a case-insensitive literal
substring match across traffic, identity, and device posture expressions.
List Zero Trust Gateway rules
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"{
"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": [
{
"action": "allow",
"enabled": true,
"filters": [
"http"
],
"name": "block bad websites",
"precedence": 0,
"traffic": "http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10",
"id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
"created_at": "2014-01-01T05:20:00.12345Z",
"deleted_at": "2019-12-27T18:11:19.117Z",
"description": "Block bad websites based on their host name.",
"device_posture": "any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})",
"expiration": {
"expires_at": "2014-01-01T05:20:20Z",
"duration": 10,
"expired": false
},
"identity": "any(identity.groups.name[*] in {\"finance\"})",
"read_only": true,
"rule_settings": {
"add_headers": {
"My-Next-Header": [
"foo",
"bar"
],
"X-Custom-Header-Name": [
"somecustomvalue"
]
},
"allow_child_bypass": false,
"audit_ssh": {
"command_logging": false
},
"biso_admin_controls": {
"copy": "remote_only",
"dcp": true,
"dd": true,
"dk": true,
"download": "enabled",
"dp": false,
"du": true,
"keyboard": "enabled",
"paste": "enabled",
"printing": "enabled",
"upload": "enabled",
"version": "v1",
"wm_id": "475345dc-5299-4b6e-8f6a-3d3e4c8e9f1a"
},
"block_page": {
"target_uri": "https://example.com",
"include_context": true
},
"block_page_enabled": true,
"block_reason": "This website is a security risk",
"bypass_parent_rule": false,
"check_session": {
"duration": "300s",
"enforce": true
},
"delete_headers": [
"X-Old-Header",
"X-Remove-Me"
],
"dns_resolvers": {
"ipv4": [
{
"ip": "2.2.2.2",
"port": 5053,
"route_through_private_network": true,
"vnet_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
}
],
"ipv6": [
{
"ip": "2001:DB8::",
"port": 5053,
"route_through_private_network": true,
"vnet_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
}
]
},
"egress": {
"ipv4": "192.0.2.2",
"ipv4_fallback": "192.0.2.3",
"ipv6": "2001:DB8::/64"
},
"forensic_copy": {
"enabled": true
},
"ignore_cname_category_matches": true,
"insecure_disable_dnssec_validation": false,
"ip_categories": true,
"ip_indicator_feeds": true,
"l4override": {
"ip": "1.1.1.1",
"port": 0
},
"notification_settings": {
"enabled": true,
"include_context": true,
"msg": "msg",
"support_url": "support_url"
},
"override_host": "example.com",
"override_ips": [
"1.1.1.1",
"2.2.2.2"
],
"payload_log": {
"enabled": true
},
"quarantine": {
"file_types": [
"exe"
]
},
"redirect": {
"target_uri": "https://example.com",
"include_context": true,
"preserve_path_and_query": true
},
"resolve_dns_internally": {
"fallback": "none",
"view_id": "view_id"
},
"resolve_dns_through_cloudflare": true,
"set_headers": {
"X-User-Identity": [
"user=@{identity.name}"
]
},
"untrusted_cert": {
"action": "error"
}
},
"schedule": {
"fri": "08:00-12:30,13:30-17:00",
"mon": "08:00-12:30,13:30-17:00",
"sat": "08:00-12:30,13:30-17:00",
"sun": "08:00-12:30,13:30-17:00",
"thu": "08:00-12:30,13:30-17:00",
"time_zone": "America/New York",
"tue": "08:00-12:30,13:30-17:00",
"wed": "08:00-12:30,13:30-17:00"
},
"sharable": true,
"source_account": "source_account",
"updated_at": "2014-01-01T05:20:00.12345Z",
"version": 1,
"warning_status": "warning_status"
}
],
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000
}
}Returns Examples
{
"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": [
{
"action": "allow",
"enabled": true,
"filters": [
"http"
],
"name": "block bad websites",
"precedence": 0,
"traffic": "http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10",
"id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
"created_at": "2014-01-01T05:20:00.12345Z",
"deleted_at": "2019-12-27T18:11:19.117Z",
"description": "Block bad websites based on their host name.",
"device_posture": "any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})",
"expiration": {
"expires_at": "2014-01-01T05:20:20Z",
"duration": 10,
"expired": false
},
"identity": "any(identity.groups.name[*] in {\"finance\"})",
"read_only": true,
"rule_settings": {
"add_headers": {
"My-Next-Header": [
"foo",
"bar"
],
"X-Custom-Header-Name": [
"somecustomvalue"
]
},
"allow_child_bypass": false,
"audit_ssh": {
"command_logging": false
},
"biso_admin_controls": {
"copy": "remote_only",
"dcp": true,
"dd": true,
"dk": true,
"download": "enabled",
"dp": false,
"du": true,
"keyboard": "enabled",
"paste": "enabled",
"printing": "enabled",
"upload": "enabled",
"version": "v1",
"wm_id": "475345dc-5299-4b6e-8f6a-3d3e4c8e9f1a"
},
"block_page": {
"target_uri": "https://example.com",
"include_context": true
},
"block_page_enabled": true,
"block_reason": "This website is a security risk",
"bypass_parent_rule": false,
"check_session": {
"duration": "300s",
"enforce": true
},
"delete_headers": [
"X-Old-Header",
"X-Remove-Me"
],
"dns_resolvers": {
"ipv4": [
{
"ip": "2.2.2.2",
"port": 5053,
"route_through_private_network": true,
"vnet_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
}
],
"ipv6": [
{
"ip": "2001:DB8::",
"port": 5053,
"route_through_private_network": true,
"vnet_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
}
]
},
"egress": {
"ipv4": "192.0.2.2",
"ipv4_fallback": "192.0.2.3",
"ipv6": "2001:DB8::/64"
},
"forensic_copy": {
"enabled": true
},
"ignore_cname_category_matches": true,
"insecure_disable_dnssec_validation": false,
"ip_categories": true,
"ip_indicator_feeds": true,
"l4override": {
"ip": "1.1.1.1",
"port": 0
},
"notification_settings": {
"enabled": true,
"include_context": true,
"msg": "msg",
"support_url": "support_url"
},
"override_host": "example.com",
"override_ips": [
"1.1.1.1",
"2.2.2.2"
],
"payload_log": {
"enabled": true
},
"quarantine": {
"file_types": [
"exe"
]
},
"redirect": {
"target_uri": "https://example.com",
"include_context": true,
"preserve_path_and_query": true
},
"resolve_dns_internally": {
"fallback": "none",
"view_id": "view_id"
},
"resolve_dns_through_cloudflare": true,
"set_headers": {
"X-User-Identity": [
"user=@{identity.name}"
]
},
"untrusted_cert": {
"action": "error"
}
},
"schedule": {
"fri": "08:00-12:30,13:30-17:00",
"mon": "08:00-12:30,13:30-17:00",
"sat": "08:00-12:30,13:30-17:00",
"sun": "08:00-12:30,13:30-17:00",
"thu": "08:00-12:30,13:30-17:00",
"time_zone": "America/New York",
"tue": "08:00-12:30,13:30-17:00",
"wed": "08:00-12:30,13:30-17:00"
},
"sharable": true,
"source_account": "source_account",
"updated_at": "2014-01-01T05:20:00.12345Z",
"version": 1,
"warning_status": "warning_status"
}
],
"result_info": {
"count": 1,
"page": 1,
"per_page": 20,
"total_count": 2000
}
}