# Email Routing ## Get Email Routing settings `client.EmailRouting.Get(ctx, query) (*Settings, error)` **get** `/zones/{zone_id}/email/routing` Get information about the settings for your Email Routing zone. ### Parameters - `query EmailRoutingGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type Settings struct{…}` - `ID string` Email Routing settings identifier. - `Enabled SettingsEnabled` State of the zone settings for Email Routing. - `const SettingsEnabledTrue SettingsEnabled = true` - `const SettingsEnabledFalse SettingsEnabled = false` - `Name string` Domain of your zone. - `Created Time` The date and time the settings have been created. - `Modified Time` The date and time the settings have been modified. - `SkipWizard SettingsSkipWizard` Flag to check if the user skipped the configuration wizard. - `const SettingsSkipWizardTrue SettingsSkipWizard = true` - `const SettingsSkipWizardFalse SettingsSkipWizard = false` - `Status SettingsStatus` Show the state of your account, and the type or configuration error. - `const SettingsStatusReady SettingsStatus = "ready"` - `const SettingsStatusUnconfigured SettingsStatus = "unconfigured"` - `const SettingsStatusMisconfigured SettingsStatus = "misconfigured"` - `const SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked"` - `const SettingsStatusUnlocked SettingsStatus = "unlocked"` - `Tag string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) settings, err := client.EmailRouting.Get(context.TODO(), email_routing.EmailRoutingGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", settings.ID) } ``` #### Response ```json { "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": "75610dab9e69410a82cf7e400a09ecec", "enabled": true, "name": "example.net", "created": "2014-01-02T02:20:00Z", "modified": "2014-01-02T02:20:00Z", "skip_wizard": true, "status": "ready", "tag": "75610dab9e69410a82cf7e400a09ecec" } } ``` ## Disable Email Routing `client.EmailRouting.Disable(ctx, params) (*Settings, error)` **post** `/zones/{zone_id}/email/routing/disable` Disable your Email Routing zone. Also removes additional MX records previously required for Email Routing to work. ### Parameters - `params EmailRoutingDisableParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Body param.Field[unknown]` Body param ### Returns - `type Settings struct{…}` - `ID string` Email Routing settings identifier. - `Enabled SettingsEnabled` State of the zone settings for Email Routing. - `const SettingsEnabledTrue SettingsEnabled = true` - `const SettingsEnabledFalse SettingsEnabled = false` - `Name string` Domain of your zone. - `Created Time` The date and time the settings have been created. - `Modified Time` The date and time the settings have been modified. - `SkipWizard SettingsSkipWizard` Flag to check if the user skipped the configuration wizard. - `const SettingsSkipWizardTrue SettingsSkipWizard = true` - `const SettingsSkipWizardFalse SettingsSkipWizard = false` - `Status SettingsStatus` Show the state of your account, and the type or configuration error. - `const SettingsStatusReady SettingsStatus = "ready"` - `const SettingsStatusUnconfigured SettingsStatus = "unconfigured"` - `const SettingsStatusMisconfigured SettingsStatus = "misconfigured"` - `const SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked"` - `const SettingsStatusUnlocked SettingsStatus = "unlocked"` - `Tag string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) settings, err := client.EmailRouting.Disable(context.TODO(), email_routing.EmailRoutingDisableParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: map[string]interface{}{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", settings.ID) } ``` #### Response ```json { "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": "75610dab9e69410a82cf7e400a09ecec", "enabled": true, "name": "example.net", "created": "2014-01-02T02:20:00Z", "modified": "2014-01-02T02:20:00Z", "skip_wizard": true, "status": "ready", "tag": "75610dab9e69410a82cf7e400a09ecec" } } ``` ## Enable Email Routing `client.EmailRouting.Enable(ctx, params) (*Settings, error)` **post** `/zones/{zone_id}/email/routing/enable` Enable you Email Routing zone. Add and lock the necessary MX and SPF records. ### Parameters - `params EmailRoutingEnableParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Body param.Field[unknown]` Body param ### Returns - `type Settings struct{…}` - `ID string` Email Routing settings identifier. - `Enabled SettingsEnabled` State of the zone settings for Email Routing. - `const SettingsEnabledTrue SettingsEnabled = true` - `const SettingsEnabledFalse SettingsEnabled = false` - `Name string` Domain of your zone. - `Created Time` The date and time the settings have been created. - `Modified Time` The date and time the settings have been modified. - `SkipWizard SettingsSkipWizard` Flag to check if the user skipped the configuration wizard. - `const SettingsSkipWizardTrue SettingsSkipWizard = true` - `const SettingsSkipWizardFalse SettingsSkipWizard = false` - `Status SettingsStatus` Show the state of your account, and the type or configuration error. - `const SettingsStatusReady SettingsStatus = "ready"` - `const SettingsStatusUnconfigured SettingsStatus = "unconfigured"` - `const SettingsStatusMisconfigured SettingsStatus = "misconfigured"` - `const SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked"` - `const SettingsStatusUnlocked SettingsStatus = "unlocked"` - `Tag string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) settings, err := client.EmailRouting.Enable(context.TODO(), email_routing.EmailRoutingEnableParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: map[string]interface{}{ }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", settings.ID) } ``` #### Response ```json { "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": "75610dab9e69410a82cf7e400a09ecec", "enabled": true, "name": "example.net", "created": "2014-01-02T02:20:00Z", "modified": "2014-01-02T02:20:00Z", "skip_wizard": true, "status": "ready", "tag": "75610dab9e69410a82cf7e400a09ecec" } } ``` ## Domain Types ### Settings - `type Settings struct{…}` - `ID string` Email Routing settings identifier. - `Enabled SettingsEnabled` State of the zone settings for Email Routing. - `const SettingsEnabledTrue SettingsEnabled = true` - `const SettingsEnabledFalse SettingsEnabled = false` - `Name string` Domain of your zone. - `Created Time` The date and time the settings have been created. - `Modified Time` The date and time the settings have been modified. - `SkipWizard SettingsSkipWizard` Flag to check if the user skipped the configuration wizard. - `const SettingsSkipWizardTrue SettingsSkipWizard = true` - `const SettingsSkipWizardFalse SettingsSkipWizard = false` - `Status SettingsStatus` Show the state of your account, and the type or configuration error. - `const SettingsStatusReady SettingsStatus = "ready"` - `const SettingsStatusUnconfigured SettingsStatus = "unconfigured"` - `const SettingsStatusMisconfigured SettingsStatus = "misconfigured"` - `const SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked"` - `const SettingsStatusUnlocked SettingsStatus = "unlocked"` - `Tag string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) # DNS ## Email Routing - DNS settings `client.EmailRouting.DNS.Get(ctx, params) (*DNSGetResponse, error)` **get** `/zones/{zone_id}/email/routing/dns` Show the DNS records needed to configure your Email Routing zone. ### Parameters - `params DNSGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Subdomain param.Field[string]` Query param: Domain of your zone. ### Returns - `type DNSGetResponse interface{…}` - `type DNSGetResponseEmailEmailRoutingDNSQueryResponse struct{…}` - `Errors []DNSGetResponseEmailEmailRoutingDNSQueryResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source DNSGetResponseEmailEmailRoutingDNSQueryResponseErrorsSource` - `Pointer string` - `Messages []DNSGetResponseEmailEmailRoutingDNSQueryResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source DNSGetResponseEmailEmailRoutingDNSQueryResponseMessagesSource` - `Pointer string` - `Success DNSGetResponseEmailEmailRoutingDNSQueryResponseSuccess` Whether the API call was successful. - `const DNSGetResponseEmailEmailRoutingDNSQueryResponseSuccessTrue DNSGetResponseEmailEmailRoutingDNSQueryResponseSuccess = true` - `Result DNSGetResponseEmailEmailRoutingDNSQueryResponseResult` - `Errors []DNSGetResponseEmailEmailRoutingDNSQueryResponseResultError` - `Code string` - `Missing DNSRecord` List of records needed to enable an Email Routing zone. - `Content string` DNS record content. - `Name string` DNS record name (or @ for the zone apex). - `Priority float64` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `TTL DNSRecordTTL` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `float64` - `type DNSRecordTTL float64` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `const DNSRecordTTL1 DNSRecordTTL = 1` - `Type DNSRecordType` DNS record type. - `const DNSRecordTypeA DNSRecordType = "A"` - `const DNSRecordTypeAAAA DNSRecordType = "AAAA"` - `const DNSRecordTypeCNAME DNSRecordType = "CNAME"` - `const DNSRecordTypeHTTPS DNSRecordType = "HTTPS"` - `const DNSRecordTypeTXT DNSRecordType = "TXT"` - `const DNSRecordTypeSRV DNSRecordType = "SRV"` - `const DNSRecordTypeLOC DNSRecordType = "LOC"` - `const DNSRecordTypeMX DNSRecordType = "MX"` - `const DNSRecordTypeNS DNSRecordType = "NS"` - `const DNSRecordTypeCERT DNSRecordType = "CERT"` - `const DNSRecordTypeDNSKEY DNSRecordType = "DNSKEY"` - `const DNSRecordTypeDS DNSRecordType = "DS"` - `const DNSRecordTypeNAPTR DNSRecordType = "NAPTR"` - `const DNSRecordTypeSMIMEA DNSRecordType = "SMIMEA"` - `const DNSRecordTypeSSHFP DNSRecordType = "SSHFP"` - `const DNSRecordTypeSVCB DNSRecordType = "SVCB"` - `const DNSRecordTypeTLSA DNSRecordType = "TLSA"` - `const DNSRecordTypeURI DNSRecordType = "URI"` - `Record []DNSRecord` - `Content string` DNS record content. - `Name string` DNS record name (or @ for the zone apex). - `Priority float64` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `TTL DNSRecordTTL` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `Type DNSRecordType` DNS record type. - `ResultInfo DNSGetResponseEmailEmailRoutingDNSQueryResponseResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. - `TotalPages float64` The number of total pages in the entire result set. - `type DNSGetResponseEmailDNSSettingsResponseCollection struct{…}` - `Errors []DNSGetResponseEmailDNSSettingsResponseCollectionError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source DNSGetResponseEmailDNSSettingsResponseCollectionErrorsSource` - `Pointer string` - `Messages []DNSGetResponseEmailDNSSettingsResponseCollectionMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source DNSGetResponseEmailDNSSettingsResponseCollectionMessagesSource` - `Pointer string` - `Success DNSGetResponseEmailDNSSettingsResponseCollectionSuccess` Whether the API call was successful. - `const DNSGetResponseEmailDNSSettingsResponseCollectionSuccessTrue DNSGetResponseEmailDNSSettingsResponseCollectionSuccess = true` - `Result []DNSRecord` - `Content string` DNS record content. - `Name string` DNS record name (or @ for the zone apex). - `Priority float64` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `TTL DNSRecordTTL` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `Type DNSRecordType` DNS record type. - `ResultInfo DNSGetResponseEmailDNSSettingsResponseCollectionResultInfo` - `Count float64` Total number of results for the requested service. - `Page float64` Current page within paginated list of results. - `PerPage float64` Number of results per page of results. - `TotalCount float64` Total results available without any search parameters. - `TotalPages float64` The number of total pages in the entire result set. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) dns, err := client.EmailRouting.DNS.Get(context.TODO(), email_routing.DNSGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dns) } ``` #### Response ```json { "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": { "errors": [ { "code": "code", "missing": { "content": "route1.mx.cloudflare.net", "name": "example.com", "priority": 12, "ttl": 1, "type": "NS" } } ], "record": [ { "content": "route1.mx.cloudflare.net", "name": "example.com", "priority": 12, "ttl": 1, "type": "NS" } ] }, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Enable Email Routing `client.EmailRouting.DNS.New(ctx, params) (*Settings, error)` **post** `/zones/{zone_id}/email/routing/dns` Enable you Email Routing zone. Add and lock the necessary MX and SPF records. ### Parameters - `params DNSNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Domain of your zone. ### Returns - `type Settings struct{…}` - `ID string` Email Routing settings identifier. - `Enabled SettingsEnabled` State of the zone settings for Email Routing. - `const SettingsEnabledTrue SettingsEnabled = true` - `const SettingsEnabledFalse SettingsEnabled = false` - `Name string` Domain of your zone. - `Created Time` The date and time the settings have been created. - `Modified Time` The date and time the settings have been modified. - `SkipWizard SettingsSkipWizard` Flag to check if the user skipped the configuration wizard. - `const SettingsSkipWizardTrue SettingsSkipWizard = true` - `const SettingsSkipWizardFalse SettingsSkipWizard = false` - `Status SettingsStatus` Show the state of your account, and the type or configuration error. - `const SettingsStatusReady SettingsStatus = "ready"` - `const SettingsStatusUnconfigured SettingsStatus = "unconfigured"` - `const SettingsStatusMisconfigured SettingsStatus = "misconfigured"` - `const SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked"` - `const SettingsStatusUnlocked SettingsStatus = "unlocked"` - `Tag string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) settings, err := client.EmailRouting.DNS.New(context.TODO(), email_routing.DNSNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", settings.ID) } ``` #### Response ```json { "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": "75610dab9e69410a82cf7e400a09ecec", "enabled": true, "name": "example.net", "created": "2014-01-02T02:20:00Z", "modified": "2014-01-02T02:20:00Z", "skip_wizard": true, "status": "ready", "tag": "75610dab9e69410a82cf7e400a09ecec" } } ``` ## Unlock Email Routing `client.EmailRouting.DNS.Edit(ctx, params) (*Settings, error)` **patch** `/zones/{zone_id}/email/routing/dns` Unlock MX Records previously locked by Email Routing. ### Parameters - `params DNSEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Domain of your zone. ### Returns - `type Settings struct{…}` - `ID string` Email Routing settings identifier. - `Enabled SettingsEnabled` State of the zone settings for Email Routing. - `const SettingsEnabledTrue SettingsEnabled = true` - `const SettingsEnabledFalse SettingsEnabled = false` - `Name string` Domain of your zone. - `Created Time` The date and time the settings have been created. - `Modified Time` The date and time the settings have been modified. - `SkipWizard SettingsSkipWizard` Flag to check if the user skipped the configuration wizard. - `const SettingsSkipWizardTrue SettingsSkipWizard = true` - `const SettingsSkipWizardFalse SettingsSkipWizard = false` - `Status SettingsStatus` Show the state of your account, and the type or configuration error. - `const SettingsStatusReady SettingsStatus = "ready"` - `const SettingsStatusUnconfigured SettingsStatus = "unconfigured"` - `const SettingsStatusMisconfigured SettingsStatus = "misconfigured"` - `const SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked"` - `const SettingsStatusUnlocked SettingsStatus = "unlocked"` - `Tag string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) settings, err := client.EmailRouting.DNS.Edit(context.TODO(), email_routing.DNSEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", settings.ID) } ``` #### Response ```json { "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": "75610dab9e69410a82cf7e400a09ecec", "enabled": true, "name": "example.net", "created": "2014-01-02T02:20:00Z", "modified": "2014-01-02T02:20:00Z", "skip_wizard": true, "status": "ready", "tag": "75610dab9e69410a82cf7e400a09ecec" } } ``` ## Disable Email Routing `client.EmailRouting.DNS.Delete(ctx, body) (*SinglePage[DNSRecord], error)` **delete** `/zones/{zone_id}/email/routing/dns` Disable your Email Routing zone. Also removes additional MX records previously required for Email Routing to work. ### Parameters - `body DNSDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type DNSRecord struct{…}` List of records needed to enable an Email Routing zone. - `Content string` DNS record content. - `Name string` DNS record name (or @ for the zone apex). - `Priority float64` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `TTL DNSRecordTTL` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `float64` - `type DNSRecordTTL float64` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `const DNSRecordTTL1 DNSRecordTTL = 1` - `Type DNSRecordType` DNS record type. - `const DNSRecordTypeA DNSRecordType = "A"` - `const DNSRecordTypeAAAA DNSRecordType = "AAAA"` - `const DNSRecordTypeCNAME DNSRecordType = "CNAME"` - `const DNSRecordTypeHTTPS DNSRecordType = "HTTPS"` - `const DNSRecordTypeTXT DNSRecordType = "TXT"` - `const DNSRecordTypeSRV DNSRecordType = "SRV"` - `const DNSRecordTypeLOC DNSRecordType = "LOC"` - `const DNSRecordTypeMX DNSRecordType = "MX"` - `const DNSRecordTypeNS DNSRecordType = "NS"` - `const DNSRecordTypeCERT DNSRecordType = "CERT"` - `const DNSRecordTypeDNSKEY DNSRecordType = "DNSKEY"` - `const DNSRecordTypeDS DNSRecordType = "DS"` - `const DNSRecordTypeNAPTR DNSRecordType = "NAPTR"` - `const DNSRecordTypeSMIMEA DNSRecordType = "SMIMEA"` - `const DNSRecordTypeSSHFP DNSRecordType = "SSHFP"` - `const DNSRecordTypeSVCB DNSRecordType = "SVCB"` - `const DNSRecordTypeTLSA DNSRecordType = "TLSA"` - `const DNSRecordTypeURI DNSRecordType = "URI"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.EmailRouting.DNS.Delete(context.TODO(), email_routing.DNSDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "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 } ``` ## Domain Types ### DNS Record - `type DNSRecord struct{…}` List of records needed to enable an Email Routing zone. - `Content string` DNS record content. - `Name string` DNS record name (or @ for the zone apex). - `Priority float64` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `TTL DNSRecordTTL` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `float64` - `type DNSRecordTTL float64` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `const DNSRecordTTL1 DNSRecordTTL = 1` - `Type DNSRecordType` DNS record type. - `const DNSRecordTypeA DNSRecordType = "A"` - `const DNSRecordTypeAAAA DNSRecordType = "AAAA"` - `const DNSRecordTypeCNAME DNSRecordType = "CNAME"` - `const DNSRecordTypeHTTPS DNSRecordType = "HTTPS"` - `const DNSRecordTypeTXT DNSRecordType = "TXT"` - `const DNSRecordTypeSRV DNSRecordType = "SRV"` - `const DNSRecordTypeLOC DNSRecordType = "LOC"` - `const DNSRecordTypeMX DNSRecordType = "MX"` - `const DNSRecordTypeNS DNSRecordType = "NS"` - `const DNSRecordTypeCERT DNSRecordType = "CERT"` - `const DNSRecordTypeDNSKEY DNSRecordType = "DNSKEY"` - `const DNSRecordTypeDS DNSRecordType = "DS"` - `const DNSRecordTypeNAPTR DNSRecordType = "NAPTR"` - `const DNSRecordTypeSMIMEA DNSRecordType = "SMIMEA"` - `const DNSRecordTypeSSHFP DNSRecordType = "SSHFP"` - `const DNSRecordTypeSVCB DNSRecordType = "SVCB"` - `const DNSRecordTypeTLSA DNSRecordType = "TLSA"` - `const DNSRecordTypeURI DNSRecordType = "URI"` # Rules ## List routing rules `client.EmailRouting.Rules.List(ctx, params) (*V4PagePaginationArray[EmailRoutingRule], error)` **get** `/zones/{zone_id}/email/routing/rules` Lists existing routing rules. ### Parameters - `params RuleListParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Enabled param.Field[RuleListParamsEnabled]` Query param: Filter by enabled routing rules. - `const RuleListParamsEnabledTrue RuleListParamsEnabled = true` - `const RuleListParamsEnabledFalse RuleListParamsEnabled = false` - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Maximum number of results per page. ### Returns - `type EmailRoutingRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled EmailRoutingRuleEnabled` Routing rule status. - `const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true` - `const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.EmailRouting.Rules.List(context.TODO(), email_routing.RuleListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "literal", "field": "to", "value": "test@example.com" } ], "name": "Send to user@example.net rule.", "priority": 0, "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 1, "total_pages": 100 } } ``` ## Get routing rule `client.EmailRouting.Rules.Get(ctx, ruleIdentifier, query) (*EmailRoutingRule, error)` **get** `/zones/{zone_id}/email/routing/rules/{rule_identifier}` Get information for a specific routing rule already created. ### Parameters - `ruleIdentifier string` Routing rule identifier. - `query RuleGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type EmailRoutingRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled EmailRoutingRuleEnabled` Routing rule status. - `const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true` - `const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) emailRoutingRule, err := client.EmailRouting.Rules.Get( context.TODO(), "a7e6fb77503c41d8a7f3113c6918f10c", email_routing.RuleGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", emailRoutingRule.ID) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "literal", "field": "to", "value": "test@example.com" } ], "name": "Send to user@example.net rule.", "priority": 0, "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } } ``` ## Create routing rule `client.EmailRouting.Rules.New(ctx, params) (*EmailRoutingRule, error)` **post** `/zones/{zone_id}/email/routing/rules` Rules consist of a set of criteria for matching emails (such as an email being sent to a specific custom email address) plus a set of actions to take on the email (like forwarding it to a specific destination address). ### Parameters - `params RuleNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Actions param.Field[[]Action]` Body param: List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Matchers param.Field[[]Matcher]` Body param: Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Enabled param.Field[RuleNewParamsEnabled]` Body param: Routing rule status. - `const RuleNewParamsEnabledTrue RuleNewParamsEnabled = true` - `const RuleNewParamsEnabledFalse RuleNewParamsEnabled = false` - `Name param.Field[string]` Body param: Routing rule name. - `Priority param.Field[float64]` Body param: Priority of the routing rule. ### Returns - `type EmailRoutingRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled EmailRoutingRuleEnabled` Routing rule status. - `const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true` - `const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) emailRoutingRule, err := client.EmailRouting.Rules.New(context.TODO(), email_routing.RuleNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Actions: cloudflare.F([]email_routing.ActionParam{email_routing.ActionParam{ Type: cloudflare.F(email_routing.ActionTypeForward), }}), Matchers: cloudflare.F([]email_routing.MatcherParam{email_routing.MatcherParam{ Type: cloudflare.F(email_routing.MatcherTypeLiteral), }}), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", emailRoutingRule.ID) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "literal", "field": "to", "value": "test@example.com" } ], "name": "Send to user@example.net rule.", "priority": 0, "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } } ``` ## Update routing rule `client.EmailRouting.Rules.Update(ctx, ruleIdentifier, params) (*EmailRoutingRule, error)` **put** `/zones/{zone_id}/email/routing/rules/{rule_identifier}` Update actions and matches, or enable/disable specific routing rules. ### Parameters - `ruleIdentifier string` Routing rule identifier. - `params RuleUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Actions param.Field[[]Action]` Body param: List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Matchers param.Field[[]Matcher]` Body param: Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Enabled param.Field[RuleUpdateParamsEnabled]` Body param: Routing rule status. - `const RuleUpdateParamsEnabledTrue RuleUpdateParamsEnabled = true` - `const RuleUpdateParamsEnabledFalse RuleUpdateParamsEnabled = false` - `Name param.Field[string]` Body param: Routing rule name. - `Priority param.Field[float64]` Body param: Priority of the routing rule. ### Returns - `type EmailRoutingRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled EmailRoutingRuleEnabled` Routing rule status. - `const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true` - `const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) emailRoutingRule, err := client.EmailRouting.Rules.Update( context.TODO(), "a7e6fb77503c41d8a7f3113c6918f10c", email_routing.RuleUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Actions: cloudflare.F([]email_routing.ActionParam{email_routing.ActionParam{ Type: cloudflare.F(email_routing.ActionTypeForward), }}), Matchers: cloudflare.F([]email_routing.MatcherParam{email_routing.MatcherParam{ Type: cloudflare.F(email_routing.MatcherTypeLiteral), }}), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", emailRoutingRule.ID) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "literal", "field": "to", "value": "test@example.com" } ], "name": "Send to user@example.net rule.", "priority": 0, "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } } ``` ## Delete routing rule `client.EmailRouting.Rules.Delete(ctx, ruleIdentifier, body) (*EmailRoutingRule, error)` **delete** `/zones/{zone_id}/email/routing/rules/{rule_identifier}` Delete a specific routing rule. ### Parameters - `ruleIdentifier string` Routing rule identifier. - `body RuleDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type EmailRoutingRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled EmailRoutingRuleEnabled` Routing rule status. - `const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true` - `const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) emailRoutingRule, err := client.EmailRouting.Rules.Delete( context.TODO(), "a7e6fb77503c41d8a7f3113c6918f10c", email_routing.RuleDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", emailRoutingRule.ID) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "literal", "field": "to", "value": "test@example.com" } ], "name": "Send to user@example.net rule.", "priority": 0, "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } } ``` ## Domain Types ### Action - `type Action struct{…}` Actions pattern. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` ### Email Routing Rule - `type EmailRoutingRule struct{…}` - `ID string` Routing rule identifier. - `Actions []Action` List actions patterns. - `Type ActionType` Type of supported action. - `const ActionTypeDrop ActionType = "drop"` - `const ActionTypeForward ActionType = "forward"` - `const ActionTypeWorker ActionType = "worker"` - `Value []string` - `Enabled EmailRoutingRuleEnabled` Routing rule status. - `const EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true` - `const EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false` - `Matchers []Matcher` Matching patterns to forward to your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. - `Name string` Routing rule name. - `Priority float64` Priority of the routing rule. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Matcher - `type Matcher struct{…}` Matching pattern to forward your actions. - `Type MatcherType` Type of matcher. - `const MatcherTypeAll MatcherType = "all"` - `const MatcherTypeLiteral MatcherType = "literal"` - `Field MatcherField` Field for type matcher. - `const MatcherFieldTo MatcherField = "to"` - `Value string` Value for matcher. # Catch Alls ## Get catch-all rule `client.EmailRouting.Rules.CatchAlls.Get(ctx, query) (*RuleCatchAllGetResponse, error)` **get** `/zones/{zone_id}/email/routing/rules/catch_all` Get information on the default catch-all routing rule. ### Parameters - `query RuleCatchAllGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type RuleCatchAllGetResponse struct{…}` - `ID string` Routing rule identifier. - `Actions []CatchAllAction` List actions for the catch-all routing rule. - `Type CatchAllActionType` Type of action for catch-all rule. - `const CatchAllActionTypeDrop CatchAllActionType = "drop"` - `const CatchAllActionTypeForward CatchAllActionType = "forward"` - `const CatchAllActionTypeWorker CatchAllActionType = "worker"` - `Value []string` - `Enabled RuleCatchAllGetResponseEnabled` Routing rule status. - `const RuleCatchAllGetResponseEnabledTrue RuleCatchAllGetResponseEnabled = true` - `const RuleCatchAllGetResponseEnabledFalse RuleCatchAllGetResponseEnabled = false` - `Matchers []CatchAllMatcher` List of matchers for the catch-all routing rule. - `Type CatchAllMatcherType` Type of matcher. Default is 'all'. - `const CatchAllMatcherTypeAll CatchAllMatcherType = "all"` - `Name string` Routing rule name. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) catchAll, err := client.EmailRouting.Rules.CatchAlls.Get(context.TODO(), email_routing.RuleCatchAllGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", catchAll.ID) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "all" } ], "name": "Send to user@example.net rule.", "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } } ``` ## Update catch-all rule `client.EmailRouting.Rules.CatchAlls.Update(ctx, params) (*RuleCatchAllUpdateResponse, error)` **put** `/zones/{zone_id}/email/routing/rules/catch_all` Enable or disable catch-all routing rule, or change action to forward to specific destination address. ### Parameters - `params RuleCatchAllUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Actions param.Field[[]CatchAllAction]` Body param: List actions for the catch-all routing rule. - `Type CatchAllActionType` Type of action for catch-all rule. - `const CatchAllActionTypeDrop CatchAllActionType = "drop"` - `const CatchAllActionTypeForward CatchAllActionType = "forward"` - `const CatchAllActionTypeWorker CatchAllActionType = "worker"` - `Value []string` - `Matchers param.Field[[]CatchAllMatcher]` Body param: List of matchers for the catch-all routing rule. - `Type CatchAllMatcherType` Type of matcher. Default is 'all'. - `const CatchAllMatcherTypeAll CatchAllMatcherType = "all"` - `Enabled param.Field[RuleCatchAllUpdateParamsEnabled]` Body param: Routing rule status. - `const RuleCatchAllUpdateParamsEnabledTrue RuleCatchAllUpdateParamsEnabled = true` - `const RuleCatchAllUpdateParamsEnabledFalse RuleCatchAllUpdateParamsEnabled = false` - `Name param.Field[string]` Body param: Routing rule name. ### Returns - `type RuleCatchAllUpdateResponse struct{…}` - `ID string` Routing rule identifier. - `Actions []CatchAllAction` List actions for the catch-all routing rule. - `Type CatchAllActionType` Type of action for catch-all rule. - `const CatchAllActionTypeDrop CatchAllActionType = "drop"` - `const CatchAllActionTypeForward CatchAllActionType = "forward"` - `const CatchAllActionTypeWorker CatchAllActionType = "worker"` - `Value []string` - `Enabled RuleCatchAllUpdateResponseEnabled` Routing rule status. - `const RuleCatchAllUpdateResponseEnabledTrue RuleCatchAllUpdateResponseEnabled = true` - `const RuleCatchAllUpdateResponseEnabledFalse RuleCatchAllUpdateResponseEnabled = false` - `Matchers []CatchAllMatcher` List of matchers for the catch-all routing rule. - `Type CatchAllMatcherType` Type of matcher. Default is 'all'. - `const CatchAllMatcherTypeAll CatchAllMatcherType = "all"` - `Name string` Routing rule name. - `Tag string` Routing rule tag. (Deprecated, replaced by routing rule identifier) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) catchAll, err := client.EmailRouting.Rules.CatchAlls.Update(context.TODO(), email_routing.RuleCatchAllUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Actions: cloudflare.F([]email_routing.CatchAllActionParam{email_routing.CatchAllActionParam{ Type: cloudflare.F(email_routing.CatchAllActionTypeForward), }}), Matchers: cloudflare.F([]email_routing.CatchAllMatcherParam{email_routing.CatchAllMatcherParam{ Type: cloudflare.F(email_routing.CatchAllMatcherTypeAll), }}), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", catchAll.ID) } ``` #### Response ```json { "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": "a7e6fb77503c41d8a7f3113c6918f10c", "actions": [ { "type": "forward", "value": [ "destinationaddress@example.net" ] } ], "enabled": true, "matchers": [ { "type": "all" } ], "name": "Send to user@example.net rule.", "tag": "a7e6fb77503c41d8a7f3113c6918f10c" } } ``` ## Domain Types ### Catch All Action - `type CatchAllAction struct{…}` Action for the catch-all routing rule. - `Type CatchAllActionType` Type of action for catch-all rule. - `const CatchAllActionTypeDrop CatchAllActionType = "drop"` - `const CatchAllActionTypeForward CatchAllActionType = "forward"` - `const CatchAllActionTypeWorker CatchAllActionType = "worker"` - `Value []string` ### Catch All Matcher - `type CatchAllMatcher struct{…}` Matcher for catch-all routing rule. - `Type CatchAllMatcherType` Type of matcher. Default is 'all'. - `const CatchAllMatcherTypeAll CatchAllMatcherType = "all"` # Addresses ## List destination addresses `client.EmailRouting.Addresses.List(ctx, params) (*V4PagePaginationArray[Address], error)` **get** `/accounts/{account_id}/email/routing/addresses` Lists existing destination addresses. ### Parameters - `params AddressListParams` - `AccountID param.Field[string]` Path param: Identifier. - `Direction param.Field[AddressListParamsDirection]` Query param: Sorts results in an ascending or descending order. - `const AddressListParamsDirectionAsc AddressListParamsDirection = "asc"` - `const AddressListParamsDirectionDesc AddressListParamsDirection = "desc"` - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Maximum number of results per page. - `Verified param.Field[AddressListParamsVerified]` Query param: Filter by verified destination addresses. - `const AddressListParamsVerifiedTrue AddressListParamsVerified = true` - `const AddressListParamsVerifiedFalse AddressListParamsVerified = false` ### Returns - `type Address struct{…}` - `ID string` Destination address identifier. - `Created Time` The date and time the destination address has been created. - `Email string` The contact email address of the user. - `Modified Time` The date and time the destination address was last modified. - `Tag string` Destination address tag. (Deprecated, replaced by destination address identifier) - `Verified Time` The date and time the destination address has been verified. Null means not verified yet. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.EmailRouting.Addresses.List(context.TODO(), email_routing.AddressListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "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": "ea95132c15732412d22c1476fa83f27a", "created": "2014-01-02T02:20:00Z", "email": "user@example.com", "modified": "2014-01-02T02:20:00Z", "tag": "ea95132c15732412d22c1476fa83f27a", "verified": "2014-01-02T02:20:00Z" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 1, "total_pages": 100 } } ``` ## Get a destination address `client.EmailRouting.Addresses.Get(ctx, destinationAddressIdentifier, query) (*Address, error)` **get** `/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}` Gets information for a specific destination email already created. ### Parameters - `destinationAddressIdentifier string` Destination address identifier. - `query AddressGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type Address struct{…}` - `ID string` Destination address identifier. - `Created Time` The date and time the destination address has been created. - `Email string` The contact email address of the user. - `Modified Time` The date and time the destination address was last modified. - `Tag string` Destination address tag. (Deprecated, replaced by destination address identifier) - `Verified Time` The date and time the destination address has been verified. Null means not verified yet. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) address, err := client.EmailRouting.Addresses.Get( context.TODO(), "ea95132c15732412d22c1476fa83f27a", email_routing.AddressGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", address.ID) } ``` #### Response ```json { "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": "ea95132c15732412d22c1476fa83f27a", "created": "2014-01-02T02:20:00Z", "email": "user@example.com", "modified": "2014-01-02T02:20:00Z", "tag": "ea95132c15732412d22c1476fa83f27a", "verified": "2014-01-02T02:20:00Z" } } ``` ## Create a destination address `client.EmailRouting.Addresses.New(ctx, params) (*Address, error)` **post** `/accounts/{account_id}/email/routing/addresses` Create a destination address to forward your emails to. Destination addresses need to be verified before they can be used. ### Parameters - `params AddressNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `Email param.Field[string]` Body param: The contact email address of the user. ### Returns - `type Address struct{…}` - `ID string` Destination address identifier. - `Created Time` The date and time the destination address has been created. - `Email string` The contact email address of the user. - `Modified Time` The date and time the destination address was last modified. - `Tag string` Destination address tag. (Deprecated, replaced by destination address identifier) - `Verified Time` The date and time the destination address has been verified. Null means not verified yet. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) address, err := client.EmailRouting.Addresses.New(context.TODO(), email_routing.AddressNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Email: cloudflare.F("user@example.com"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", address.ID) } ``` #### Response ```json { "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": "ea95132c15732412d22c1476fa83f27a", "created": "2014-01-02T02:20:00Z", "email": "user@example.com", "modified": "2014-01-02T02:20:00Z", "tag": "ea95132c15732412d22c1476fa83f27a", "verified": "2014-01-02T02:20:00Z" } } ``` ## Delete destination address `client.EmailRouting.Addresses.Delete(ctx, destinationAddressIdentifier, body) (*Address, error)` **delete** `/accounts/{account_id}/email/routing/addresses/{destination_address_identifier}` Deletes a specific destination address. ### Parameters - `destinationAddressIdentifier string` Destination address identifier. - `body AddressDeleteParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type Address struct{…}` - `ID string` Destination address identifier. - `Created Time` The date and time the destination address has been created. - `Email string` The contact email address of the user. - `Modified Time` The date and time the destination address was last modified. - `Tag string` Destination address tag. (Deprecated, replaced by destination address identifier) - `Verified Time` The date and time the destination address has been verified. Null means not verified yet. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_routing" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) address, err := client.EmailRouting.Addresses.Delete( context.TODO(), "ea95132c15732412d22c1476fa83f27a", email_routing.AddressDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", address.ID) } ``` #### Response ```json { "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": "ea95132c15732412d22c1476fa83f27a", "created": "2014-01-02T02:20:00Z", "email": "user@example.com", "modified": "2014-01-02T02:20:00Z", "tag": "ea95132c15732412d22c1476fa83f27a", "verified": "2014-01-02T02:20:00Z" } } ``` ## Domain Types ### Address - `type Address struct{…}` - `ID string` Destination address identifier. - `Created Time` The date and time the destination address has been created. - `Email string` The contact email address of the user. - `Modified Time` The date and time the destination address was last modified. - `Tag string` Destination address tag. (Deprecated, replaced by destination address identifier) - `Verified Time` The date and time the destination address has been verified. Null means not verified yet.