Skip to content
Start here

Batch trusted domains operations

client.EmailSecurity.Settings.TrustedDomains.Batch(ctx, params) (*SettingTrustedDomainBatchResponse, error)
POST/accounts/{account_id}/email-security/settings/trusted_domains/batch

Executes multiple operations atomically. All four operation arrays (deletes, patches, puts, posts) are required and executed in order. Send empty arrays for unused operations.

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)
Cloud Email Security: Write
ParametersExpand Collapse
params SettingTrustedDomainBatchParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
Deletes param.Field[[]SettingTrustedDomainBatchParamsDelete]

Body param

ID string

Trusted domain identifier.

formatuuid
Patches param.Field[[]SettingTrustedDomainBatchParamsPatch]

Body param

ID string

Trusted domain identifier.

formatuuid
Comments stringOptional
maxLength1024
CreatedAt TimeOptional
formatdate-time
IsRecent boolOptional

Select to prevent recently registered domains from triggering a Suspicious or Malicious disposition.

IsRegex boolOptional
IsSimilarity boolOptional

Select for partner or other approved domains that have similar spelling to your connected domains. Prevents listed domains from triggering a Spoof disposition.

DeprecatedLastModified TimeOptional

Use modified_at instead.

Deprecated, use modified_at instead. End of life: November 1, 2026.

formatdate-time
ModifiedAt TimeOptional
formatdate-time
Pattern stringOptional
maxLength1024
minLength1
Posts param.Field[[]SettingTrustedDomainBatchParamsPost]

Body param

IsRecent bool

Select to prevent recently registered domains from triggering a Suspicious or Malicious disposition.

IsRegex bool
IsSimilarity bool

Select for partner or other approved domains that have similar spelling to your connected domains. Prevents listed domains from triggering a Spoof disposition.

Pattern string
maxLength1024
minLength1
ID stringOptional

Trusted domain identifier.

formatuuid
Comments stringOptional
maxLength1024
CreatedAt TimeOptional
formatdate-time
DeprecatedLastModified TimeOptional

Use modified_at instead.

Deprecated, use modified_at instead. End of life: November 1, 2026.

formatdate-time
ModifiedAt TimeOptional
formatdate-time
Puts param.Field[[]SettingTrustedDomainBatchParamsPut]

Body param

ID string

Trusted domain identifier.

formatuuid
IsRecent bool

Select to prevent recently registered domains from triggering a Suspicious or Malicious disposition.

IsRegex bool
IsSimilarity bool

Select for partner or other approved domains that have similar spelling to your connected domains. Prevents listed domains from triggering a Spoof disposition.

Pattern string
maxLength1024
minLength1
Comments stringOptional
maxLength1024
CreatedAt TimeOptional
formatdate-time
DeprecatedLastModified TimeOptional

Use modified_at instead.

Deprecated, use modified_at instead. End of life: November 1, 2026.

formatdate-time
ModifiedAt TimeOptional
formatdate-time
ReturnsExpand Collapse
type SettingTrustedDomainBatchResponse struct{…}
Deletes []SettingTrustedDomainBatchResponseDeleteOptional
ID string

Trusted domain identifier.

formatuuid
Patches []SettingTrustedDomainBatchResponsePatchOptional
ID stringOptional

Trusted domain identifier.

formatuuid
Comments stringOptional
maxLength1024
CreatedAt TimeOptional
formatdate-time
IsRecent boolOptional

Select to prevent recently registered domains from triggering a Suspicious or Malicious disposition.

IsRegex boolOptional
IsSimilarity boolOptional

Select for partner or other approved domains that have similar spelling to your connected domains. Prevents listed domains from triggering a Spoof disposition.

DeprecatedLastModified TimeOptional

Use modified_at instead.

Deprecated, use modified_at instead. End of life: November 1, 2026.

formatdate-time
ModifiedAt TimeOptional
formatdate-time
Pattern stringOptional
maxLength1024
minLength1
Posts []SettingTrustedDomainBatchResponsePostOptional
ID stringOptional

Trusted domain identifier.

formatuuid
Comments stringOptional
maxLength1024
CreatedAt TimeOptional
formatdate-time
IsRecent boolOptional

Select to prevent recently registered domains from triggering a Suspicious or Malicious disposition.

IsRegex boolOptional
IsSimilarity boolOptional

Select for partner or other approved domains that have similar spelling to your connected domains. Prevents listed domains from triggering a Spoof disposition.

DeprecatedLastModified TimeOptional

Use modified_at instead.

Deprecated, use modified_at instead. End of life: November 1, 2026.

