# Add a custom domain POST https://api2.freecustom.email/v1/custom-domains Content-Type: application/json Adds a new custom domain to your account and returns the DNS records you must configure at your registrar before verifying. **Plan required:** Growth ($49/mo) or Enterprise ($149/mo). **Workflow:** 1. `POST /v1/custom-domains` — add the domain, get DNS records. 2. Add the two DNS records (MX + TXT) at your registrar. 3. `POST /v1/custom-domains/{domain}/verify` — confirm propagation. 4. `POST /v1/inboxes` with any address `@yourdomain` — start receiving mail. This call is **idempotent** — if the domain is already added it returns the existing entry with `200` instead of `201`. **Limits:** Maximum 10 custom domains per account. Reference: https://docs.freecustom.email/free-custom-email-api/v-1/custom-domains/add-a-custom-domain ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: collection version: 1.0.0 paths: /v1/custom-domains: post: operationId: add-a-custom-domain summary: Add a custom domain description: > Adds a new custom domain to your account and returns the DNS records you must configure at your registrar before verifying. **Plan required:** Growth ($49/mo) or Enterprise ($149/mo). **Workflow:** 1. `POST /v1/custom-domains` — add the domain, get DNS records. 2. Add the two DNS records (MX + TXT) at your registrar. 3. `POST /v1/custom-domains/{domain}/verify` — confirm propagation. 4. `POST /v1/inboxes` with any address `@yourdomain` — start receiving mail. This call is **idempotent** — if the domain is already added it returns the existing entry with `200` instead of `201`. **Limits:** Maximum 10 custom domains per account. tags: - subpackage_v1.subpackage_v1/customDomains parameters: - name: Authorization in: header description: Bearer authentication required: true schema: type: string responses: '200': description: OK content: application/json: schema: $ref: >- #/components/schemas/v1_custom-domains_Add a custom domain_Response_200 '400': description: Bad Request content: application/json: schema: $ref: >- #/components/schemas/PostV1Custom-domainsRequestBadRequestError '401': description: Unauthorized content: application/json: schema: $ref: >- #/components/schemas/PostV1Custom-domainsRequestUnauthorizedError '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/PostV1Custom-domainsRequestForbiddenError' '429': description: Too Many Requests content: application/json: schema: $ref: >- #/components/schemas/PostV1Custom-domainsRequestTooManyRequestsError requestBody: content: application/json: schema: type: object properties: domain: type: string required: - domain servers: - url: https://api2.freecustom.email components: schemas: V1CustomDomainsPostResponsesContentApplicationJsonSchemaDataDnsRecordsItems: type: object properties: ttl: type: string type: type: string value: type: string hostname: type: string priority: type: string required: - ttl - type - value - hostname - priority title: >- V1CustomDomainsPostResponsesContentApplicationJsonSchemaDataDnsRecordsItems V1CustomDomainsPostResponsesContentApplicationJsonSchemaData: type: object properties: domain: type: string added_at: type: string format: date-time verified: type: boolean mx_record: type: string next_step: type: string txt_record: type: string dns_records: type: array items: $ref: >- #/components/schemas/V1CustomDomainsPostResponsesContentApplicationJsonSchemaDataDnsRecordsItems required: - domain - added_at - verified - mx_record - next_step - txt_record - dns_records title: V1CustomDomainsPostResponsesContentApplicationJsonSchemaData v1_custom-domains_Add a custom domain_Response_200: type: object properties: data: $ref: >- #/components/schemas/V1CustomDomainsPostResponsesContentApplicationJsonSchemaData message: type: string success: type: boolean required: - data - message - success title: v1_custom-domains_Add a custom domain_Response_200 PostV1Custom-domainsRequestBadRequestError: type: object properties: error: type: string message: type: string success: type: boolean required: - error - message - success title: PostV1Custom-domainsRequestBadRequestError PostV1Custom-domainsRequestUnauthorizedError: type: object properties: error: type: string message: type: string success: type: boolean required: - error - message - success title: PostV1Custom-domainsRequestUnauthorizedError PostV1Custom-domainsRequestForbiddenError: type: object properties: error: type: string message: type: string success: type: boolean upgrade_url: type: string format: uri required: - error - message - success - upgrade_url title: PostV1Custom-domainsRequestForbiddenError PostV1Custom-domainsRequestTooManyRequestsError: type: object properties: hint: type: string error: type: string message: type: string success: type: boolean credits_url: type: string format: uri upgrade_url: type: string format: uri required: - hint - error - message - success - credits_url - upgrade_url title: PostV1Custom-domainsRequestTooManyRequestsError securitySchemes: bearerAuth: type: http scheme: bearer ``` ## SDK Code Examples ```python v1_custom-domains_Add a custom domain_example import requests url = "https://api2.freecustom.email/v1/custom-domains" payload = { "domain": "mail.acme.com" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript v1_custom-domains_Add a custom domain_example const url = 'https://api2.freecustom.email/v1/custom-domains'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"domain":"mail.acme.com"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go v1_custom-domains_Add a custom domain_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api2.freecustom.email/v1/custom-domains" payload := strings.NewReader("{\n \"domain\": \"mail.acme.com\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby v1_custom-domains_Add a custom domain_example require 'uri' require 'net/http' url = URI("https://api2.freecustom.email/v1/custom-domains") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"domain\": \"mail.acme.com\"\n}" response = http.request(request) puts response.read_body ``` ```java v1_custom-domains_Add a custom domain_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api2.freecustom.email/v1/custom-domains") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"domain\": \"mail.acme.com\"\n}") .asString(); ``` ```php v1_custom-domains_Add a custom domain_example request('POST', 'https://api2.freecustom.email/v1/custom-domains', [ 'body' => '{ "domain": "mail.acme.com" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp v1_custom-domains_Add a custom domain_example using RestSharp; var client = new RestClient("https://api2.freecustom.email/v1/custom-domains"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"domain\": \"mail.acme.com\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift v1_custom-domains_Add a custom domain_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["domain": "mail.acme.com"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api2.freecustom.email/v1/custom-domains")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python v1_custom-domains_Add a custom domain_example import requests url = "https://api2.freecustom.email/v1/custom-domains" payload = { "domain": "mail.acme.com" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript v1_custom-domains_Add a custom domain_example const url = 'https://api2.freecustom.email/v1/custom-domains'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"domain":"mail.acme.com"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go v1_custom-domains_Add a custom domain_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api2.freecustom.email/v1/custom-domains" payload := strings.NewReader("{\n \"domain\": \"mail.acme.com\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby v1_custom-domains_Add a custom domain_example require 'uri' require 'net/http' url = URI("https://api2.freecustom.email/v1/custom-domains") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"domain\": \"mail.acme.com\"\n}" response = http.request(request) puts response.read_body ``` ```java v1_custom-domains_Add a custom domain_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api2.freecustom.email/v1/custom-domains") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"domain\": \"mail.acme.com\"\n}") .asString(); ``` ```php v1_custom-domains_Add a custom domain_example request('POST', 'https://api2.freecustom.email/v1/custom-domains', [ 'body' => '{ "domain": "mail.acme.com" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp v1_custom-domains_Add a custom domain_example using RestSharp; var client = new RestClient("https://api2.freecustom.email/v1/custom-domains"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"domain\": \"mail.acme.com\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift v1_custom-domains_Add a custom domain_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["domain": "mail.acme.com"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api2.freecustom.email/v1/custom-domains")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```