Skip to content

Commit b57c93d

Browse files
committed
Add DNS API example
1 parent 4844691 commit b57c93d

File tree

1 file changed

+15
-35
lines changed

1 file changed

+15
-35
lines changed

src/content/partials/cloudflare-one/gateway/get-started/create-dns-policy.mdx

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,30 @@ import { Render, Tabs, TabItem } from "~/components";
2121

2222
<TabItem label="API">
2323

24-
1. Create a custom API token with the following permissions:
24+
1. [Create an API token](/fundamentals/api/get-started/create-token/) with the following permissions:
2525

26-
| Scope | Application | Action |
27-
| ------- | ----------- | ------ |
28-
| Account | Zero Trust | Edit |
26+
| Type | Item | Permission |
27+
| ------- | ---------- | ---------- |
28+
| Account | Zero Trust | Edit |
2929

30-
2. (Optional) Configure your API environment variables with your account ID, email address, and API token.
31-
3. Send a `POST` request to the [Create a Zero Trust Gateway rule](/api/operations/zero-trust-gateway-rules-create-zero-trust-gateway-rule) endpoint:
30+
2. (Optional) Configure your API environment variables to include your [account ID](/fundamentals/setup/find-account-and-zone-ids/), email address, and API token.
31+
3. Send a `POST` request to the [Create a Zero Trust Gateway rule](/api/operations/zero-trust-gateway-rules-create-zero-trust-gateway-rule) endpoint. For example, we recommend adding a policy to block all [security categories](/cloudflare-one/policies/gateway/domain-categories/#security-categories):
3232

33-
```bash
33+
```bash title="curl API example"
3434
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
35-
--header "X-Auth-Email: <EMAIL>" \
36-
--header "X-Auth-Key: <API_KEY>" \
37-
--header "Content-Type: application/json" \
38-
--data '{
39-
"action": "allow",
40-
"description": "Lisbon team access rule",
35+
--header "X-Auth-Email: <EMAIL>" \
36+
--header "X-Auth-Key: <API_KEY>" \
37+
--data '{
38+
"action": "allow",
39+
"name": "Block security risks",
40+
"description": "Block all default Cloudflare security categories",
4141
"device_posture": "any(device_posture.checks.passed[*] in {})",
4242
"enabled": true,
43-
"expiration": {
44-
"duration": 10,
45-
"expired": false,
46-
"expires_at": "2014-01-01T05:20:20Z"
47-
},
4843
"filters": [
49-
"http"
44+
"dns"
5045
],
51-
"identity": "any(identity.groups.name[*] in {\"Lisbon-team\"})",
52-
"name": "Lisbon Team Access Rule",
5346
"precedence": 0,
54-
"rule_settings": {
55-
"allow_child_bypass": false
56-
},
57-
"schedule": {
58-
"fri": "08:00-12:30,13:30-17:00",
59-
"mon": "08:00-12:30,13:30-17:00",
60-
"sat": "08:00-12:30,13:30-17:00",
61-
"sun": "08:00-12:30,13:30-17:00",
62-
"thu": "08:00-12:30,13:30-17:00",
63-
"time_zone": "America/New York",
64-
"tue": "08:00-12:30,13:30-17:00",
65-
"wed": "08:00-12:30,13:30-17:00"
66-
},
67-
"traffic": "http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10"
47+
"traffic": "any(dns.security_category[*] in {68 178 80 83 176 175 117 131 134 151 153})"
6848
}'
6949
```
7050

0 commit comments

Comments
 (0)