Add an email address
email.addresses_create
POST/api/v1/households/{household_id}/email/addresses
- Route
Claims an address for the household, on Rigel's domain or one of its custom domains, and records it. Fails with address_taken when any household has it, invalid_address when the name can't be an address, or domain_not_found.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
local_partstringrequired | The part before the @, such as "home". Letters, digits and . _ - only. |
email_domain_idstring or nullrequired | The household's custom domain to put it on, or null for Rigel's own. |
display_namestringrequired | The name on mail sent from it, such as "The Okafors". 1–80 characters. |
Response#
201 The address was added.
| Field | Description |
|---|---|
email_address_idstringrequired | The new address. |
addressstringrequired | The address itself. |
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. |
Examples#
These are real. Each was recorded from a sample household, the Okafors, running through the whole API when this site was built.
Add an email address
A name on one of the household's domains, or on Rigel's when email_domain_id is null.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"local_part": "home",
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
"display_name": "The Okafors"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
local_part: "home",
email_domain_id: "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
display_name: "The Okafors",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"local_part": "home",
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
"display_name": "The Okafors"
}HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_01M6V9CSQ9K91Q609HTVPBAZ1R
{
"email_address_id": "eml_01M6V9CSQB5Y3M8ETS3YPHFPA1",
"address": "home@okafors.example.com"
}Add an address for receipts
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"local_part": "receipts",
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
"display_name": "Okafor receipts"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
local_part: "receipts",
email_domain_id: "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
display_name: "Okafor receipts",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"local_part": "receipts",
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
"display_name": "Okafor receipts"
}HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_01M6V9CSS7GXW1JPJT2J5H4RFY
{
"email_address_id": "eml_01M6V9CSS8GN4S0XWFK70XY4ZJ",
"address": "receipts@okafors.example.com"
}Add an address that is taken
Addresses are unique across all households.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"local_part": "home",
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
"display_name": "The Okafors"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
local_part: "home",
email_domain_id: "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
display_name: "The Okafors",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/email/addresses HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"local_part": "home",
"email_domain_id": "emd_01M6V9CSQ63D47MKP7KG4FEBDJ",
"display_name": "The Okafors"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01M6V9CSSB3CMXSZ07HR4BJ1W1
{
"error": {
"code": "address_taken",
"message": "home@okafors.example.com is already one of your addresses. No changes were applied.",
"details": {},
"recovery": "Choose another name.",
"request_id": "req_01M6V9CSSB3CMXSZ07HR4BJ1W1"
}
}