Skip to content
Start here

Change Image Transformations Allowed Origins setting

client.Zones.TransformationsAllowedOrigins.Edit(ctx, params) (*TransformationsAllowedOrigins, error)
PATCH/zones/{zone_id}/settings/transformations_allowed_origins

Media Transformations Allowed Origins restricts transformations for images and video served through Cloudflare’s network to requests originating from specified domains. Refer to the Image Transformations and Video Transformations documentation for more information.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Zone Settings Write
ParametersExpand Collapse
params TransformationsAllowedOriginEditParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Value param.Field[string]

Body param: Comma-separated list of allowed origin domains for image and video transformations. Use ”*” to allow all origins (default).

ReturnsExpand Collapse
type TransformationsAllowedOrigins struct{…}

Controls which origins are allowed to request image and video transformations.

ID TransformationsAllowedOriginsIDOptional

ID of the zone setting.

Editable TransformationsAllowedOriginsEditableOptional

Whether or not this setting can be modified for this zone (based on your Cloudflare plan level).

One of the following:
const TransformationsAllowedOriginsEditableTrue TransformationsAllowedOriginsEditable = true
const TransformationsAllowedOriginsEditableFalse TransformationsAllowedOriginsEditable = false
ModifiedOn TimeOptional

last time this setting was modified.

formatdate-time
Value TransformationsAllowedOriginsValueOptional

Comma-separated list of allowed origin domains for image and video transformations. Use ”*” to allow all origins (default).

One of the following:
const TransformationsAllowedOriginsValueOn TransformationsAllowedOriginsValue = "on"
const TransformationsAllowedOriginsValueOff TransformationsAllowedOriginsValue = "off"

Change Image Transformations Allowed Origins setting

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/zones"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  transformationsAllowedOrigins, err := client.Zones.TransformationsAllowedOrigins.Edit(context.TODO(), zones.TransformationsAllowedOriginEditParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Value: cloudflare.F("example.com,cdn.example.com"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", transformationsAllowedOrigins.ID)
}
{
  "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": "image_resizing_allowed_origins",
    "editable": true,
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "value": "on"
  }
}
Returns Examples
{
  "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": "image_resizing_allowed_origins",
    "editable": true,
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "value": "on"
  }
}