Skip to content

Commit 0c87b73

Browse files
committed
API placeholder guidelines
1 parent 060a1c6 commit 0c87b73

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/content/docs/style-guide/api-content-strategy/guidelines-for-curl-commands.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66

77
---
88

9-
Use long parameter names, like in the [API reference documentation](/api/), for clarity:
9+
Use long parameter names for clarity:
1010

1111
* `--header` (instead of `-H`)
1212
* `--request` (when needed, instead of `-X`)
@@ -33,7 +33,7 @@ If you must suggest the use of this tool, you can add a link to the [Make API ca
3333
### Preliminary notes
3434

3535
* Make sure not to use typographical or smart quotes in a cURL command, or the command will fail.
36-
* Placeholders in the URL should follow the same format as in the API documentation: `{zone_id}`
36+
* Placeholders in the URL should follow the same format as in the API documentation: `$ZONE_ID`
3737
* Placeholders in the request body (that is, the data included in a `POST`/`PUT`/`PATCH` request) should use this format: `<RULE_ID>`
3838

3939
The same placeholder name should correspond to the same value – use different placeholder names for different ID values. You can use the same request placeholders in the response, if they should match the values in the request.
@@ -43,19 +43,19 @@ The same placeholder name should correspond to the same value – use different
4343
If using Email + API Key authentication, include the following arguments in the cURL command to add the two required HTTP headers to the request:
4444

4545
```txt
46-
--header "X-Auth-Email: <EMAIL>" \
47-
--header "X-Auth-Key: <API_KEY>" \
46+
--header "X-Auth-Email: $CLOUDFLARE_EMAIL" \
47+
--header "X-Auth-Key: $CLOUDFLARE_API_KEY" \
4848
```
4949

5050
:::note
5151

52-
Ending slashes included to facilitate copy and paste. Do not include the last slash if this is the last line of the cURL command.
52+
Ending slashes included to facilitate copy and paste. Do not include the last slash if this is the last line of the cURL command.
5353
:::
5454

5555
If using API Token (the preferred authentication method), include the following arguments in the cURL command to add the required HTTP header to the request:
5656

5757
```txt
58-
--header "Authorization: Bearer <API_TOKEN>" \
58+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
5959
```
6060

6161
### Request without body content (`GET`, `DELETE`)
@@ -66,20 +66,20 @@ For `GET` requests, do not include the `--request GET` command-line argument, si
6666

6767
```txt
6868
curl {full_url_with_placeholders} \
69-
--header "Authorization: Bearer <API_TOKEN>"
69+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
7070
```
7171

7272
```bash title="Example"
73-
curl https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules \
74-
--header "Authorization: Bearer <API_TOKEN>"
73+
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/firewall/rules \
74+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
7575
```
7676

7777
#### `DELETE` request template
7878

7979
```txt
8080
curl --request DELETE \
8181
{full_url_with_placeholders} \
82-
--header "Authorization: Bearer <API_TOKEN>"
82+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
8383
```
8484

8585
Requests without a body do not need syntax highlight, but we use `bash` syntax highlighting to highlight the several delimited strings.
@@ -96,16 +96,16 @@ For `POST` requests with a body, do not include the `--request POST` command-lin
9696

9797
```txt
9898
curl {full_url_with_placeholders} \
99-
--header "Authorization: Bearer <API_TOKEN>" \
99+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
100100
--header "Content-Type: application/json" \
101101
--data '({|[)
102102
(...JSON content, pretty printed, using 2-space indents...)
103103
(}|])'
104104
```
105105

106106
```bash title="Example"
107-
curl https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules \
108-
--header "Authorization: Bearer <API_TOKEN>" \
107+
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/firewall/rules \
108+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
109109
--header "Content-Type: application/json" \
110110
--data '[
111111
{
@@ -123,7 +123,7 @@ curl https://api.cloudflare.com/client/v4/zones/{zone_id}/firewall/rules \
123123
```txt
124124
curl --request (PUT/PATCH) \
125125
{full_url_with_placeholders} \
126-
--header "Authorization: Bearer <API_TOKEN>" \
126+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
127127
--header "Content-Type: application/json" \
128128
--data '({|[)
129129
(...JSON content, pretty printed, using 2-space indents...)
@@ -141,8 +141,8 @@ The recommended way of escaping a single quote inside the body is the following
141141
Which means "close string, add escaped single quote, begin string again".
142142

143143
```bash title="Example"
144-
curl https://api.cloudflare.com/api/v4/zones/{zone_id}/page_shield/policies \
145-
--header "Authorization: Bearer <API_TOKEN>" \
144+
curl https://api.cloudflare.com/api/v4/zones/$ZONE_ID/page_shield/policies \
145+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
146146
--header "Content-Type: application/json" \
147147
--data '{
148148
"value": "script-src myapp.example.com cdnjs.cloudflare.com https://www.google-analytics.com/analytics.js '\''self'\''"
@@ -156,7 +156,7 @@ If you have a `POST` request without a body, you must add the `--request POST` a
156156
```txt
157157
curl --request POST \
158158
{full_url_with_placeholders} \
159-
--header "Authorization: Bearer <API_TOKEN>"
159+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
160160
```
161161

162162
### Additional information
@@ -166,8 +166,8 @@ Code blocks with example requests that include a JSON body should use `bash` syn
166166
### Full request example
167167

168168
```bash
169-
curl https://api.cloudflare.com/api/v4/zones/{zone_id}/page_shield/policies \
170-
--header "Authorization: Bearer <API_TOKEN>" \
169+
curl https://api.cloudflare.com/api/v4/zones/$ZONE_ID/page_shield/policies \
170+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
171171
--header "Content-Type: application/json" \
172172
--data '{
173173
"description": "My first policy in log mode",

0 commit comments

Comments
 (0)