# Create a domain Creates a domain for sending emails Endpoint: POST /v4/domains Version: 3.0.0 Security: basicAuth ## Request fields (multipart/form-data): - `archive_to` (string) If set to a URL, then each successfully delivered message will be submitted in an HTTP POST request to the URL. The Content-Type of the POST requests is application/mime and the request body is exactly what the recipient SMTP server received. - `dkim_host_name` (string) Set the DKIM host name for the domain that is being created. Note, the value must be a valid domain name, and can be the domain name being created, a subdomain of the domain being created, or the root domain. This parameter cannot be used in conjunction with force_dkim_authority or force_root_dkim_host. - `dkim_key_size` (string) The size of the new domain's DKIM key. Shall be either 1024 or 2048. - `dkim_selector` (string) Explicitly set the value of the DKIM selector for the domain being created. If the domain key does not already exist, one will be created. The selector must be a valid atom per RFC2822. e.g valid value , invalid value https://datatracker.ietf.org/doc/html/rfc2822#section-3.2.4 - `encrypt_incoming_message` (boolean) Enable encrypting incoming messages for the given domain. This cannot be altered via API after being set for security purposes. Reach out to Support to disable if necessary. Default to false - `force_dkim_authority` (boolean) If set to true, the domain will be the DKIM authority for itself even if the root domain is registered on the same mailgun account. If set to false, the domain will have the same DKIM authority as the root domain registered on the same mailgun account. Default to false. - `force_root_dkim_host` (boolean) If set to true, the root domain will be the DKIM Host for the domain being created even if the root domain itself is not registered with Mailgun. The domain being created will still need to pass domain verification with valid spf records for the domain and valid DKIM record for the root domain. This does not effect the smtp mail-from host for the domain being created. The mail-from host will remain the domain name being created, not the root domain. - `wildcard` (boolean) Allows domain to accept inbound messages received on subdomains that have MX records pointed to Mailgun. Default is false. - `name` (string, required) The name of the new domain - `pool_id` (string) Requested IP Pool to be assigned to the domain at creation. - `ips` (string) An optional, comma-separated list of IP addresses to be assigned to this domain. If not specified, all dedicated IP addresses on the account will be assigned. If the request cannot be fulfilled (e.g. a requested IP is not assigned to the account, etc), a 400 will be returned. - `require_tls` (boolean) If set to true, this requires messages for the domain only be sent over a TLS connection. If a TLS connection cannot be established, Mailgun will not deliver the message. If set to false, Mailgun will still try and upgrade the connection, but if Mailgun cannot, the message will be delivered over a plaintext SMTP connection. The default value is false. - `skip_verification` (boolean) If set to true, the certificate and hostname will not be verified when trying to establish a TLS connection and Mailgun will accept any certificate during delivery of a message. If set to false, Mailgun will verify the certificate and hostname. If either one can not be verified, a TLS connection will not be established. The default value is false. - `spam_action` (string) Disabled, block or tag. Default to disabled. If disabled, no spam filtering will occur for inbound messages. If block, inbound spam messages will not be delivered. If tag, inbound messages will be tagged with a spam header. See Spam Filter. - `smtp_password` (string) Password for SMTP authentication - `use_automatic_sender_security` (boolean) Enable Automatic Sender Security. This requires setting DNS CNAME entries for DKIM keys instead of a TXT record. Defaults to false. - `web_prefix` (string) Sets your open, click and unsubscribe URLs domain name prefix. Links rewritten or added by Mailgun in your emails will look like ://./... Default to email - `web_scheme` (string) Sets your open, click and unsubscribe URLs to use http or https. Value either or . Defaults to http. In order for https to work, you must have a valid cert created for your domain. See Domain Tracking for TLS cert generation. - `message_ttl` (integer) Specifies the time-to-live (TTL) in seconds for retrieving both incoming and outgoing messages. The maximum TTL value is determined by your subscription plan. ## Response 200 fields (application/json): - `message` (string, required) Response message - `domain` (any, required) Details of the newly created domain - `receiving_dns_records` (array, required) List of DNS records required for receiving emails - `sending_dns_records` (array, required) List of DNS records required for sending emails ## Response 401 fields (application/json): - `message` (string, required) Response message