Skip to content
Start here

Remove Custom Domain From Bucket

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

Remove custom domain registration from an existing R2 bucket.

Security

API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Workers R2 Storage Write
ParametersExpand Collapse
bucketName string

Name of the bucket.

maxLength64
minLength3
domain string

Name of the custom domain.

params BucketDomainCustomDeleteParams
AccountID param.Field[string]

Path param: Account ID.

maxLength32
Jurisdiction param.Field[BucketDomainCustomDeleteParamsCfR2Jurisdiction]optional

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

const BucketDomainCustomDeleteParamsCfR2JurisdictionDefault BucketDomainCustomDeleteParamsCfR2Jurisdiction = "default"
const BucketDomainCustomDeleteParamsCfR2JurisdictionEu BucketDomainCustomDeleteParamsCfR2Jurisdiction = "eu"
const BucketDomainCustomDeleteParamsCfR2JurisdictionFedramp BucketDomainCustomDeleteParamsCfR2Jurisdiction = "fedramp"
ReturnsExpand Collapse
type BucketDomainCustomDeleteResponse struct{…}
Domain string

Name of the removed custom domain.

Remove Custom Domain From Bucket

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.Delete(
    context.TODO(),
    "example-bucket",
    "example-domain/custom-domain.com",
    r2.BucketDomainCustomDeleteParams{
      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/custom-domain.com"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "domain": "example-domain/custom-domain.com"
  },
  "success": true
}