|
8 | 8 | content: Common API calls | Custom Error Assets |
9 | 9 | --- |
10 | 10 |
|
| 11 | +import { APIRequest } from "~/components"; |
| 12 | + |
11 | 13 | The following sections provide examples of common API calls for managing custom error assets at the zone level. |
12 | 14 |
|
13 | 15 | To perform the same operations at the account level, use the corresponding account-level API endpoints. |
@@ -167,3 +169,75 @@ To delete an asset at the account level, use the account-level endpoint: |
167 | 169 | ```txt |
168 | 170 | https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets/$ASSET_NAME |
169 | 171 | ``` |
| 172 | + |
| 173 | +### Get error page |
| 174 | + |
| 175 | +This example obtains the current configuration for the `Rate limiting block` error page (with ID `ratelimit_block`). |
| 176 | + |
| 177 | +<APIRequest |
| 178 | + path="/zones/{zone_identifier}/custom_pages/{identifier}" |
| 179 | + method="GET" |
| 180 | + parameters={{ |
| 181 | + identifier: "ratelimit_block", |
| 182 | + }} |
| 183 | +/> |
| 184 | + |
| 185 | +```json output |
| 186 | +{ |
| 187 | + "result": { |
| 188 | + "id": "ratelimit_block", |
| 189 | + "description": "Rate limit Block", |
| 190 | + "required_tokens": [], |
| 191 | + "preview_target": "block:rate-limit", |
| 192 | + "created_on": "2025-06-03T08:33:17.091587Z", |
| 193 | + "modified_on": "2025-06-03T08:33:17.091587Z", |
| 194 | + "url": null, |
| 195 | + "state": "default" |
| 196 | + }, |
| 197 | + "success": true, |
| 198 | + "errors": [], |
| 199 | + "messages": [] |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +The response indicates that the page is currently set to the Cloudflare default page (`"state": "default"`). |
| 204 | + |
| 205 | +For a list of error page identifiers, refer to [Error page types](/rules/custom-errors/reference/error-page-types/). |
| 206 | + |
| 207 | +### Update error page |
| 208 | + |
| 209 | +This example defines a custom error page for `Rate limiting block` errors (with ID `ratelimit_block`) based on the provided URL. |
| 210 | + |
| 211 | +<APIRequest |
| 212 | + path="/zones/{zone_identifier}/custom_pages/{identifier}" |
| 213 | + method="PUT" |
| 214 | + parameters={{ |
| 215 | + identifier: "ratelimit_block", |
| 216 | + }} |
| 217 | + json={{ |
| 218 | + state: "customized", |
| 219 | + url: "https://example.com/rate_limiting_block_error_page.html", |
| 220 | + }} |
| 221 | +/> |
| 222 | + |
| 223 | +```json output |
| 224 | +{ |
| 225 | + "result": { |
| 226 | + "id": "ratelimit_block", |
| 227 | + "description": "Rate limit Block", |
| 228 | + "required_tokens": [], |
| 229 | + "preview_target": "block:rate-limit", |
| 230 | + "created_on": "2025-06-03T08:33:17.091587Z", |
| 231 | + "modified_on": "2025-06-03T08:35:32.639114Z", |
| 232 | + "url": "https://example.com/rate_limiting_block_error_page.html", |
| 233 | + "state": "customized" |
| 234 | + }, |
| 235 | + "success": true, |
| 236 | + "errors": [], |
| 237 | + "messages": [] |
| 238 | +} |
| 239 | +``` |
| 240 | + |
| 241 | +To set the error page back to the default page, use `"state": "default"` in the request body. |
| 242 | + |
| 243 | +For a list of error page identifiers, refer to [Error page types](/rules/custom-errors/reference/error-page-types/). |
0 commit comments