Skip to content
Start here

Detach Domain

client.Workers.Domains.Delete(ctx, domainID, body) (*DomainDeleteResponse, error)
DELETE/accounts/{account_id}/workers/domains/{domain_id}

Detaches a domain from a Worker. Both the Worker and all of its previews are no longer routable using this domain.

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)
Workers Scripts Write
ParametersExpand Collapse
domainID string

ID of the domain.

body DomainDeleteParams
AccountID param.Field[string]

Identifier.

maxLength32
ReturnsExpand Collapse
type DomainDeleteResponse struct{…}
Errors []DomainDeleteResponseError
Code int64
minimum1000
Message string
DocumentationURL stringoptional
Source DomainDeleteResponseErrorsSourceoptional
Pointer stringoptional
Messages []DomainDeleteResponseMessage
Code int64
minimum1000
Message string
DocumentationURL stringoptional
Source DomainDeleteResponseMessagesSourceoptional
Pointer stringoptional
Success DomainDeleteResponseSuccess

Whether the API call was successful.

Detach Domain

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  domain, err := client.Workers.Domains.Delete(
    context.TODO(),
    "dbe10b4bc17c295377eabd600e1787fd",
    workers.DomainDeleteParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", domain.Errors)
}
{
  "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
}
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
}