Add a named person at a contractor
maintenance.contact.add
POST/api/v1/households/{household_id}/commands/maintenance.contact.add
- Command
- Rigel runs it
- Applies offline
Records someone to ask for at a contractor, with how to reach them. An email address is also linked to that address in Email, so their mail shows on the contractor's page.
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 |
|---|---|
contractor_idstringrequired | A contractor ID, such as ctr_01JC0000000000000000000000. |
namestringrequired | A name as the household says it, 1–120 characters. |
rolestringoptional | Their job there: office manager, technician. |
phonestringoptional | A phone number as written. |
emailstringoptional | An email address. |
notesstringoptional | Anything worth remembering, such as the best time to call. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.contact_idstringrequired | The new contact. |
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 | contractor_not_found | A contractor that isn't there. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
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.
A named person
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"contractor_id": "ctr_01JC00000000000000000000K1",
"name": "Pat",
"role": "Dispatcher",
"phone": "555-0101",
"email": "pat@example.com",
"notes": "Mornings"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
contractor_id: "ctr_01JC00000000000000000000K1",
name: "Pat",
role: "Dispatcher",
phone: "555-0101",
email: "pat@example.com",
notes: "Mornings",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"contractor_id": "ctr_01JC00000000000000000000K1",
"name": "Pat",
"role": "Dispatcher",
"phone": "555-0101",
"email": "pat@example.com",
"notes": "Mornings"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0B3VQDWEKY8HVY29N
{
"result": {
"contact_id": "ccn_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Only a name
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"contractor_id": "ctr_01JC00000000000000000000K1",
"name": "Pat"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
contractor_id: "ctr_01JC00000000000000000000K1",
name: "Pat",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"contractor_id": "ctr_01JC00000000000000000000K1",
"name": "Pat"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0A5T31AYRF0FHE88R
{
"result": {
"contact_id": "ccn_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A contractor that isn't there
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"contractor_id": "ctr_01JC00000000000000000000K1",
"name": "Pat"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
contractor_id: "ctr_01JC00000000000000000000K1",
name: "Pat",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contact.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"contractor_id": "ctr_01JC00000000000000000000K1",
"name": "Pat"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0642PAHMCYY8EZ5X0
{
"error": {
"code": "contractor_not_found",
"message": "That contractor isn't there any more. No changes were applied.",
"details": {
"contractor_id": "ctr_01JC00000000000000000000K1"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0642PAHMCYY8EZ5X0"
}
}Add the person to ask for at a contractor
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contact.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSWG95YAASDWDM767PNE' \
-d '{
"contractor_id": "ctr_01M6V9CSWEFJH8CRZCXNAH8109",
"name": "Pat Smith",
"role": "Service manager",
"notes": "Best reached before 10 am."
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contact.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSWG95YAASDWDM767PNE",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
contractor_id: "ctr_01M6V9CSWEFJH8CRZCXNAH8109",
name: "Pat Smith",
role: "Service manager",
notes: "Best reached before 10 am.",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contact.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSWG95YAASDWDM767PNE
{
"contractor_id": "ctr_01M6V9CSWEFJH8CRZCXNAH8109",
"name": "Pat Smith",
"role": "Service manager",
"notes": "Best reached before 10 am."
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSWGVZTJGA85JRQYVX6D
{
"result": {
"contact_id": "ccn_01M6V9CSWGTX839J9HJDVKV38M"
},
"version": 192
}For Rigel#
Rigel's tool for this command is maintenance_contact_add. Rigel runs this on its own, then says what it did. The agent guide has the rest.