# Subdomains ## List sending subdomains `client.EmailSending.Subdomains.List(ctx, query) (*SinglePage[SubdomainListResponse], error)` **get** `/zones/{zone_id}/email/sending/subdomains` Lists all sending-enabled subdomains for the zone. ### Parameters - `query SubdomainListParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type SubdomainListResponse struct{…}` - `EmailSendingEnabled bool` Whether Email Sending is enabled on this subdomain. - `Name string` The subdomain domain name. - `Tag string` Sending subdomain identifier. - `Created Time` The date and time the destination address has been created. - `EmailSendingDKIMSelector string` The DKIM selector used for email signing. - `EmailSendingReturnPathDomain string` The return-path domain used for bounce handling. - `Enabled bool` Whether Email Routing (receiving) is enabled on this subdomain. Read-only; included for informational purposes since both services share the subdomain row. - `Modified Time` The date and time the destination address was last modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_sending" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.EmailSending.Subdomains.List(context.TODO(), email_sending.SubdomainListParams{ 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": [ { "email_sending_enabled": true, "name": "sub.example.com", "tag": "aabbccdd11223344aabbccdd11223344", "created": "2014-01-02T02:20:00Z", "email_sending_dkim_selector": "cf-bounce", "email_sending_return_path_domain": "cf-bounce.sub.example.com", "enabled": true, "modified": "2014-01-02T02:20:00Z" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Get a sending subdomain `client.EmailSending.Subdomains.Get(ctx, subdomainID, query) (*SubdomainGetResponse, error)` **get** `/zones/{zone_id}/email/sending/subdomains/{subdomain_id}` Gets information for a specific sending subdomain. ### Parameters - `subdomainID string` Sending subdomain identifier. - `query SubdomainGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type SubdomainGetResponse struct{…}` - `EmailSendingEnabled bool` Whether Email Sending is enabled on this subdomain. - `Name string` The subdomain domain name. - `Tag string` Sending subdomain identifier. - `Created Time` The date and time the destination address has been created. - `EmailSendingDKIMSelector string` The DKIM selector used for email signing. - `EmailSendingReturnPathDomain string` The return-path domain used for bounce handling. - `Enabled bool` Whether Email Routing (receiving) is enabled on this subdomain. Read-only; included for informational purposes since both services share the subdomain row. - `Modified Time` The date and time the destination address was last modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_sending" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) subdomain, err := client.EmailSending.Subdomains.Get( context.TODO(), "aabbccdd11223344aabbccdd11223344", email_sending.SubdomainGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subdomain.EmailSendingEnabled) } ``` #### 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": { "email_sending_enabled": true, "name": "sub.example.com", "tag": "aabbccdd11223344aabbccdd11223344", "created": "2014-01-02T02:20:00Z", "email_sending_dkim_selector": "cf-bounce", "email_sending_return_path_domain": "cf-bounce.sub.example.com", "enabled": true, "modified": "2014-01-02T02:20:00Z" } } ``` ## Create a sending subdomain `client.EmailSending.Subdomains.New(ctx, params) (*SubdomainNewResponse, error)` **post** `/zones/{zone_id}/email/sending/subdomains` Creates a new sending subdomain or re-enables sending on an existing subdomain that had it disabled. If zone-level Email Sending has not been enabled yet, the zone flag is automatically set when the entitlement is present. ### Parameters - `params SubdomainNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: The subdomain name. Must be within the zone. ### Returns - `type SubdomainNewResponse struct{…}` - `EmailSendingEnabled bool` Whether Email Sending is enabled on this subdomain. - `Name string` The subdomain domain name. - `Tag string` Sending subdomain identifier. - `Created Time` The date and time the destination address has been created. - `EmailSendingDKIMSelector string` The DKIM selector used for email signing. - `EmailSendingReturnPathDomain string` The return-path domain used for bounce handling. - `Enabled bool` Whether Email Routing (receiving) is enabled on this subdomain. Read-only; included for informational purposes since both services share the subdomain row. - `Modified Time` The date and time the destination address was last modified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_sending" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) subdomain, err := client.EmailSending.Subdomains.New(context.TODO(), email_sending.SubdomainNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("sub.example.com"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subdomain.EmailSendingEnabled) } ``` #### 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": { "email_sending_enabled": true, "name": "sub.example.com", "tag": "aabbccdd11223344aabbccdd11223344", "created": "2014-01-02T02:20:00Z", "email_sending_dkim_selector": "cf-bounce", "email_sending_return_path_domain": "cf-bounce.sub.example.com", "enabled": true, "modified": "2014-01-02T02:20:00Z" } } ``` ## Delete a sending subdomain `client.EmailSending.Subdomains.Delete(ctx, subdomainID, body) (*SubdomainDeleteResponse, error)` **delete** `/zones/{zone_id}/email/sending/subdomains/{subdomain_id}` Disables sending on a subdomain and removes its DNS records. If routing is still active on the subdomain, only sending is disabled. ### Parameters - `subdomainID string` Sending subdomain identifier. - `body SubdomainDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type SubdomainDeleteResponse struct{…}` - `Errors []SubdomainDeleteResponseError` - `Code int64` - `Message string` - `DocumentationURL string` - `Source SubdomainDeleteResponseErrorsSource` - `Pointer string` - `Messages []SubdomainDeleteResponseMessage` - `Code int64` - `Message string` - `DocumentationURL string` - `Source SubdomainDeleteResponseMessagesSource` - `Pointer string` - `Success SubdomainDeleteResponseSuccess` Whether the API call was successful. - `const SubdomainDeleteResponseSuccessTrue SubdomainDeleteResponseSuccess = true` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/email_sending" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) subdomain, err := client.EmailSending.Subdomains.Delete( context.TODO(), "aabbccdd11223344aabbccdd11223344", email_sending.SubdomainDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", subdomain.Errors) } ``` #### 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 } ``` # DNS ## Get sending subdomain DNS records `client.EmailSending.Subdomains.DNS.Get(ctx, subdomainID, query) (*SinglePage[DNSRecord], error)` **get** `/zones/{zone_id}/email/sending/subdomains/{subdomain_id}/dns` Returns the expected DNS records for a sending subdomain. ### Parameters - `subdomainID string` Sending subdomain identifier. - `query SubdomainDNSGetParams` - `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_sending" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.EmailSending.Subdomains.DNS.Get( context.TODO(), "aabbccdd11223344aabbccdd11223344", email_sending.SubdomainDNSGetParams{ 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": [ { "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 } } ```