Replace the cache exclusions for a WordPress installation
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.wpengineapi.com/v1/installs/294deacc-d8b8-4005-82c4-0727ba8ddde0/cache_exclusions"
payload := strings.NewReader("{ \"exclusions\": [ { \"type\": \"url path\", \"value\": \"/foo\" }, { \"type\": \"query arg\", \"value\": \"utm_source\" } ] }")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Basic <credentials>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.wpengineapi.com/v1/installs/294deacc-d8b8-4005-82c4-0727ba8ddde0/cache_exclusions';const options = { method: 'PUT', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"exclusions":[{"type":"url path","value":"/foo"},{"type":"query arg","value":"utm_source"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://api.wpengineapi.com/v1/installs/294deacc-d8b8-4005-82c4-0727ba8ddde0/cache_exclusions \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "exclusions": [ { "type": "url path", "value": "/foo" }, { "type": "query arg", "value": "utm_source" } ] }'Replaces the full set of cache exclusion rules for an install with the list supplied in the request body, and returns the resulting list.
Behavior
- This is a full replacement, not a partial update: any exclusion currently configured but absent from
exclusionsis removed, and an empty array clears every writable exclusion - Duplicate entries are collapsed before being saved
- Entries of type
cookieare managed by the platform and cannot be written here. They are accepted and ignored, so a list read fromGET /installs/{install_id}/cache_exclusionscan be edited and sent back unchanged, and they continue to appear in the response. To add or change one, see Exclude pages from cache when a cookie is present - Each
valueis matched as a regular expression; an invalid expression returns a400 - Requires an eligible account and a user who can update the install; otherwise returns a
403 - Exclusions cannot be modified while the install is transferable; such requests return a
409and leave the existing exclusions unchanged. Reading them withGET /installs/{install_id}/cache_exclusionsis still permitted
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”ID of install
Example
294deacc-d8b8-4005-82c4-0727ba8ddde0Request Bodyrequired
Section titled “Request Bodyrequired”Properties
- exclusions - required - The complete list of cache exclusions for the install. Each entry requires a
type(query arg,url path, orcookie) and avalue. Entries of typecookieare ignored when saving
object
The complete set of cache exclusions to apply to the install
object
The kind of request attribute this exclusion matches on
Example
url pathThe value used to match requests that should bypass the cache
Example
/fooExample
{ "exclusions": [ { "type": "url path", "value": "/foo" }, { "type": "query arg", "value": "utm_source" } ]}Responses
Section titled “Responses”The resulting cache exclusions for the install
object
object
The kind of request attribute this exclusion matches on
The value used to match requests that should bypass the cache
Example
{ "results": [ { "type": "query arg", "value": "/foo" } ]}Bad Request
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
An array of error objects describing specific errors that arose when servicing the request
object
The name of the resource that was being processed when the error occurred
(Optional) The specific field associated with the error
(Optional) A type associated with the error. invalid_value, access_error, value_unavailable
(Optional) A machine code relating to the error that occurred with the field and resource
(Optional) A human-readable message relating to the error that occurred with the field and resource
Example
{ "message": "Invalid Site: Name cannot be empty.", "errors": [ { "resource": "Site", "field": "name", "type": "invalid_value", "code": "too_long", "message": "Name is too long (maximum is 40 characters)" } ]}Authentication Error
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Bad Credentials"}Not authorized
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "You don't have permission to perform that action"}Not found
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Not Found"}Conflict — cache exclusions cannot be modified while the install is transferable
object
A message regarding the conflict that occurred
(Optional) A URL where documentation regarding this specific error can be found
An array of error objects describing specific errors that arose when servicing the request
object
The name of the resource that was being processed when the error occurred
(Optional) The specific field associated with the error
(Optional) A type associated with the error. invalid_value, access_error, value_unavailable
(Optional) A machine code relating to the error that occurred with the field and resource
(Optional) A human-readable message relating to the error that occurred with the field and resource
Example
{ "message": "Transfer has already started and cannot be cancelled", "errors": [ { "resource": "Site", "field": "name", "type": "invalid_value", "code": "too_long", "message": "Name is too long (maximum is 40 characters)" } ]}Too many requests
Internal server error
object
A message regarding the error that occurred on the server
Example
{ "message": "An unexpected error occurred, please try again in a few minutes"}Service unavailable