# DNS ## Email Routing - DNS settings `client.emailRouting.dns.get(DNSGetParamsparams, RequestOptionsoptions?): DNSGetResponse` **get** `/zones/{zone_id}/email/routing/dns` Show the DNS records needed to configure your Email Routing zone. ### Parameters - `params: DNSGetParams` - `zone_id: string` Path param: Identifier. - `subdomain?: string` Query param: Domain of your zone. ### Returns - `DNSGetResponse = EmailEmailRoutingDNSQueryResponse | EmailDNSSettingsResponseCollection` - `EmailEmailRoutingDNSQueryResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` - `result?: Result` - `errors?: Array` - `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?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `number` - `1` - `1` - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `"A"` - `"AAAA"` - `"CNAME"` - `"HTTPS"` - `"TXT"` - `"SRV"` - `"LOC"` - `"MX"` - `"NS"` - `"CERT"` - `"DNSKEY"` - `"DS"` - `"NAPTR"` - `"SMIMEA"` - `"SSHFP"` - `"SVCB"` - `"TLSA"` - `"URI"` - `record?: Array` - `content?: string` DNS record content. - `name?: string` DNS record name (or @ for the zone apex). - `priority?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `result_info?: ResultInfo` - `count?: number` Total number of results for the requested service. - `page?: number` Current page within paginated list of results. - `per_page?: number` Number of results per page of results. - `total_count?: number` Total results available without any search parameters. - `total_pages?: number` The number of total pages in the entire result set. - `EmailDNSSettingsResponseCollection` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` - `result?: Array` - `content?: string` DNS record content. - `name?: string` DNS record name (or @ for the zone apex). - `priority?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `result_info?: ResultInfo` - `count?: number` Total number of results for the requested service. - `page?: number` Current page within paginated list of results. - `per_page?: number` Number of results per page of results. - `total_count?: number` Total results available without any search parameters. - `total_pages?: number` The number of total pages in the entire result set. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const dns = await client.emailRouting.dns.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); console.log(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.create(DNSCreateParamsparams, RequestOptionsoptions?): Settings` **post** `/zones/{zone_id}/email/routing/dns` Enable you Email Routing zone. Add and lock the necessary MX and SPF records. ### Parameters - `params: DNSCreateParams` - `zone_id: string` Path param: Identifier. - `name?: string` Body param: Domain of your zone. ### Returns - `Settings` - `id: string` Email Routing settings identifier. - `enabled: true | false` State of the zone settings for Email Routing. - `true` - `false` - `name: string` Domain of your zone. - `created?: string` The date and time the settings have been created. - `modified?: string` The date and time the settings have been modified. - `skip_wizard?: true | false` Flag to check if the user skipped the configuration wizard. - `true` - `false` - `status?: "ready" | "unconfigured" | "misconfigured" | 2 more` Show the state of your account, and the type or configuration error. - `"ready"` - `"unconfigured"` - `"misconfigured"` - `"misconfigured/locked"` - `"unlocked"` - `tag?: string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const settings = await client.emailRouting.dns.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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(DNSEditParamsparams, RequestOptionsoptions?): Settings` **patch** `/zones/{zone_id}/email/routing/dns` Unlock MX Records previously locked by Email Routing. ### Parameters - `params: DNSEditParams` - `zone_id: string` Path param: Identifier. - `name?: string` Body param: Domain of your zone. ### Returns - `Settings` - `id: string` Email Routing settings identifier. - `enabled: true | false` State of the zone settings for Email Routing. - `true` - `false` - `name: string` Domain of your zone. - `created?: string` The date and time the settings have been created. - `modified?: string` The date and time the settings have been modified. - `skip_wizard?: true | false` Flag to check if the user skipped the configuration wizard. - `true` - `false` - `status?: "ready" | "unconfigured" | "misconfigured" | 2 more` Show the state of your account, and the type or configuration error. - `"ready"` - `"unconfigured"` - `"misconfigured"` - `"misconfigured/locked"` - `"unlocked"` - `tag?: string` Email Routing settings tag. (Deprecated, replaced by Email Routing settings identifier) ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); const settings = await client.emailRouting.dns.edit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(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(DNSDeleteParamsparams, RequestOptionsoptions?): SinglePage` **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 - `params: DNSDeleteParams` - `zone_id: string` Identifier. ### Returns - `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?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `number` - `1` - `1` - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `"A"` - `"AAAA"` - `"CNAME"` - `"HTTPS"` - `"TXT"` - `"SRV"` - `"LOC"` - `"MX"` - `"NS"` - `"CERT"` - `"DNSKEY"` - `"DS"` - `"NAPTR"` - `"SMIMEA"` - `"SSHFP"` - `"SVCB"` - `"TLSA"` - `"URI"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const dnsRecord of client.emailRouting.dns.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(dnsRecord.content); } ``` #### 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 - `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?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `number` - `1` - `1` - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `"A"` - `"AAAA"` - `"CNAME"` - `"HTTPS"` - `"TXT"` - `"SRV"` - `"LOC"` - `"MX"` - `"NS"` - `"CERT"` - `"DNSKEY"` - `"DS"` - `"NAPTR"` - `"SMIMEA"` - `"SSHFP"` - `"SVCB"` - `"TLSA"` - `"URI"` ### DNS Get Response - `DNSGetResponse = EmailEmailRoutingDNSQueryResponse | EmailDNSSettingsResponseCollection` - `EmailEmailRoutingDNSQueryResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` - `result?: Result` - `errors?: Array` - `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?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `number` - `1` - `1` - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `"A"` - `"AAAA"` - `"CNAME"` - `"HTTPS"` - `"TXT"` - `"SRV"` - `"LOC"` - `"MX"` - `"NS"` - `"CERT"` - `"DNSKEY"` - `"DS"` - `"NAPTR"` - `"SMIMEA"` - `"SSHFP"` - `"SVCB"` - `"TLSA"` - `"URI"` - `record?: Array` - `content?: string` DNS record content. - `name?: string` DNS record name (or @ for the zone apex). - `priority?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `result_info?: ResultInfo` - `count?: number` Total number of results for the requested service. - `page?: number` Current page within paginated list of results. - `per_page?: number` Number of results per page of results. - `total_count?: number` Total results available without any search parameters. - `total_pages?: number` The number of total pages in the entire result set. - `EmailDNSSettingsResponseCollection` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` - `result?: Array` - `content?: string` DNS record content. - `name?: string` DNS record name (or @ for the zone apex). - `priority?: number` Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred. - `ttl?: number | 1` Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for 'automatic'. - `type?: "A" | "AAAA" | "CNAME" | 15 more` DNS record type. - `result_info?: ResultInfo` - `count?: number` Total number of results for the requested service. - `page?: number` Current page within paginated list of results. - `per_page?: number` Number of results per page of results. - `total_count?: number` Total results available without any search parameters. - `total_pages?: number` The number of total pages in the entire result set.