Take one person out of a meal
meals.meal.remove_person
POST/api/v1/households/{household_id}/commands/meals.meal.remove_person
- Command
- Rigel runs it
- Applies offline
For "Theo is at grandma's on Saturday": removes the person from the meal and leaves the others. If no one is left the meal is deleted. Fails with person_not_in_meal if they weren't in it.
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 |
|---|---|
meal_idstringrequired | A meal ID, such as mel_01JC0000000000000000000000. |
person_idstringrequired | A person ID, such as per_01JC0000000000000000000000. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.meal_removedbooleanrequired | True when that was the last person and the meal was deleted. |
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 | meal_not_found | A missing meal. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | person_not_in_meal | Someone who isn't in the meal. |
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.
Takes one person out and keeps the meal
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"meal_id": "mel_01JC000000000000000000000A",
"person_id": "per_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
meal_id: "mel_01JC000000000000000000000A",
person_id: "per_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"meal_id": "mel_01JC000000000000000000000A",
"person_id": "per_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R02AVYDDE104EM3NS7
{
"result": {
"meal_removed": false
},
"version": 1
}The last person takes the meal with them
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"meal_id": "mel_01JC000000000000000000000B",
"person_id": "per_01JC000000000000000000000C"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
meal_id: "mel_01JC000000000000000000000B",
person_id: "per_01JC000000000000000000000C",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"meal_id": "mel_01JC000000000000000000000B",
"person_id": "per_01JC000000000000000000000C"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0HR91DTRHVW9YAN3S
{
"result": {
"meal_removed": true
},
"version": 1
}Someone who isn't in the meal
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"meal_id": "mel_01JC000000000000000000000A",
"person_id": "per_01JC000000000000000000000C"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
meal_id: "mel_01JC000000000000000000000A",
person_id: "per_01JC000000000000000000000C",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"meal_id": "mel_01JC000000000000000000000A",
"person_id": "per_01JC000000000000000000000C"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R08NME20PY3BZN6ZVG
{
"error": {
"code": "person_not_in_meal",
"message": "They aren't in that meal. No changes were applied.",
"details": {
"meal_id": "mel_01JC000000000000000000000A",
"person_id": "per_01JC000000000000000000000C"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R08NME20PY3BZN6ZVG"
}
}A missing meal
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"meal_id": "mel_01JC000000000000000000000Z",
"person_id": "per_01JC000000000000000000000C"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
meal_id: "mel_01JC000000000000000000000Z",
person_id: "per_01JC000000000000000000000C",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.meal.remove_person HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"meal_id": "mel_01JC000000000000000000000Z",
"person_id": "per_01JC000000000000000000000C"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0AEW5KMJETEZRS19G
{
"error": {
"code": "meal_not_found",
"message": "That meal isn't there any more. No changes were applied.",
"details": {
"meal_id": "mel_01JC000000000000000000000Z"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0AEW5KMJETEZRS19G"
}
}Take one person out of a meal
For "Theo is at Grandma's on Sunday". The meal stays for everyone else.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/meals.meal.remove_person' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSGM36VDKBREGFJFBRYV' \
-d '{
"meal_id": "mel_01M6V9CSFXE8ZNK29NR2EPTDDZ",
"person_id": "per_01M6V9CS7CDAEP5VDA5T8R9TG6"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/meals.meal.remove_person", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSGM36VDKBREGFJFBRYV",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
meal_id: "mel_01M6V9CSFXE8ZNK29NR2EPTDDZ",
person_id: "per_01M6V9CS7CDAEP5VDA5T8R9TG6",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/meals.meal.remove_person HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSGM36VDKBREGFJFBRYV
{
"meal_id": "mel_01M6V9CSFXE8ZNK29NR2EPTDDZ",
"person_id": "per_01M6V9CS7CDAEP5VDA5T8R9TG6"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSGMPHG7A1DSD4G5C1XK
{
"result": {
"meal_removed": false
},
"version": 81
}For Rigel#
Rigel's tool for this command is meals_meal_remove_person. Rigel runs this on its own, then says what it did. The agent guide has the rest.