Create a household
households.create
POST/api/v1/households
- Route
Creates a household with you as its admin, and adds you to its family.
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
namestringrequired | What the household calls itself, such as "The Okafors". |
time_zonestringrequired | IANA time zone, such as America/New_York. |
Response#
201 The new household.
| Field | Description |
|---|---|
idstringrequired | The household's ID. |
namestringrequired | What the household calls itself. |
time_zonestringrequired | IANA time zone, such as America/New_York. |
roleone of: adminrequired | Your role there: admin (the only role for now). |
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. |
Examples#
These are real. Each was recorded from a sample household, the Okafors, running through the whole API when this site was built.
Create a household
You become its admin, and your own person is added to the family.
Request, curl
curl -X POST 'https://rigel.house/api/v1/households' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"name": "The Okafors",
"time_zone": "America/Chicago"
}'Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "The Okafors",
time_zone: "America/Chicago",
}),
});
const data = await response.json();Request, HTTP
POST /api/v1/households HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"name": "The Okafors",
"time_zone": "America/Chicago"
}Response, 201
HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_01M6V9CS6DJNA2ST949WNQ7PTT
{
"id": "hh_01M6V9CS6GGVFCY7NAS8ZTQV95",
"name": "The Okafors",
"time_zone": "America/Chicago",
"role": "admin"
}A time zone that doesn't exist
Request, curl
curl -X POST 'https://rigel.house/api/v1/households' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"name": "The Okafors",
"time_zone": "Chicago"
}'Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/households", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "The Okafors",
time_zone: "Chicago",
}),
});
const data = await response.json();Request, HTTP
POST /api/v1/households HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"name": "The Okafors",
"time_zone": "Chicago"
}Response, 400
HTTP/1.1 400 Bad Request
Content-Type: application/json
X-Request-Id: req_01M6V9CS6WF40PJGRAH78QRPMX
{
"error": {
"code": "validation_failed",
"message": "The request has invalid fields. No changes were applied.",
"details": {
"fields": [
{
"field": "time_zone",
"problem": "must be an IANA time zone, such as America/New_York"
}
]
},
"recovery": "Correct each field listed in details.fields, then send the request again.",
"request_id": "req_01M6V9CS6WF40PJGRAH78QRPMX"
}
}