-
Notifications
You must be signed in to change notification settings - Fork 10k
[Rules] Update Custom Errors #21954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nikitacano
merged 5 commits into
production
from
pedro/PCX-16710-rules-update-custom-errors
Apr 24, 2025
Merged
[Rules] Update Custom Errors #21954
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| --- | ||
| title: Common API calls | ||
| pcx_content_type: configuration | ||
| sidebar: | ||
| order: 5 | ||
| head: | ||
| - tag: title | ||
| content: Common API calls | Custom Error Assets | ||
| --- | ||
|
|
||
| The following sections provide examples of common API calls for managing custom error assets at the zone level. | ||
|
|
||
| To perform the same operations at the account level, use the corresponding account-level API endpoints. | ||
|
|
||
| ### Create a custom error asset | ||
|
|
||
| The following `POST` request creates new a custom error asset in a zone based on the provided URL: | ||
|
|
||
| ```bash | ||
| curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets" \ | ||
| --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ | ||
| --json '{ | ||
| "name": "500_error_template", | ||
| "description": "Standard 5xx error template page", | ||
| "url": "https://example.com/errors/500_template.html" | ||
| }' | ||
| ``` | ||
|
|
||
| ```json output | ||
| { | ||
| "result": { | ||
| "name": "500_error_template", | ||
| "description": "Standard 5xx error template page", | ||
| "url": "https://example.com/errors/500_template.html", | ||
| "last_updated": "2025-02-10T11:36:07.810215Z", | ||
| "size_bytes": 2048 | ||
| }, | ||
| "success": true | ||
| } | ||
| ``` | ||
|
|
||
| To create an asset at the account level, use the account-level endpoint: | ||
|
|
||
| ```txt | ||
| https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets | ||
| ``` | ||
|
|
||
| ### List custom error assets | ||
|
|
||
| The following `GET` request retrieves a list of custom error assets configured in the zone: | ||
|
|
||
| ```bash | ||
| curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets" \ | ||
| --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | ||
| ``` | ||
|
|
||
| ```json output | ||
| { | ||
| "result": [ | ||
| { | ||
| "name": "500_error_template", | ||
| "description": "Standard 5xx error template page", | ||
| "url": "https://example.com/errors/500_template.html", | ||
| "last_updated": "2025-02-10T11:36:07.810215Z", | ||
| "size_bytes": 2048 | ||
| } | ||
| // ... | ||
| ], | ||
| "success": true, | ||
| "errors": [], | ||
| "messages": [], | ||
| "result_info": { | ||
| "count": 2, | ||
| "page": 1, | ||
| "per_page": 20, | ||
| "total_count": 2, | ||
| "total_pages": 1 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| To retrieve a list of assets at the account level, use the account-level endpoint: | ||
|
|
||
| ```txt | ||
| https://api.cloudflare.com/client/v4/accounts/$ZONE_ID/custom_pages/assets | ||
| ``` | ||
|
|
||
| ### Update a custom error asset | ||
|
|
||
| The following `PUT` request updates the URL of an existing custom error asset at the zone level named `500_error_template`: | ||
|
|
||
| ```bash | ||
| curl --request PUT \ | ||
| "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets/500_error_template" \ | ||
| --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ | ||
| --json '{ | ||
| "description": "Standard 5xx error template page", | ||
| "url": "https://example.com/errors/500_new_template.html" | ||
| }' | ||
| ``` | ||
|
|
||
| ```json output | ||
| { | ||
| "result": { | ||
| "name": "500_error_template", | ||
| "description": "Standard 5xx error template page", | ||
| "url": "https://example.com/errors/500_new_template.html", | ||
| "last_updated": "2025-02-10T13:13:07.810215Z", | ||
| "size_bytes": 3145 | ||
| }, | ||
| "success": true | ||
| } | ||
| ``` | ||
|
|
||
| You can update the asset description and URL. You cannot update the asset name after creation. | ||
|
|
||
| If you provide the same URL when updating an asset, Cloudflare will fetch the URL again, along with its resources. | ||
|
|
||
| To update an asset at the account level, use the account-level endpoint: | ||
|
|
||
| ```txt | ||
| https://api.cloudflare.com/client/v4/accounts/{account_id}/custom_pages/assets/{asset_name} | ||
| ``` | ||
|
|
||
| ### Get a custom error asset | ||
|
|
||
| The following `GET` request retrieves the details of an existing custom error asset at the zone level named `500_error_template`: | ||
|
|
||
| ```bash | ||
| curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets/500_error_template" \ | ||
| --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | ||
| ``` | ||
|
|
||
| ```json output | ||
| { | ||
| "result": { | ||
| "name": "500_error_template", | ||
| "description": "Standard 5xx error template page", | ||
| "url": "https://example.com/errors/500_new_template.html", | ||
| "last_updated": "2025-02-10T13:13:07.810215Z", | ||
| "size_bytes": 3145 | ||
| }, | ||
| "success": true | ||
| } | ||
| ``` | ||
|
|
||
| To retrieve an asset at the account level, use the account-level endpoint: | ||
|
|
||
| ```txt | ||
| https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets/$ASSET_NAME | ||
| ``` | ||
|
|
||
| ### Delete a custom error asset | ||
|
|
||
| The following `DELETE` request deletes an existing custom error asset at the zone level named `500_error_template`: | ||
|
|
||
| ```bash | ||
| curl --request DELETE \ | ||
| "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_pages/assets/500_error_template" \ | ||
| --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" | ||
| ``` | ||
|
|
||
| If the request is successful, the response will have a `204` HTTP status code. | ||
|
|
||
| To delete an asset at the account level, use the account-level endpoint: | ||
|
|
||
| ```txt | ||
| https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/custom_pages/assets/$ASSET_NAME | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.