Add a custom domain
email.domains_create
POST/api/v1/households/{household_id}/email/domains
- Route
Claims the domain for the household, has the mail service verify it for sending, and records it with the DNS records its owner must add. Fails with domain_taken when another household has it, invalid_domain, or sending_not_configured when this server has no mail service keys.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
domainstringrequired | The domain, such as okafors.example. |
Response#
201 The domain was added.
| Field | Description |
|---|---|
email_domain_idstringrequired | The new domain. |
Errors#
Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.
| Status | Code | When |
|---|---|---|
400 | validation_failed | A field is missing, misspelled or out of range. details.fields lists each problem. |
401 | unauthenticated | The request has no valid session. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | Read error.code | Described above. |
503 | Read error.code | Described above. |
Examples#
These are real. Each was recorded from a sample household, the Okafors, running through the whole API when this site was built.
Add a custom domain
The API has the mail service verify the domain for sending. The DNS records to add come from email.domain.records.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/domains' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"domain": "okafors.example.com"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/domains", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
domain: "okafors.example.com",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/domains HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"domain": "okafors.example.com"
}HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_01M6V9CSQ5G58TRZ4XFHGQE04Y
{
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ"
}Add a second custom domain
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/domains' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"domain": "okafor.example.net"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/domains", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
domain: "okafor.example.net",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/domains HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"domain": "okafor.example.net"
}HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_01M6V9CSSD37XGH766FPM8R949
{
"email_domain_id": "emd_01M6V9CSSD5VZEVZHZH5TE669F"
}