Make a new calendar
calendar.calendar.create
POST/api/v1/households/{household_id}/commands/calendar.calendar.create
- Command
- Rigel runs it
- Applies offline
Adds a calendar, last in the list. Names are unique ignoring case. The color is the first calendar color nobody uses yet unless given. A household always has exactly one default calendar: the first calendar made is it, and is_default true here moves the default to this one. is_busy_only is set when the calendar is made and can't change later: its events are stored as 'Busy' with no details.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
Idempotency-Keyheaderstringoptional | The command's ID. Reuse it when retrying the same command. |
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
namestringrequired | A calendar's name, as written, 1–80 characters: "Family", "Nia's school". Unique ignoring case. |
colorone of: calendar-1, calendar-2, calendar-3, calendar-4, calendar-5, calendar-6, calendar-7, calendar-8optional | One of the eight calendar color tokens, calendar-1 to calendar-8. |
person_idstring or nulloptional | Whose calendar it is, or null for a shared one. |
is_defaultbooleanoptional | Make it the calendar new events go to. |
is_visiblebooleanoptional | Whether it shows in the views by default. Defaults to true. |
is_busy_onlybooleanoptional | Store its events as 'Busy' with no details, for a calendar imported that way. Defaults to false. |
sort_orderintegeroptional | Where it goes in the list. Defaults to last. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.calendar_idstringrequired | The new calendar. |
versionintegerrequired | The household version after the command. |
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 | person_not_found | The owner must exist. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | name_taken | Names are unique ignoring case. |
409 | idempotency_key_reused | The Idempotency-Key was already used for a different command. |
Examples#
These are real. Each scenario is one of the command's test cases, run on a household when this site was built, and the response is what the API returned.
The first calendar made becomes the default, with the first color
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Family"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Family",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Family"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0F6R2BXTFC50T1K6Z
{
"result": {
"calendar_id": "cal_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A later one is last in the list with the next unused color, and not the default
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Nia'\''s school",
"person_id": "per_01JC000000000000000000000C"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Nia's school",
person_id: "per_01JC000000000000000000000C",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Nia's school",
"person_id": "per_01JC000000000000000000000C"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0TEV00XFZ3CWYACBX
{
"result": {
"calendar_id": "cal_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Is_default true takes the flag off the old default
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Home",
"is_default": true,
"color": "calendar-8",
"is_visible": false
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Home",
is_default: true,
color: "calendar-8",
is_visible: false,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Home",
"is_default": true,
"color": "calendar-8",
"is_visible": false
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0M3GXDESYZHDAZJ4G
{
"result": {
"calendar_id": "cal_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A busy-only calendar with an explicit sort order
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Ada'\''s work",
"is_busy_only": true,
"sort_order": 7
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Ada's work",
is_busy_only: true,
sort_order: 7,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Ada's work",
"is_busy_only": true,
"sort_order": 7
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0YKNTDDNTZHPZZ1SE
{
"result": {
"calendar_id": "cal_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Names are unique ignoring case
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "FAMILY"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "FAMILY",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "FAMILY"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0A8PDABX8X81R9XV4
{
"error": {
"code": "name_taken",
"message": "There's already a calendar called FAMILY. No changes were applied.",
"details": {
"name": "FAMILY"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0A8PDABX8X81R9XV4"
}
}The owner must exist
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Gran",
"person_id": "per_01JC000000000000000000000Z"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Gran",
person_id: "per_01JC000000000000000000000Z",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Gran",
"person_id": "per_01JC000000000000000000000Z"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0RVNZG4XB553TTV1D
{
"error": {
"code": "person_not_found",
"message": "That person isn't in the household any more. No changes were applied.",
"details": {
"person_id": "per_01JC000000000000000000000Z"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0RVNZG4XB553TTV1D"
}
}Add a calendar
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/calendar.calendar.create' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSHKQ6H7HF8FN8A6E4D3' \
-d '{
"name": "Kids'\'' activities",
"color": "calendar-4"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/calendar.calendar.create", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSHKQ6H7HF8FN8A6E4D3",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Kids' activities",
color: "calendar-4",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/calendar.calendar.create HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSHKQ6H7HF8FN8A6E4D3
{
"name": "Kids' activities",
"color": "calendar-4"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSHKKWBWR6TYXSCFYTSK
{
"result": {
"calendar_id": "cal_01M6V9CSHK7NNRTMZQSM1BFD1B"
},
"version": 87
}For Rigel#
Rigel's tool for this command is calendar_calendar_create. Rigel runs this on its own, then says what it did. The agent guide has the rest.