Make a throwaway test account
test_accounts.post
POST/api/v1/test-accounts
- Route
Makes a test user with a household of their own, for trying something without touching real data, and returns a token and a session for them. It's deleted, with its household, a day later. Needs a session of a person who isn't a test user; at most 10 live test accounts each.
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
namestringoptional | The test user's name. Default "Test person". |
sample_databooleanoptional | Add the sample family's records (docs/sample-data.md). Default false. |
Response#
201 The test account.
| Field | Description |
|---|---|
userobjectrequired | |
user.idstringrequired | The test user's ID, usr_…. |
user.emailstringrequired | Always <user id>@test.invalid, which can't receive mail or sign in with Google. |
user.namestringrequired | No description. |
household_idstringrequired | The test user's own household, where they're the admin. |
expires_atstringrequired | When the account and its household are deleted, UTC: a day after it was made. |
tokenstringrequired | A read_write personal API token for the household, tok_….<secret>. |
sessionstringrequired | A session for a browser: set it as the rigel_session cookie. Your own cookie isn't changed. |
sample_recordsintegerrequired | How many sample records were added; 0 without sample_data. |
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. |
403 | Read error.code | Described above. |
409 | Read error.code | Described above. |
Examples#
No call has been recorded for this operation yet, so this example is built from its schema. The values are placeholders.
Built from the schema
Not recorded from a real call: the fields are filled in from the schema, so the values are placeholders.
curl -X POST 'https://rigel.house/api/v1/test-accounts' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-d '{
"name": "Example",
"sample_data": true
}'const response = await fetch("https://rigel.house/api/v1/test-accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Example",
sample_data: true,
}),
});
const data = await response.json();POST /api/v1/test-accounts HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
{
"name": "Example",
"sample_data": true
}HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_01K9BKNGK0ENW3AHRZ6DMV29GQ
{
"user": {
"id": "usr_01K9BKNGK0ENW3AHRZ6DMV29GQ",
"email": "example",
"name": "Example"
},
"household_id": "hh_01K9BKQB60S07ENW3AHRZ6DMV2",
"expires_at": "example",
"token": "example",
"session": "example",
"sample_records": 1
}