# Cache ## Purge Cached Content `client.Cache.Purge(ctx, params) (*CachePurgeResponse, error)` **post** `/zones/{zone_id}/purge_cache` ### Purge All Cached Content Removes ALL files from Cloudflare's cache. All tiers can purge everything. ``` {"purge_everything": true} ``` ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. All tiers can purge by URL. To purge files with custom cache keys, include the headers used to compute the cache key as in the example. If you have a device type or geo in your cache key, you will need to include the CF-Device-Type or CF-IPCountry headers. If you have lang in your cache key, you will need to include the Accept-Language header. **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for http, 443 for https), but must be included otherwise. Single file purge example with files: ``` {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} ``` Single file purge example with url and header pairs: ``` {"files": [{"url": "http://www.example.com/cat_picture.jpg", "headers": {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}}, {"url": "http://www.example.com/dog_picture.jpg", "headers": {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}}]} ``` ### Purge Cached Content by Tag, Host or Prefix Granularly removes one or more files from Cloudflare's cache either by specifying the host, the associated Cache-Tag, or a Prefix. Flex purge with tags: ``` {"tags": ["a-cache-tag", "another-cache-tag"]} ``` Flex purge with hosts: ``` {"hosts": ["www.example.com", "images.example.com"]} ``` Flex purge with prefixes: ``` {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} ``` ### Availability and limits Please refer to [purge cache availability and limits documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/#availability-and-limits). ### Parameters - `params CachePurgeParams` - `ZoneID param.Field[string]` Path param - `Tags param.Field[[]string]` Body param: For more information on cache tags and purging by tags, please refer to [purge by cache-tags documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/). ### Returns - `type CachePurgeResponse struct{…}` - `ID string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.Purge(context.TODO(), cache.CachePurgeParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: cache.CachePurgeParamsBodyCachePurgeFlexPurgeByTags{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` ## Purge Cached Content by Environment `client.Cache.PurgeEnvironment(ctx, environmentID, params) (*CachePurgeEnvironmentResponse, error)` **post** `/zones/{zone_id}/environments/{environment_id}/purge_cache` Purge cached content scoped to a specific environment. Supports the same purge types as the zone-level endpoint (purge everything, by URL, by tag, host, or prefix). ### Availability and limits Please refer to [purge cache availability and limits documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/#availability-and-limits). ### Parameters - `environmentID string` - `params CachePurgeEnvironmentParams` - `ZoneID param.Field[string]` Path param - `Tags param.Field[[]string]` Body param: For more information on cache tags and purging by tags, please refer to [purge by cache-tags documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/). ### Returns - `type CachePurgeEnvironmentResponse struct{…}` - `ID string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.PurgeEnvironment( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", cache.CachePurgeEnvironmentParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: cache.CachePurgeEnvironmentParamsBodyCachePurgeFlexPurgeByTags{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` # Cache Reserve ## Get Cache Reserve setting `client.Cache.CacheReserve.Get(ctx, query) (*CacheReserveGetResponse, error)` **get** `/zones/{zone_id}/cache/cache_reserve` Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) for more information. ### Parameters - `query CacheReserveGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type CacheReserveGetResponse struct{…}` - `ID CacheReserve` The identifier of the caching setting. - `const CacheReserveCacheReserve CacheReserve = "cache_reserve"` - `Editable bool` Whether the setting is editable. - `Value CacheReserveGetResponseValue` Value of the Cache Reserve zone setting. - `const CacheReserveGetResponseValueOn CacheReserveGetResponseValue = "on"` - `const CacheReserveGetResponseValueOff CacheReserveGetResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cacheReserve, err := client.Cache.CacheReserve.Get(context.TODO(), cache.CacheReserveGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cacheReserve.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "editable": true, "id": "cache_reserve", "value": "off" }, "success": true } ``` ## Change Cache Reserve setting `client.Cache.CacheReserve.Edit(ctx, params) (*CacheReserveEditResponse, error)` **patch** `/zones/{zone_id}/cache/cache_reserve` Increase cache lifetimes by automatically storing all cacheable files into Cloudflare's persistent object storage buckets. Requires Cache Reserve subscription. Note: using Tiered Cache with Cache Reserve is highly recommended to reduce Reserve operations costs. See the [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) for more information. ### Parameters - `params CacheReserveEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Value param.Field[CacheReserveEditParamsValue]` Body param: Value of the Cache Reserve zone setting. - `const CacheReserveEditParamsValueOn CacheReserveEditParamsValue = "on"` - `const CacheReserveEditParamsValueOff CacheReserveEditParamsValue = "off"` ### Returns - `type CacheReserveEditResponse struct{…}` - `ID CacheReserve` The identifier of the caching setting. - `const CacheReserveCacheReserve CacheReserve = "cache_reserve"` - `Editable bool` Whether the setting is editable. - `Value CacheReserveEditResponseValue` Value of the Cache Reserve zone setting. - `const CacheReserveEditResponseValueOn CacheReserveEditResponseValue = "on"` - `const CacheReserveEditResponseValueOff CacheReserveEditResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.CacheReserve.Edit(context.TODO(), cache.CacheReserveEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Value: cloudflare.F(cache.CacheReserveEditParamsValueOn), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "editable": true, "id": "cache_reserve", "value": "on" }, "success": true } ``` ## Get Cache Reserve Clear `client.Cache.CacheReserve.Status(ctx, query) (*CacheReserveStatusResponse, error)` **get** `/zones/{zone_id}/cache/cache_reserve_clear` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. ### Parameters - `query CacheReserveStatusParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type CacheReserveStatusResponse struct{…}` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. - `ID CacheReserveClear` ID of the zone setting. - `const CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear"` - `StartTs Time` The time that the latest Cache Reserve Clear operation started. - `State State` The current state of the Cache Reserve Clear operation. - `const StateInProgress State = "In-progress"` - `const StateCompleted State = "Completed"` - `EndTs Time` The time that the latest Cache Reserve Clear operation completed. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.CacheReserve.Status(context.TODO(), cache.CacheReserveStatusParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "end_ts": "2023-10-02T12:00:00.12345Z", "id": "cache_reserve_clear", "start_ts": "2023-10-02T10:00:00.12345Z", "state": "Completed" }, "success": true } ``` ## Start Cache Reserve Clear `client.Cache.CacheReserve.Clear(ctx, params) (*CacheReserveClearResponse, error)` **post** `/zones/{zone_id}/cache/cache_reserve_clear` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. ### Parameters - `params CacheReserveClearParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Body param.Field[unknown]` Body param ### Returns - `type CacheReserveClearResponse struct{…}` You can use Cache Reserve Clear to clear your Cache Reserve, but you must first disable Cache Reserve. In most cases, this will be accomplished within 24 hours. You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind that you cannot undo or cancel this operation. - `ID CacheReserveClear` ID of the zone setting. - `const CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear"` - `StartTs Time` The time that the latest Cache Reserve Clear operation started. - `State State` The current state of the Cache Reserve Clear operation. - `const StateInProgress State = "In-progress"` - `const StateCompleted State = "Completed"` - `EndTs Time` The time that the latest Cache Reserve Clear operation completed. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.CacheReserve.Clear(context.TODO(), cache.CacheReserveClearParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: map[string]interface{}{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "id": "cache_reserve_clear", "start_ts": "2023-10-02T10:00:00.12345Z", "state": "In-progress" }, "success": true } ``` ## Domain Types ### Cache Reserve - `type CacheReserve string` The identifier of the caching setting. - `const CacheReserveCacheReserve CacheReserve = "cache_reserve"` ### Cache Reserve Clear - `type CacheReserveClear string` ID of the zone setting. - `const CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear"` ### State - `type State string` The current state of the Cache Reserve Clear operation. - `const StateInProgress State = "In-progress"` - `const StateCompleted State = "Completed"` # Smart Tiered Cache ## Get Smart Tiered Cache setting `client.Cache.SmartTieredCache.Get(ctx, query) (*SmartTieredCacheGetResponse, error)` **get** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `query SmartTieredCacheGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type SmartTieredCacheGetResponse struct{…}` - `ID SmartTieredCacheGetResponseID` The identifier of the caching setting. - `const SmartTieredCacheGetResponseIDTieredCacheSmartTopologyEnable SmartTieredCacheGetResponseID = "tiered_cache_smart_topology_enable"` - `Editable bool` Whether the setting is editable. - `Value SmartTieredCacheGetResponseValue` Value of the Smart Tiered Cache zone setting. - `const SmartTieredCacheGetResponseValueOn SmartTieredCacheGetResponseValue = "on"` - `const SmartTieredCacheGetResponseValueOff SmartTieredCacheGetResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) smartTieredCache, err := client.Cache.SmartTieredCache.Get(context.TODO(), cache.SmartTieredCacheGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", smartTieredCache.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Create Smart Tiered Cache setting `client.Cache.SmartTieredCache.New(ctx, params) (*SmartTieredCacheNewResponse, error)` **post** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website's origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `params SmartTieredCacheNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Value param.Field[SmartTieredCacheNewParamsValue]` Body param: Enable or disable the Smart Tiered Cache. - `const SmartTieredCacheNewParamsValueOn SmartTieredCacheNewParamsValue = "on"` - `const SmartTieredCacheNewParamsValueOff SmartTieredCacheNewParamsValue = "off"` ### Returns - `type SmartTieredCacheNewResponse struct{…}` - `ID SmartTieredCacheNewResponseID` The identifier of the caching setting. - `const SmartTieredCacheNewResponseIDTieredCacheSmartTopologyEnable SmartTieredCacheNewResponseID = "tiered_cache_smart_topology_enable"` - `Editable bool` Whether the setting is editable. - `Value SmartTieredCacheNewResponseValue` Value of the Smart Tiered Cache zone setting. - `const SmartTieredCacheNewResponseValueOn SmartTieredCacheNewResponseValue = "on"` - `const SmartTieredCacheNewResponseValueOff SmartTieredCacheNewResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) smartTieredCache, err := client.Cache.SmartTieredCache.New(context.TODO(), cache.SmartTieredCacheNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Value: cloudflare.F(cache.SmartTieredCacheNewParamsValueOn), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", smartTieredCache.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Patch Smart Tiered Cache setting `client.Cache.SmartTieredCache.Edit(ctx, params) (*SmartTieredCacheEditResponse, error)` **patch** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `params SmartTieredCacheEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Value param.Field[SmartTieredCacheEditParamsValue]` Body param: Enable or disable the Smart Tiered Cache. - `const SmartTieredCacheEditParamsValueOn SmartTieredCacheEditParamsValue = "on"` - `const SmartTieredCacheEditParamsValueOff SmartTieredCacheEditParamsValue = "off"` ### Returns - `type SmartTieredCacheEditResponse struct{…}` - `ID SmartTieredCacheEditResponseID` The identifier of the caching setting. - `const SmartTieredCacheEditResponseIDTieredCacheSmartTopologyEnable SmartTieredCacheEditResponseID = "tiered_cache_smart_topology_enable"` - `Editable bool` Whether the setting is editable. - `Value SmartTieredCacheEditResponseValue` Value of the Smart Tiered Cache zone setting. - `const SmartTieredCacheEditResponseValueOn SmartTieredCacheEditResponseValue = "on"` - `const SmartTieredCacheEditResponseValueOff SmartTieredCacheEditResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.SmartTieredCache.Edit(context.TODO(), cache.SmartTieredCacheEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Value: cloudflare.F(cache.SmartTieredCacheEditParamsValueOn), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Delete Smart Tiered Cache setting `client.Cache.SmartTieredCache.Delete(ctx, body) (*SmartTieredCacheDeleteResponse, error)` **delete** `/zones/{zone_id}/cache/tiered_cache_smart_topology_enable` Smart Tiered Cache dynamically selects the single closest upper tier for each of your website’s origins with no configuration required, using our in-house performance and routing data. Cloudflare collects latency data for each request to an origin, and uses the latency data to determine how well any upper-tier data center is connected with an origin. As a result, Cloudflare can select the data center with the lowest latency to be the upper-tier for an origin. ### Parameters - `body SmartTieredCacheDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type SmartTieredCacheDeleteResponse struct{…}` - `ID SmartTieredCacheDeleteResponseID` The identifier of the caching setting. - `const SmartTieredCacheDeleteResponseIDTieredCacheSmartTopologyEnable SmartTieredCacheDeleteResponseID = "tiered_cache_smart_topology_enable"` - `Editable bool` Whether the setting is editable. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) smartTieredCache, err := client.Cache.SmartTieredCache.Delete(context.TODO(), cache.SmartTieredCacheDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", smartTieredCache.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tiered_cache_smart_topology_enable", "editable": true, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` # Variants ## Get variants setting `client.Cache.Variants.Get(ctx, query) (*VariantGetResponse, error)` **get** `/zones/{zone_id}/cache/variants` Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers. ### Parameters - `query VariantGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type VariantGetResponse struct{…}` - `ID VariantGetResponseID` The identifier of the caching setting. - `const VariantGetResponseIDVariants VariantGetResponseID = "variants"` - `Editable bool` Whether the setting is editable. - `Value VariantGetResponseValue` Value of the zone setting. - `AVIF []string` List of strings with the MIME types of all the variants that should be served for avif. - `BMP []string` List of strings with the MIME types of all the variants that should be served for bmp. - `GIF []string` List of strings with the MIME types of all the variants that should be served for gif. - `JP2 []string` List of strings with the MIME types of all the variants that should be served for jp2. - `JPEG []string` List of strings with the MIME types of all the variants that should be served for jpeg. - `JPG []string` List of strings with the MIME types of all the variants that should be served for jpg. - `JPG2 []string` List of strings with the MIME types of all the variants that should be served for jpg2. - `PNG []string` List of strings with the MIME types of all the variants that should be served for png. - `TIF []string` List of strings with the MIME types of all the variants that should be served for tif. - `TIFF []string` List of strings with the MIME types of all the variants that should be served for tiff. - `WebP []string` List of strings with the MIME types of all the variants that should be served for webp. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) variant, err := client.Cache.Variants.Get(context.TODO(), cache.VariantGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", variant.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "variants", "editable": true, "value": { "avif": [ "image/webp", "image/jpeg" ], "bmp": [ "image/webp", "image/jpeg" ], "gif": [ "image/webp", "image/jpeg" ], "jp2": [ "image/webp", "image/avif" ], "jpeg": [ "image/webp", "image/avif" ], "jpg": [ "image/webp", "image/avif" ], "jpg2": [ "image/webp", "image/avif" ], "png": [ "image/webp", "image/avif" ], "tif": [ "image/webp", "image/avif" ], "tiff": [ "image/webp", "image/avif" ], "webp": [ "image/jpeg", "image/avif" ] }, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Change variants setting `client.Cache.Variants.Edit(ctx, params) (*VariantEditResponse, error)` **patch** `/zones/{zone_id}/cache/variants` Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers. ### Parameters - `params VariantEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Value param.Field[VariantEditParamsValue]` Body param: Value of the zone setting. - `AVIF []string` List of strings with the MIME types of all the variants that should be served for avif. - `BMP []string` List of strings with the MIME types of all the variants that should be served for bmp. - `GIF []string` List of strings with the MIME types of all the variants that should be served for gif. - `JP2 []string` List of strings with the MIME types of all the variants that should be served for jp2. - `JPEG []string` List of strings with the MIME types of all the variants that should be served for jpeg. - `JPG []string` List of strings with the MIME types of all the variants that should be served for jpg. - `JPG2 []string` List of strings with the MIME types of all the variants that should be served for jpg2. - `PNG []string` List of strings with the MIME types of all the variants that should be served for png. - `TIF []string` List of strings with the MIME types of all the variants that should be served for tif. - `TIFF []string` List of strings with the MIME types of all the variants that should be served for tiff. - `WebP []string` List of strings with the MIME types of all the variants that should be served for webp. ### Returns - `type VariantEditResponse struct{…}` - `ID VariantEditResponseID` The identifier of the caching setting. - `const VariantEditResponseIDVariants VariantEditResponseID = "variants"` - `Editable bool` Whether the setting is editable. - `Value VariantEditResponseValue` Value of the zone setting. - `AVIF []string` List of strings with the MIME types of all the variants that should be served for avif. - `BMP []string` List of strings with the MIME types of all the variants that should be served for bmp. - `GIF []string` List of strings with the MIME types of all the variants that should be served for gif. - `JP2 []string` List of strings with the MIME types of all the variants that should be served for jp2. - `JPEG []string` List of strings with the MIME types of all the variants that should be served for jpeg. - `JPG []string` List of strings with the MIME types of all the variants that should be served for jpg. - `JPG2 []string` List of strings with the MIME types of all the variants that should be served for jpg2. - `PNG []string` List of strings with the MIME types of all the variants that should be served for png. - `TIF []string` List of strings with the MIME types of all the variants that should be served for tif. - `TIFF []string` List of strings with the MIME types of all the variants that should be served for tiff. - `WebP []string` List of strings with the MIME types of all the variants that should be served for webp. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.Variants.Edit(context.TODO(), cache.VariantEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Value: cloudflare.F(cache.VariantEditParamsValue{ }), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "variants", "editable": true, "value": { "avif": [ "image/webp", "image/jpeg" ], "bmp": [ "image/webp", "image/jpeg" ], "gif": [ "image/webp", "image/jpeg" ], "jp2": [ "image/webp", "image/avif" ], "jpeg": [ "image/webp", "image/avif" ], "jpg": [ "image/webp", "image/avif" ], "jpg2": [ "image/webp", "image/avif" ], "png": [ "image/webp", "image/avif" ], "tif": [ "image/webp", "image/avif" ], "tiff": [ "image/webp", "image/avif" ], "webp": [ "image/jpeg", "image/avif" ] }, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Delete variants setting `client.Cache.Variants.Delete(ctx, body) (*VariantDeleteResponse, error)` **delete** `/zones/{zone_id}/cache/variants` Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers. ### Parameters - `body VariantDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type VariantDeleteResponse struct{…}` - `ID VariantDeleteResponseID` The identifier of the caching setting. - `const VariantDeleteResponseIDVariants VariantDeleteResponseID = "variants"` - `Editable bool` Whether the setting is editable. - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) variant, err := client.Cache.Variants.Delete(context.TODO(), cache.VariantDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", variant.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "variants", "editable": true, "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Domain Types ### Cache Variant - `type CacheVariant struct{…}` Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers. - `ID CacheVariantID` ID of the zone setting. - `const CacheVariantIDVariants CacheVariantID = "variants"` - `ModifiedOn Time` Last time this setting was modified. # Regional Tiered Cache ## Get Regional Tiered Cache setting `client.Cache.RegionalTieredCache.Get(ctx, query) (*RegionalTieredCacheGetResponse, error)` **get** `/zones/{zone_id}/cache/regional_tiered_cache` Instructs Cloudflare to check a regional hub data center on the way to your upper tier. This can help improve performance for smart and custom tiered cache topologies. ### Parameters - `query RegionalTieredCacheGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RegionalTieredCacheGetResponse struct{…}` - `ID RegionalTieredCache` The identifier of the caching setting. - `const RegionalTieredCacheTcRegional RegionalTieredCache = "tc_regional"` - `Editable bool` Whether the setting is editable. - `Value RegionalTieredCacheGetResponseValue` Value of the Regional Tiered Cache zone setting. - `const RegionalTieredCacheGetResponseValueOn RegionalTieredCacheGetResponseValue = "on"` - `const RegionalTieredCacheGetResponseValueOff RegionalTieredCacheGetResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) regionalTieredCache, err := client.Cache.RegionalTieredCache.Get(context.TODO(), cache.RegionalTieredCacheGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", regionalTieredCache.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tc_regional", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Change Regional Tiered Cache setting `client.Cache.RegionalTieredCache.Edit(ctx, params) (*RegionalTieredCacheEditResponse, error)` **patch** `/zones/{zone_id}/cache/regional_tiered_cache` Instructs Cloudflare to check a regional hub data center on the way to your upper tier. This can help improve performance for smart and custom tiered cache topologies. ### Parameters - `params RegionalTieredCacheEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Value param.Field[RegionalTieredCacheEditParamsValue]` Body param: Value of the Regional Tiered Cache zone setting. - `const RegionalTieredCacheEditParamsValueOn RegionalTieredCacheEditParamsValue = "on"` - `const RegionalTieredCacheEditParamsValueOff RegionalTieredCacheEditParamsValue = "off"` ### Returns - `type RegionalTieredCacheEditResponse struct{…}` - `ID RegionalTieredCache` The identifier of the caching setting. - `const RegionalTieredCacheTcRegional RegionalTieredCache = "tc_regional"` - `Editable bool` Whether the setting is editable. - `Value RegionalTieredCacheEditResponseValue` Value of the Regional Tiered Cache zone setting. - `const RegionalTieredCacheEditResponseValueOn RegionalTieredCacheEditResponseValue = "on"` - `const RegionalTieredCacheEditResponseValueOff RegionalTieredCacheEditResponseValue = "off"` - `ModifiedOn Time` Last time this setting was modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.RegionalTieredCache.Edit(context.TODO(), cache.RegionalTieredCacheEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Value: cloudflare.F(cache.RegionalTieredCacheEditParamsValueOn), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "tc_regional", "editable": true, "value": "on", "modified_on": "2014-01-01T05:20:00.12345Z" } } ``` ## Domain Types ### Regional Tiered Cache - `type RegionalTieredCache string` The identifier of the caching setting. - `const RegionalTieredCacheTcRegional RegionalTieredCache = "tc_regional"` # Origin Cloud Regions ## List origin cloud region mappings `client.Cache.OriginCloudRegions.List(ctx, params) (*V4PagePaginationArray[OriginCloudRegion], error)` **get** `/zones/{zone_id}/origin/cloud_regions` Returns all IP-to-cloud-region mappings configured for the zone with pagination support. Each mapping tells Cloudflare which cloud vendor and region hosts the origin at that IP, enabling the edge to route via the nearest Tiered Cache upper-tier co-located with that cloud provider. Returns an empty array when no mappings exist. ### Parameters - `params OriginCloudRegionListParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Page param.Field[int64]` Query param: Page number of paginated results. - `PerPage param.Field[int64]` Query param: Number of items per page. ### Returns - `type OriginCloudRegion struct{…}` A single origin IP-to-cloud-region mapping. - `OriginIP string` The origin IP address (IPv4 or IPv6). Normalized to canonical form (RFC 5952 for IPv6). - `Region string` Cloud vendor region identifier. - `Vendor OriginCloudRegionVendor` Cloud vendor hosting the origin. - `const OriginCloudRegionVendorAws OriginCloudRegionVendor = "aws"` - `const OriginCloudRegionVendorAzure OriginCloudRegionVendor = "azure"` - `const OriginCloudRegionVendorGcp OriginCloudRegionVendor = "gcp"` - `const OriginCloudRegionVendorOci OriginCloudRegionVendor = "oci"` - `ModifiedOn Time` Time this mapping was last modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.Cache.OriginCloudRegions.List(context.TODO(), cache.OriginCloudRegionListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [], "messages": [], "result": [], "result_info": { "count": 0, "page": 1, "per_page": 20, "total_count": 0, "total_pages": 0 }, "success": true } ``` ## Get an origin cloud region mapping `client.Cache.OriginCloudRegions.Get(ctx, originIP, query) (*OriginCloudRegion, error)` **get** `/zones/{zone_id}/origin/cloud_regions/{origin_ip}` Returns the cloud region mapping for a single origin IP address. The IP path parameter is normalized before lookup (RFC 5952 for IPv6). Returns 404 if the zone has no mappings or if the specified IP has no mapping. ### Parameters - `originIP string` - `query OriginCloudRegionGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type OriginCloudRegion struct{…}` A single origin IP-to-cloud-region mapping. - `OriginIP string` The origin IP address (IPv4 or IPv6). Normalized to canonical form (RFC 5952 for IPv6). - `Region string` Cloud vendor region identifier. - `Vendor OriginCloudRegionVendor` Cloud vendor hosting the origin. - `const OriginCloudRegionVendorAws OriginCloudRegionVendor = "aws"` - `const OriginCloudRegionVendorAzure OriginCloudRegionVendor = "azure"` - `const OriginCloudRegionVendorGcp OriginCloudRegionVendor = "gcp"` - `const OriginCloudRegionVendorOci OriginCloudRegionVendor = "oci"` - `ModifiedOn Time` Time this mapping was last modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) originCloudRegion, err := client.Cache.OriginCloudRegions.Get( context.TODO(), "192.0.2.1", cache.OriginCloudRegionGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", originCloudRegion.OriginIP) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "modified_on": "2026-03-01T12:00:00Z", "origin_ip": "192.0.2.1", "region": "us-east-1", "vendor": "aws" }, "success": true } ``` ## Create or replace an origin cloud region mapping `client.Cache.OriginCloudRegions.Update(ctx, originIP, params) (*OriginCloudRegion, error)` **put** `/zones/{zone_id}/origin/cloud_regions/{origin_ip}` Creates a new IP-to-cloud-region mapping or replaces the existing mapping for the specified IP. PUT is idempotent — calling it repeatedly with the same body produces the same result. The IP path parameter is normalized to canonical form (RFC 5952 for IPv6) before storage. The vendor and region are validated against the list from `GET /zones/{zone_id}/origin/cloud_regions/supported_regions`. Returns 400 if the `origin_ip` in the body does not match the URL path parameter. Returns 403 (code 1164) when the zone has reached the limit of 3,500 IP mappings. ### Parameters - `originIP string` - `params OriginCloudRegionUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `OriginIP param.Field[string]` Body param: Origin IP address (IPv4 or IPv6). For the single PUT endpoint (`PUT /origin/cloud_regions/{origin_ip}`), this field must match the path parameter or the request will be rejected with a 400 error. For the batch PUT endpoint, this field identifies which mapping to upsert. - `Region param.Field[string]` Body param: Cloud vendor region identifier. Must be a valid region for the specified vendor as returned by the supported_regions endpoint. - `Vendor param.Field[OriginCloudRegionUpdateParamsVendor]` Body param: Cloud vendor hosting the origin. Must be one of the supported vendors. - `const OriginCloudRegionUpdateParamsVendorAws OriginCloudRegionUpdateParamsVendor = "aws"` - `const OriginCloudRegionUpdateParamsVendorAzure OriginCloudRegionUpdateParamsVendor = "azure"` - `const OriginCloudRegionUpdateParamsVendorGcp OriginCloudRegionUpdateParamsVendor = "gcp"` - `const OriginCloudRegionUpdateParamsVendorOci OriginCloudRegionUpdateParamsVendor = "oci"` ### Returns - `type OriginCloudRegion struct{…}` A single origin IP-to-cloud-region mapping. - `OriginIP string` The origin IP address (IPv4 or IPv6). Normalized to canonical form (RFC 5952 for IPv6). - `Region string` Cloud vendor region identifier. - `Vendor OriginCloudRegionVendor` Cloud vendor hosting the origin. - `const OriginCloudRegionVendorAws OriginCloudRegionVendor = "aws"` - `const OriginCloudRegionVendorAzure OriginCloudRegionVendor = "azure"` - `const OriginCloudRegionVendorGcp OriginCloudRegionVendor = "gcp"` - `const OriginCloudRegionVendorOci OriginCloudRegionVendor = "oci"` - `ModifiedOn Time` Time this mapping was last modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) originCloudRegion, err := client.Cache.OriginCloudRegions.Update( context.TODO(), "192.0.2.1", cache.OriginCloudRegionUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), OriginIP: cloudflare.F("192.0.2.1"), Region: cloudflare.F("us-east-1"), Vendor: cloudflare.F(cache.OriginCloudRegionUpdateParamsVendorAws), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", originCloudRegion.OriginIP) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "modified_on": "2026-03-01T12:00:00Z", "origin_ip": "192.0.2.1", "region": "us-east-1", "vendor": "aws" }, "success": true } ``` ## Delete an origin cloud region mapping `client.Cache.OriginCloudRegions.Delete(ctx, originIP, body) (*OriginCloudRegionDeleteResponse, error)` **delete** `/zones/{zone_id}/origin/cloud_regions/{origin_ip}` Removes the cloud region mapping for a single origin IP address. The IP path parameter is normalized before lookup. Returns the deleted IP on success. Returns 404 if no mapping exists for the specified IP. When the last mapping for the zone is removed the underlying rule record is also deleted. ### Parameters - `originIP string` - `body OriginCloudRegionDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type OriginCloudRegionDeleteResponse struct{…}` Response result for a delete operation. Identifies the deleted mapping. - `OriginIP string` The origin IP address whose mapping was deleted. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) originCloudRegion, err := client.Cache.OriginCloudRegions.Delete( context.TODO(), "192.0.2.1", cache.OriginCloudRegionDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", originCloudRegion.OriginIP) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "origin_ip": "192.0.2.1" }, "success": true } ``` ## Batch create or replace origin cloud region mappings `client.Cache.OriginCloudRegions.BulkUpdate(ctx, params) (*OriginCloudRegionBulkUpdateResponse, error)` **put** `/zones/{zone_id}/origin/cloud_regions/batch` Upserts up to 100 IP-to-cloud-region mappings in a single request. Items in the request body are created or replaced; mappings not included in the request body are preserved unchanged (this is a merge operation, not a full collection replacement). Each item is validated independently — valid items are applied and invalid items are returned in the `failed` array. The vendor and region for every item are validated against the list from `GET /zones/{zone_id}/origin/cloud_regions/supported_regions`. ### Parameters - `params OriginCloudRegionBulkUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Body param.Field[[]OriginCloudRegionBulkUpdateParamsBody]` Body param - `OriginIP string` Origin IP address (IPv4 or IPv6). For the single PUT endpoint (`PUT /origin/cloud_regions/{origin_ip}`), this field must match the path parameter or the request will be rejected with a 400 error. For the batch PUT endpoint, this field identifies which mapping to upsert. - `Region string` Cloud vendor region identifier. Must be a valid region for the specified vendor as returned by the supported_regions endpoint. - `Vendor OriginCloudRegionBulkUpdateParamsBodyVendor` Cloud vendor hosting the origin. Must be one of the supported vendors. - `const OriginCloudRegionBulkUpdateParamsBodyVendorAws OriginCloudRegionBulkUpdateParamsBodyVendor = "aws"` - `const OriginCloudRegionBulkUpdateParamsBodyVendorAzure OriginCloudRegionBulkUpdateParamsBodyVendor = "azure"` - `const OriginCloudRegionBulkUpdateParamsBodyVendorGcp OriginCloudRegionBulkUpdateParamsBodyVendor = "gcp"` - `const OriginCloudRegionBulkUpdateParamsBodyVendorOci OriginCloudRegionBulkUpdateParamsBodyVendor = "oci"` ### Returns - `type OriginCloudRegionBulkUpdateResponse struct{…}` Response result for a batch origin cloud region operation. - `Failed []OriginCloudRegionBulkUpdateResponseFailed` Items that could not be applied, with error details. - `OriginIP string` The origin IP address for this item. - `Error string` Error message explaining why the item failed. Present only on failed items. - `Region string` Cloud vendor region identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). - `Vendor string` Cloud vendor identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). - `Succeeded []OriginCloudRegionBulkUpdateResponseSucceeded` Items that were successfully applied. - `OriginIP string` The origin IP address for this item. - `Error string` Error message explaining why the item failed. Present only on failed items. - `Region string` Cloud vendor region identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). - `Vendor string` Cloud vendor identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.OriginCloudRegions.BulkUpdate(context.TODO(), cache.OriginCloudRegionBulkUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: []cache.OriginCloudRegionBulkUpdateParamsBody{cache.OriginCloudRegionBulkUpdateParamsBody{ OriginIP: cloudflare.F("192.0.2.1"), Region: cloudflare.F("us-east-1"), Vendor: cloudflare.F(cache.OriginCloudRegionBulkUpdateParamsBodyVendorAws), }, cache.OriginCloudRegionBulkUpdateParamsBody{ OriginIP: cloudflare.F("2001:db8::1"), Region: cloudflare.F("us-central1"), Vendor: cloudflare.F(cache.OriginCloudRegionBulkUpdateParamsBodyVendorGcp), }}, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Failed) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "failed": [], "succeeded": [ { "origin_ip": "192.0.2.1", "region": "us-east-1", "vendor": "aws" }, { "origin_ip": "2001:db8::1", "region": "us-central1", "vendor": "gcp" } ] }, "success": true } ``` ## Batch delete origin cloud region mappings `client.Cache.OriginCloudRegions.BulkDelete(ctx, body) (*OriginCloudRegionBulkDeleteResponse, error)` **delete** `/zones/{zone_id}/origin/cloud_regions/batch` Removes up to 100 IP-to-cloud-region mappings in a single request. Each IP is validated independently — successfully deleted items are returned in the `succeeded` array and IPs that could not be found or are invalid are returned in the `failed` array. ### Parameters - `body OriginCloudRegionBulkDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type OriginCloudRegionBulkDeleteResponse struct{…}` Response result for a batch origin cloud region operation. - `Failed []OriginCloudRegionBulkDeleteResponseFailed` Items that could not be applied, with error details. - `OriginIP string` The origin IP address for this item. - `Error string` Error message explaining why the item failed. Present only on failed items. - `Region string` Cloud vendor region identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). - `Vendor string` Cloud vendor identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). - `Succeeded []OriginCloudRegionBulkDeleteResponseSucceeded` Items that were successfully applied. - `OriginIP string` The origin IP address for this item. - `Error string` Error message explaining why the item failed. Present only on failed items. - `Region string` Cloud vendor region identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). - `Vendor string` Cloud vendor identifier. Present on succeeded items (the new value for upsert, the deleted value for delete). ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.OriginCloudRegions.BulkDelete(context.TODO(), cache.OriginCloudRegionBulkDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Failed) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "failed": [], "succeeded": [ { "origin_ip": "192.0.2.1", "region": "us-east-1", "vendor": "aws" }, { "origin_ip": "2001:db8::1", "region": "us-central1", "vendor": "gcp" } ] }, "success": true } ``` ## List supported cloud vendors and regions `client.Cache.OriginCloudRegions.SupportedRegions(ctx, query) (*OriginCloudRegionSupportedRegionsResponse, error)` **get** `/zones/{zone_id}/origin/cloud_regions/supported_regions` Returns the cloud vendors and regions that are valid values for origin cloud region mappings. Each region includes the Tiered Cache upper-tier colocation codes that will be used for cache routing when a mapping targeting that region is active. Requires the zone to have Tiered Cache enabled. ### Parameters - `query OriginCloudRegionSupportedRegionsParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type OriginCloudRegionSupportedRegionsResponse struct{…}` Cloud vendors and their supported regions for origin cloud region mappings. - `ObtainedCodes bool` Whether Cloudflare airport codes (IATA colo identifiers) were successfully resolved for the `upper_tier_colos` field on each region. When `false`, the `upper_tier_colos` arrays may be empty or incomplete. - `Vendors map[string, []OriginCloudRegionSupportedRegionsResponseVendor]` Map of vendor name to list of supported regions. - `Name string` Cloud vendor region identifier. - `UpperTierColos []string` Cloudflare Tiered Cache upper-tier colocation codes co-located with this cloud region. Requests from zones with a matching origin mapping will be routed through these colos. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Cache.OriginCloudRegions.SupportedRegions(context.TODO(), cache.OriginCloudRegionSupportedRegionsParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ObtainedCodes) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "obtained_codes": true, "vendors": { "aws": [ { "name": "us-east-1", "upper_tier_colos": [ "IAD", "EWR" ] }, { "name": "us-west-2", "upper_tier_colos": [ "SEA" ] } ], "gcp": [ { "name": "us-central1", "upper_tier_colos": [ "ORD" ] } ] } }, "success": true } ``` ## Domain Types ### Origin Cloud Region - `type OriginCloudRegion struct{…}` A single origin IP-to-cloud-region mapping. - `OriginIP string` The origin IP address (IPv4 or IPv6). Normalized to canonical form (RFC 5952 for IPv6). - `Region string` Cloud vendor region identifier. - `Vendor OriginCloudRegionVendor` Cloud vendor hosting the origin. - `const OriginCloudRegionVendorAws OriginCloudRegionVendor = "aws"` - `const OriginCloudRegionVendorAzure OriginCloudRegionVendor = "azure"` - `const OriginCloudRegionVendorGcp OriginCloudRegionVendor = "gcp"` - `const OriginCloudRegionVendorOci OriginCloudRegionVendor = "oci"` - `ModifiedOn Time` Time this mapping was last modified.