Add a contractor the household uses
maintenance.contractor.add
POST/api/v1/households/{household_id}/commands/maintenance.contractor.add
- Command
- Rigel runs it
- Applies offline
Records a business: a plumber, an HVAC company, a landscaper. Only the name is needed. Contractors belong to the household, not to one property. is_preferred defaults to false. An email address is also linked to that address in Email, so their mail shows on their 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 |
|---|---|
namestringrequired | A name as the household says it, 1–120 characters. |
tradestringoptional | What they do, in words: HVAC, plumbing, landscaping. |
phonestringoptional | A phone number as written. |
emailstringoptional | An email address. |
websitestring (uri)optional | A web address. |
addressstringoptional | Their office address. |
service_areastringoptional | Where they work: a town, a county, a radius. |
notesstringoptional | Anything worth remembering about them. |
is_preferredbooleanoptional | Whether this is the household's go-to for its trade. Defaults to false. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.contractor_idstringrequired | The new contractor. |
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 | 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.
Only a name
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contractor.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Smith HVAC"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contractor.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Smith HVAC",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contractor.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Smith HVAC"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0DBEMN0PKTHSPG60A
{
"result": {
"contractor_id": "ctr_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Everything, preferred
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contractor.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"name": "Jo'\''s Plumbing",
"trade": "Plumbing",
"phone": "555-0100",
"email": "jo@example.com",
"website": "https://jo.example.com",
"address": "1 Main St",
"service_area": "Marin County",
"notes": "Ask for Jo",
"is_preferred": true
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contractor.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Jo's Plumbing",
trade: "Plumbing",
phone: "555-0100",
email: "jo@example.com",
website: "https://jo.example.com",
address: "1 Main St",
service_area: "Marin County",
notes: "Ask for Jo",
is_preferred: true,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/maintenance.contractor.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"name": "Jo's Plumbing",
"trade": "Plumbing",
"phone": "555-0100",
"email": "jo@example.com",
"website": "https://jo.example.com",
"address": "1 Main St",
"service_area": "Marin County",
"notes": "Ask for Jo",
"is_preferred": true
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0SQMCNGAGYJ1V2VET
{
"result": {
"contractor_id": "ctr_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Add a contractor
An email address links the contractor to that address in Email, so their mail shows on their page.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contractor.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSWEAR8GHWXJV949B31Q' \
-d '{
"name": "Smith Heating & Air",
"trade": "HVAC",
"phone": "555-0142",
"email": "pat@smithhvac.example.com",
"website": "https://smithhvac.example.com",
"service_area": "Within 25 miles of town",
"notes": "Installed the furnace. Tune-up customers get same-week appointments.",
"is_preferred": true
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contractor.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSWEAR8GHWXJV949B31Q",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Smith Heating & Air",
trade: "HVAC",
phone: "555-0142",
email: "pat@smithhvac.example.com",
website: "https://smithhvac.example.com",
service_area: "Within 25 miles of town",
notes: "Installed the furnace. Tune-up customers get same-week appointments.",
is_preferred: true,
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contractor.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSWEAR8GHWXJV949B31Q
{
"name": "Smith Heating & Air",
"trade": "HVAC",
"phone": "555-0142",
"email": "pat@smithhvac.example.com",
"website": "https://smithhvac.example.com",
"service_area": "Within 25 miles of town",
"notes": "Installed the furnace. Tune-up customers get same-week appointments.",
"is_preferred": true
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSWEGNV0CC02RXP5TC4M
{
"result": {
"contractor_id": "ctr_01M6V9CSWEFJH8CRZCXNAH8109"
},
"version": 191
}Add another contractor
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contractor.add' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSWH7EXFXDWYT9MP829M' \
-d '{
"name": "Riverbend Plumbing & Drain",
"trade": "Plumbing",
"phone": "555-0178",
"email": "office@riverbendplumbing.example.com",
"notes": "Charges a flat trip fee."
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contractor.add", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSWH7EXFXDWYT9MP829M",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
name: "Riverbend Plumbing & Drain",
trade: "Plumbing",
phone: "555-0178",
email: "office@riverbendplumbing.example.com",
notes: "Charges a flat trip fee.",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/maintenance.contractor.add HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSWH7EXFXDWYT9MP829M
{
"name": "Riverbend Plumbing & Drain",
"trade": "Plumbing",
"phone": "555-0178",
"email": "office@riverbendplumbing.example.com",
"notes": "Charges a flat trip fee."
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSWHH5HWK3QGA7346FM3
{
"result": {
"contractor_id": "ctr_01M6V9CSWHPNYAY4A5FBX3R14F"
},
"version": 193
}For Rigel#
Rigel's tool for this command is maintenance_contractor_add. Rigel runs this on its own, then says what it did. The agent guide has the rest.