Skip to content
Start here

Configure Custom Domain Settings

client.R2.Buckets.Domains.Custom.Update(ctx, bucketName, domain, params) (*BucketDomainCustomUpdateResponse, error)
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}

Edit the configuration for a custom domain on an existing R2 bucket.

Security

API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
ParametersExpand Collapse
bucketName string

Name of the bucket.

maxLength64
minLength3
domain string

Name of the custom domain.

params BucketDomainCustomUpdateParams
AccountID param.Field[string]

Path param: Account ID.

maxLength32
Ciphers param.Field[[]string]optional

Body param: An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format.

Enabled param.Field[bool]optional

Body param: Whether to enable public bucket access at the specified custom domain.

MinTLS param.Field[BucketDomainCustomUpdateParamsMinTLS]optional

Body param: Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to previous value.

const BucketDomainCustomUpdateParamsMinTLS1_0 BucketDomainCustomUpdateParamsMinTLS = "1.0"
const BucketDomainCustomUpdateParamsMinTLS1_1 BucketDomainCustomUpdateParamsMinTLS = "1.1"
const BucketDomainCustomUpdateParamsMinTLS1_2 BucketDomainCustomUpdateParamsMinTLS = "1.2"
const BucketDomainCustomUpdateParamsMinTLS1_3 BucketDomainCustomUpdateParamsMinTLS = "1.3"
Jurisdiction param.Field[BucketDomainCustomUpdateParamsCfR2Jurisdiction]optional

Header param: Jurisdiction where objects in this bucket are guaranteed to be stored.

const BucketDomainCustomUpdateParamsCfR2JurisdictionDefault BucketDomainCustomUpdateParamsCfR2Jurisdiction = "default"
const BucketDomainCustomUpdateParamsCfR2JurisdictionEu BucketDomainCustomUpdateParamsCfR2Jurisdiction = "eu"
const BucketDomainCustomUpdateParamsCfR2JurisdictionFedramp BucketDomainCustomUpdateParamsCfR2Jurisdiction = "fedramp"
ReturnsExpand Collapse
type BucketDomainCustomUpdateResponse struct{…}
Domain string

Domain name of the affected custom domain.

Ciphers []stringoptional

An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format.

Enabled booloptional

Whether this bucket is publicly accessible at the specified custom domain.

MinTLS BucketDomainCustomUpdateResponseMinTLSoptional

Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0.

One of the following:
const BucketDomainCustomUpdateResponseMinTLS1_0 BucketDomainCustomUpdateResponseMinTLS = "1.0"
const BucketDomainCustomUpdateResponseMinTLS1_1 BucketDomainCustomUpdateResponseMinTLS = "1.1"
const BucketDomainCustomUpdateResponseMinTLS1_2 BucketDomainCustomUpdateResponseMinTLS = "1.2"
const BucketDomainCustomUpdateResponseMinTLS1_3 BucketDomainCustomUpdateResponseMinTLS = "1.3"

Configure Custom Domain Settings

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  custom, err := client.R2.Buckets.Domains.Custom.Update(
    context.TODO(),
    "example-bucket",
    "example-domain/custom-domain.com",
    r2.BucketDomainCustomUpdateParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", custom.Domain)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "domain": "example-domain.com",
    "ciphers": [
      "string"
    ],
    "enabled": true,
    "minTLS": "1.0"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "domain": "example-domain.com",
    "ciphers": [
      "string"
    ],
    "enabled": true,
    "minTLS": "1.0"
  },
  "success": true
}