Who you are and your households
me
GET/api/v1/me
- Route
The signed-in user and every household they're a member of.
Response#
200 The signed-in user.
| Field | Description |
|---|---|
userobjectrequired | |
user.idstringrequired | The user's ID. |
user.emailstringrequired | Their verified email address. |
user.namestringrequired | Their name. |
householdsarray of objectsrequired | Households they're a member of, oldest first. |
households[].idstringrequired | The household's ID. |
households[].namestringrequired | The household's name. |
households[].roleone of: adminrequired | Their 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 |
|---|---|---|
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.
Who you are and your households
Request, curl
curl 'https://rigel.house/api/v1/me' \
-H "Cookie: rigel_session=$RIGEL_SESSION"Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/me", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();Request, HTTP
GET /api/v1/me HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>Response, 200
HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CS707TD2XHCECQH18ZG3
{
"user": {
"id": "usr_01M6V9CS5XV66GR856KS52MTTZ",
"email": "ada@example.com",
"name": "Ada Okafor"
},
"households": [
{
"id": "hh_01M6V9CS6GGVFCY7NAS8ZTQV95",
"name": "The Okafors",
"role": "admin"
}
]
}Without a session
Every route except the health check, the OpenAPI document and the sign-in routes needs a session.
Request, curl
curl 'https://rigel.house/api/v1/me' \
-H "Cookie: rigel_session=$RIGEL_SESSION"Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/me", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();Request, HTTP
GET /api/v1/me HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>Response, 401
HTTP/1.1 401 Unauthorized
Content-Type: application/json
X-Request-Id: req_01M6V9CS72T5A85G59EKMEN3KR
{
"error": {
"code": "unauthenticated",
"message": "You're not signed in.",
"details": {},
"recovery": "Sign in, then send the request again.",
"request_id": "req_01M6V9CS72T5A85G59EKMEN3KR"
}
}A session that has ended
The cookie from before signing out no longer works.
Request, curl
curl 'https://rigel.house/api/v1/me' \
-H "Cookie: rigel_session=$RIGEL_SESSION"Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/me", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();Request, HTTP
GET /api/v1/me HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>Response, 401
HTTP/1.1 401 Unauthorized
Content-Type: application/json
X-Request-Id: req_01M6V9CVJDC10WVFP9CHN5XSES
{
"error": {
"code": "unauthenticated",
"message": "You're not signed in.",
"details": {},
"recovery": "Sign in, then send the request again.",
"request_id": "req_01M6V9CVJDC10WVFP9CHN5XSES"
}
}