formatdate-time
ModifiedAt TimeOptional
formatdate-time
Pattern stringOptional
maxLength1024
minLength1
Puts []SettingTrustedDomainBatchResponsePutOptional
ID stringOptional

Trusted domain identifier.

formatuuid
Comments stringOptional
maxLength1024
CreatedAt TimeOptional
formatdate-time
IsRecent boolOptional

Select to prevent recently registered domains from triggering a Suspicious or Malicious disposition.

IsRegex boolOptional
IsSimilarity boolOptional

Select for partner or other approved domains that have similar spelling to your connected domains. Prevents listed domains from triggering a Spoof disposition.

DeprecatedLastModified TimeOptional

Use modified_at instead.

Deprecated, use modified_at instead. End of life: November 1, 2026.

formatdate-time
ModifiedAt TimeOptional
formatdate-time
Pattern stringOptional
maxLength1024
minLength1

Batch trusted domains operations

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.EmailSecurity.Settings.TrustedDomains.Batch(context.TODO(), email_security.SettingTrustedDomainBatchParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Deletes: cloudflare.F([]email_security.SettingTrustedDomainBatchParamsDelete{email_security.SettingTrustedDomainBatchParamsDelete{
      ID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"),
    }}),
    Patches: cloudflare.F([]email_security.SettingTrustedDomainBatchParamsPatch{email_security.SettingTrustedDomainBatchParamsPatch{

    }}),
    Posts: cloudflare.F([]email_security.SettingTrustedDomainBatchParamsPost{email_security.SettingTrustedDomainBatchParamsPost{
      IsRecent: cloudflare.F(true),
      IsRegex: cloudflare.F(false),
      IsSimilarity: cloudflare.F(false),
      Pattern: cloudflare.F("example.com"),
    }}),
    Puts: cloudflare.F([]email_security.SettingTrustedDomainBatchParamsPut{email_security.SettingTrustedDomainBatchParamsPut{
      IsRecent: cloudflare.F(true),
      IsRegex: cloudflare.F(false),
      IsSimilarity: cloudflare.F(false),
      Pattern: cloudflare.F("example.com"),
    }}),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Deletes)
}
{
  "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": {
    "deletes": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
      }
    ],
    "patches": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
        "comments": "Trusted partner domain",
        "created_at": "2014-01-01T05:20:00.12345Z",
        "is_recent": true,
        "is_regex": false,
        "is_similarity": false,
        "last_modified": "2014-01-01T05:20:00.12345Z",
        "modified_at": "2014-01-01T05:20:00.12345Z",
        "pattern": "example.com"
      }
    ],
    "posts": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
        "comments": "Trusted partner domain",
        "created_at": "2014-01-01T05:20:00.12345Z",
        "is_recent": true,
        "is_regex": false,
        "is_similarity": false,
        "last_modified": "2014-01-01T05:20:00.12345Z",
        "modified_at": "2014-01-01T05:20:00.12345Z",
        "pattern": "example.com"
      }
    ],
    "puts": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
        "comments": "Trusted partner domain",
        "created_at": "2014-01-01T05:20:00.12345Z",
        "is_recent": true,
        "is_regex": false,
        "is_similarity": false,
        "last_modified": "2014-01-01T05:20:00.12345Z",
        "modified_at": "2014-01-01T05:20:00.12345Z",
        "pattern": "example.com"
      }
    ]
  }
}
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": {
    "deletes": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"
      }
    ],
    "patches": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
        "comments": "Trusted partner domain",
        "created_at": "2014-01-01T05:20:00.12345Z",
        "is_recent": true,
        "is_regex": false,
        "is_similarity": false,
        "last_modified": "2014-01-01T05:20:00.12345Z",
        "modified_at": "2014-01-01T05:20:00.12345Z",
        "pattern": "example.com"
      }
    ],
    "posts": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
        "comments": "Trusted partner domain",
        "created_at": "2014-01-01T05:20:00.12345Z",
        "is_recent": true,
        "is_regex": false,
        "is_similarity": false,
        "last_modified": "2014-01-01T05:20:00.12345Z",
        "modified_at": "2014-01-01T05:20:00.12345Z",
        "pattern": "example.com"
      }
    ],
    "puts": [
      {
        "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
        "comments": "Trusted partner domain",
        "created_at": "2014-01-01T05:20:00.12345Z",
        "is_recent": true,
        "is_regex": false,
        "is_similarity": false,
        "last_modified": "2014-01-01T05:20:00.12345Z",
        "modified_at": "2014-01-01T05:20:00.12345Z",
        "pattern": "example.com"
      }
    ]
  }
}