Skip to content

Commit 3c08119

Browse files
Adds APIRequest to WR docs (#23232)
1 parent a8e01b0 commit 3c08119

File tree

6 files changed

+123
-96
lines changed

6 files changed

+123
-96
lines changed

src/content/docs/waiting-room/additional-options/embed-waiting-room-in-iframe.mdx

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

77
---
88

9-
import { Details } from "~/components"
9+
import { Details, APIRequest } from "~/components"
1010

1111
Because of how a waiting room [tracks visitor progress](#background), you need to [specify certain cookie attributes](#allow-cookies-to-pass-through-iframes) to properly embed a waiting room in an iFrame.
1212

@@ -47,28 +47,27 @@ If you are embedding a waiting room in an iFrame, specify the following values o
4747

4848
<Details header="Request">
4949

50-
```bash
51-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/waiting_rooms" \
52-
--header "Authorization: Bearer <API_TOKEN>" \
53-
--header "Content-Type: application/json" \
54-
--data '{
55-
"name": "shop_waiting_room",
56-
"description": "Waiting room for webshop",
57-
"host": "shop.example.com",
58-
"path": "/shop",
59-
"queue_all": true,
60-
"new_users_per_minute": 200,
61-
"total_active_users": 300,
62-
"session_duration": 1,
63-
"disable_session_renewal": false,
64-
"json_response_enabled": false,
65-
"queueing_method": "FIFO",
66-
"cookie_attributes": {
67-
"samesite": "none",
68-
"secure": "auto"
69-
}
70-
}'
71-
```
50+
<APIRequest
51+
path="/zones/{zone_id}/waiting_rooms"
52+
method="POST"
53+
json={{
54+
name: "shop_waiting_room",
55+
description: "Waiting room for webshop",
56+
host: "shop.example.com",
57+
path: "/shop",
58+
queue_all: true,
59+
new_users_per_minute: 200,
60+
total_active_users: 300,
61+
session_duration: 1,
62+
disable_session_renewal: false,
63+
json_response_enabled: false,
64+
queueing_method: "FIFO",
65+
cookie_attributes: {
66+
samesite: "none",
67+
secure: "auto"
68+
}
69+
}}
70+
/>
7271

7372

7473
</Details>

src/content/docs/waiting-room/additional-options/waiting-room-rules/bypass-rules.mdx

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

77
---
88

9-
import { Details } from "~/components"
9+
import { Details, APIRequest } from "~/components"
1010

1111
A Waiting Room Bypass Rule is a type of Waiting Room Rule built on Cloudflare’s Ruleset Engine and managed via the Waiting Room API. A Waiting Room Bypass Rule allows you to indicate specific traffic or areas of your site or application that you do not want a waiting room to apply to. Each bypass rule is created and managed at the individual waiting room level for precise control over your waiting room traffic.
1212

@@ -88,31 +88,30 @@ Configure your bypass rule with the following required and optional parameters:
8888

8989
If your waiting room is configured at `example.com/` and you would like all traffic visiting `example.com/bypassme` and all of its subpaths. In this example, we also want to ensure any subrequests of `js`, `css`, or `png` from also bypass the waiting room to ensure all assets are loaded properly on the paths being bypassed. Note that in this example, all requests ending in `js`, `css` or `png` will bypass the waiting room regardless of the subpath. If this is not your intended use case, please alter the expression to suit your specific requirements and site architecture.
9090

91-
```bash
92-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/waiting_rooms/{room_id}/rules" \
93-
--header "Authorization: Bearer <API_TOKEN>" \
94-
--data '{
95-
"description": "subpath bypass",
96-
"expression": "starts_with(http.request.uri.path, \"/bypassme\") or ends_with(http.request.uri.path, \".js\") or ends_with(http.request.uri.path, \".css\") or ends_with(http.request.uri.path, \".png\")",
97-
"action": "bypass_waiting_room"
98-
}'
99-
```
100-
91+
<APIRequest
92+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules"
93+
method="POST"
94+
json={{
95+
description: "subpath bypass",
96+
expression: "starts_with(http.request.uri.path, \"/bypassme\") or ends_with(http.request.uri.path, \".js\") or ends_with(http.request.uri.path, \".css\") or ends_with(http.request.uri.path, \".png\")",
97+
action: "bypass_waiting_room"
98+
}}
99+
/>
101100

102101
</Details>
103102

104103

105104
<Details header="Allow a defined list of IPs to bypass the waiting room">
106105

107-
```bash
108-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/waiting_rooms/{room_id}/rules" \
109-
--header "Authorization: Bearer <API_TOKEN>" \
110-
--data '{
111-
"description": "ip list bypass",
112-
"expression": "ip.src in $bypass_ip_list",
113-
"action": "bypass_waiting_room"
114-
}'
115-
```
106+
<APIRequest
107+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules"
108+
method="POST"
109+
json={{
110+
description: "ip list bypass",
111+
expression: "ip.src in $bypass_ip_list",
112+
action: "bypass_waiting_room"
113+
}}
114+
/>
116115

117116

118117
</Details>

src/content/docs/waiting-room/how-to/create-waiting-room.mdx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ head:
88
content: Create a waiting room
99
---
1010

11-
import { TabItem, Tabs } from "~/components";
11+
import { TabItem, Tabs, APIRequest } from "~/components";
1212

1313
You can create a waiting room from the dashboard or via API.
1414

@@ -37,29 +37,28 @@ To create a Waiting Room using the API, send a [`POST` request](/api/resources/w
3737
- For authentication instructions, refer to [Create an API token](/fundamentals/api/get-started/create-token/).
3838
- For help with endpoints and pagination, refer to [Make API calls](/fundamentals/api/how-to/make-api-calls/).
3939

40-
```json title="Request"
41-
curl -X POST "https://api.cloudflare.com/client/v4/zones/{zone_identifier}/waiting_rooms" \
42-
--header 'Authorization: Bearer REDACTED' \
43-
--header 'Content-Type: application/json' \
44-
--data '{
45-
"name": "shop_waiting_room",
46-
"description": "Waiting room for webshop",
47-
"host": "shop.example.com",
48-
"path": "/shop",
49-
"queue_all": true,
50-
"new_users_per_minute": 200,
51-
"total_active_users": 300,
52-
"session_duration": 1,
53-
"disable_session_renewal": false,
54-
"json_response_enabled": false,
55-
"queueing_method": "fifo",
56-
"queueing_status_code": 202,
57-
"cookie_attributes": {
58-
"samesite": "auto",
59-
"secure": "auto"
60-
}
61-
}'
62-
```
40+
<APIRequest
41+
path="/zones/{zone_id}/waiting_rooms"
42+
method="POST"
43+
json={{
44+
name: "shop_waiting_room",
45+
description: "Waiting room for webshop",
46+
host: "shop.example.com",
47+
path: "/shop",
48+
queue_all: true,
49+
new_users_per_minute: 200,
50+
total_active_users: 300,
51+
session_duration: 1,
52+
disable_session_renewal: false,
53+
json_response_enabled: false,
54+
queueing_method: "fifo",
55+
queueing_status_code: 202,
56+
cookie_attributes: {
57+
samesite: "auto",
58+
secure: "auto"
59+
}
60+
}}
61+
/>
6362

6463
The response contains the complete definition of the newly created Waiting Room.
6564

src/content/docs/waiting-room/how-to/customize-waiting-room.mdx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sidebar:
66

77
---
88

9+
import { APIRequest } from "~/components";
10+
911
You can customize your waiting room from the dashboard or via API.
1012

1113
## Customize a waiting room from the dashboard
@@ -167,13 +169,19 @@ You can use the Waiting Room API to customize the web page served to visitors wh
167169

168170
In the following `PATCH` request, the `custom_page_html` field contains the HTML code for the [customized waiting room](/waiting-room/how-to/customize-waiting-room/):
169171

170-
```bash
171-
curl --request PATCH \
172-
"https://api.cloudflare.com/client/v4/zones/{zone_id}/waiting_rooms/{waiting_room_id}" \
173-
--header "Authorization: Bearer <API_TOKEN>" \
174-
--header "Content-Type: application/json" \
175-
--data '{"custom_page_html": "<p>Include custom HTML here</p>"}'
176-
```
172+
<APIRequest
173+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}"
174+
method="PATCH"
175+
json={{
176+
name: "webshop-waiting-room",
177+
host: "example.com",
178+
new_users_per_minute: 200,
179+
total_active_users: 300,
180+
custom_page_html: "<p>Include custom HTML here</p>"
181+
}}
182+
/>
183+
184+
Response:
177185

178186
```json
179187
{
@@ -227,12 +235,13 @@ Note that you pass HTML content to the preview endpoint in the `custom_html` fie
227235

228236
Example request:
229237

230-
```bash
231-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/waiting_rooms/preview" \
232-
--header "Authorization: Bearer <API_TOKEN>" \
233-
--header "Content-Type: application/json" \
234-
--data '{"custom_html": "<p>Include custom HTML here</p>"}'
235-
```
238+
<APIRequest
239+
path="/zones/{zone_id}/waiting_rooms/preview"
240+
method="POST"
241+
json={{
242+
custom_html: "<p>Include custom HTML here</p>"
243+
}}
244+
/>
236245

237246
The preview endpoint returns a temporary URL in the response body where you can preview your custom page:
238247

src/content/docs/waiting-room/how-to/edit-delete-waiting-room.mdx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sidebar:
66

77
---
88

9+
import { APIRequest } from "~/components";
10+
911
You can manage your waiting rooms using the [Waiting Room dashboard](/waiting-room/how-to/waiting-room-dashboard/) or the [API](/waiting-room/reference/waiting-room-api/).
1012

1113
:::note
@@ -35,22 +37,37 @@ For details about updating an active waiting room, refer to [Best practices](/wa
3537

3638
[Replace](https://api.cloudflare.com#waiting-room-update-waiting-room) a configured waiting room by appending the following endpoint to the Cloudflare API base URL.
3739

38-
```bash
39-
PUT zones/{zone_identifier}/waiting_rooms/{identifier}
40-
```
40+
<APIRequest
41+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}"
42+
method="PUT"
43+
json={{
44+
name: "webshop-waiting-room",
45+
host: "example.com",
46+
new_users_per_minute: 200,
47+
total_active_users: 300
48+
}}
49+
/>
4150

4251
[Update](https://api.cloudflare.com#waiting-room-patch-waiting-room) a configured waiting room by appending the following endpoint to the Cloudflare API base URL.
4352

44-
```bash
45-
PATCH zones/{zone_identifier}/waiting_rooms/{identifier}
46-
```
53+
<APIRequest
54+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}"
55+
method="PATCH"
56+
json={{
57+
name: "webshop-waiting-room",
58+
host: "example.com",
59+
new_users_per_minute: 200,
60+
total_active_users: 300
61+
}}
62+
/>
4763

48-
You only need to include the parameters that you want to update in the `data` field of the PATCH request.
4964

65+
You only need to include the fields you want to update in the payload of the PATCH request.
5066
### Delete a waiting room
5167

5268
Delete a waiting room by appending the following endpoint in the [Waiting Room API](https://api.cloudflare.com#waiting-room-delete-waiting-room) to the Cloudflare API base URL.
5369

54-
```bash
55-
DELETE zones/{zone_identifier}/waiting_rooms/{identifier}
56-
```
70+
<APIRequest
71+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}"
72+
method="DELETE"
73+
/>

src/content/docs/waiting-room/how-to/monitor-waiting-room.mdx

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

77
---
88

9+
import { APIRequest } from "~/components";
10+
911
You can monitor the status of your waiting rooms using the [dashboard](#status-in-the-dashboard) or the [API](#status-in-the-api).
1012

1113
Note that the **Total active users** and **Queued users** shown in the dashboard, as well as through API endpoints are estimates. That data corresponding to each of these metrics is cached for around 30 seconds after the time it takes to be synced from all data centers globally. Therefore, the status will range between 20-50 seconds in the past, depending on the exact moment the data was queried, aggregated, as well as the age of the cache.
@@ -34,9 +36,10 @@ The **Status** column displays the current state of the waiting room:
3436

3537
[Check whether traffic is queueing in a configured waiting room](/api/resources/waiting_rooms/subresources/statuses/methods/get/) by appending the following endpoint to the Cloudflare API base URL:
3638

37-
```bash
38-
GET zones/{zone_identifier}/waiting_rooms/{identifier}/status
39-
```
39+
<APIRequest
40+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}/status"
41+
method="GET"
42+
/>
4043

4144
The response is:
4245

@@ -45,9 +48,10 @@ The response is:
4548

4649
To check whether a configured waiting room is suspended or whether the traffic is force-queued to the waiting room, append the following endpoint to the Cloudflare API base URL.
4750

48-
```bash
49-
GET zones/{zone_identifier}/waiting_rooms/{identifier}
50-
```
51+
<APIRequest
52+
path="/zones/{zone_id}/waiting_rooms/{waiting_room_id}"
53+
method="GET"
54+
/>
5155

5256
The endpoint above [fetches all settings](/api/resources/waiting_rooms/methods/get/) for a configured waiting room:
5357

0 commit comments

Comments
 (0)