Skip to content

Commit 8b7e384

Browse files
pedrosousadaisyfaithauma
authored andcommitted
[Rules] Update Custom Errors (#21954)
* [Rules] Update Custom Errors * Delete old pages in Support
1 parent 9229506 commit 8b7e384

File tree

25 files changed

+927
-673
lines changed

25 files changed

+927
-673
lines changed

public/__redirects

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,9 @@
10191019
/rules/page-rules/how-to/rewrite-host-headers/ /rules/origin-rules/examples/change-uri-path-and-host-header/ 301
10201020
/rules/page-rules/how-to/override-url-or-ip-address/ /rules/origin-rules/features/ 301
10211021
/rules/origin-rules/examples/change-uri-path-and-host-header/ /rules/origin-rules/tutorials/change-uri-path-and-host-header/ 301
1022+
/rules/custom-errors/create-api/ /rules/custom-errors/create-rules/ 301
1023+
/rules/custom-errors/error-tokens/ /rules/custom-errors/reference/error-tokens/ 301
1024+
/rules/custom-errors/parameters/ /rules/custom-errors/reference/parameters/ 301
10221025

10231026
# ruleset engine
10241027
/ruleset-engine/rules-language/fields/standard-fields/ /ruleset-engine/rules-language/fields/reference/ 301
@@ -1240,6 +1243,9 @@
12401243
/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-10xxx-errors/ /support/troubleshooting/http-status-codes/cloudflare-10xxx-errors/ 301
12411244
/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-1xxx-errors/ /support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/ 301
12421245
/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-5xx-errors/ /support/troubleshooting/http-status-codes/cloudflare-5xx-errors/ 301
1246+
/support/more-dashboard-apps/cloudflare-custom-pages/configuring-custom-pages-error-and-challenge/ /rules/custom-errors/ 301
1247+
/support/more-dashboard-apps/cloudflare-custom-pages/ /rules/custom-errors/ 301
1248+
/support/more-dashboard-apps/ /support/ 301
12431249

12441250
# r2
12451251
/r2/platform/s3-compatibility/api/ /r2/api/s3/api/ 301
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
title: Common API calls
3+
pcx_content_type: configuration
4+
sidebar:
5+
order: 5
6+
head:
7+
- tag: title
8+
content: Common API calls | Custom Error Assets
9+
---
10+
11+
The following sections provide examples of common API calls for managing custom error assets at the zone level.
12+
13+
To perform the same operations at the account level, use the corresponding account-level API endpoints.
14+
15+
### Create a custom error asset
16+
17+
The following `POST` request creates a new custom error asset in a zone based on the provided URL:
18+
19+
```bash
20+
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets" \
21+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
22+
--json '{
23+
"name": "500_error_template",
24+
"description": "Standard 5xx error template page",
25+
"url": "https://example.com/errors/500_template.html"
26+
}'
27+
```
28+
29+
```json output
30+
{
31+
"result": {
32+
"name": "500_error_template",
33+
"description": "Standard 5xx error template page",
34+
"url": "https://example.com/errors/500_template.html",
35+
"last_updated": "2025-02-10T11:36:07.810215Z",
36+
"size_bytes": 2048
37+
},
38+
"success": true
39+
}
40+
```
41+
42+
To create an asset at the account level, use the account-level endpoint:
43+
44+
```txt
45+
https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets
46+
```
47+
48+
### List custom error assets
49+
50+
The following `GET` request retrieves a list of custom error assets configured in the zone:
51+
52+
```bash
53+
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets" \
54+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
55+
```
56+
57+
```json output
58+
{
59+
"result": [
60+
{
61+
"name": "500_error_template",
62+
"description": "Standard 5xx error template page",
63+
"url": "https://example.com/errors/500_template.html",
64+
"last_updated": "2025-02-10T11:36:07.810215Z",
65+
"size_bytes": 2048
66+
}
67+
// ...
68+
],
69+
"success": true,
70+
"errors": [],
71+
"messages": [],
72+
"result_info": {
73+
"count": 2,
74+
"page": 1,
75+
"per_page": 20,
76+
"total_count": 2,
77+
"total_pages": 1
78+
}
79+
}
80+
```
81+
82+
To retrieve a list of assets at the account level, use the account-level endpoint:
83+
84+
```txt
85+
https://api.cloudflare.com/client/v4/accounts/$ZONE_ID/custom_pages/assets
86+
```
87+
88+
### Update a custom error asset
89+
90+
The following `PUT` request updates the URL of an existing custom error asset at the zone level named `500_error_template`:
91+
92+
```bash
93+
curl --request PUT \
94+
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets/500_error_template" \
95+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
96+
--json '{
97+
"description": "Standard 5xx error template page",
98+
"url": "https://example.com/errors/500_new_template.html"
99+
}'
100+
```
101+
102+
```json output
103+
{
104+
"result": {
105+
"name": "500_error_template",
106+
"description": "Standard 5xx error template page",
107+
"url": "https://example.com/errors/500_new_template.html",
108+
"last_updated": "2025-02-10T13:13:07.810215Z",
109+
"size_bytes": 3145
110+
},
111+
"success": true
112+
}
113+
```
114+
115+
You can update the asset description and URL. You cannot update the asset name after creation.
116+
117+
If you provide the same URL when updating an asset, Cloudflare will fetch the URL again, along with its resources.
118+
119+
To update an asset at the account level, use the account-level endpoint:
120+
121+
```txt
122+
https://api.cloudflare.com/client/v4/accounts/{account_id}/custom_pages/assets/{asset_name}
123+
```
124+
125+
### Get a custom error asset
126+
127+
The following `GET` request retrieves the details of an existing custom error asset at the zone level named `500_error_template`:
128+
129+
```bash
130+
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets/500_error_template" \
131+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
132+
```
133+
134+
```json output
135+
{
136+
"result": {
137+
"name": "500_error_template",
138+
"description": "Standard 5xx error template page",
139+
"url": "https://example.com/errors/500_new_template.html",
140+
"last_updated": "2025-02-10T13:13:07.810215Z",
141+
"size_bytes": 3145
142+
},
143+
"success": true
144+
}
145+
```
146+
147+
To retrieve an asset at the account level, use the account-level endpoint:
148+
149+
```txt
150+
https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets/$ASSET_NAME
151+
```
152+
153+
### Delete a custom error asset
154+
155+
The following `DELETE` request deletes an existing custom error asset at the zone level named `500_error_template`:
156+
157+
```bash
158+
curl --request DELETE \
159+
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets/500_error_template" \
160+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
161+
```
162+
163+
If the request is successful, the response will have a `204` HTTP status code.
164+
165+
To delete an asset at the account level, use the account-level endpoint:
166+
167+
```txt
168+
https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets/$ASSET_NAME
169+
```

0 commit comments

Comments
 (0)