Write an email draft, or change one
email.draft.write
POST/api/v1/households/{household_id}/commands/email.draft.write
- Command
- Rigel runs it
- Applies offline
Creates a draft when email_draft_id is left out, otherwise changes that draft (only while it is a draft or failed; a failed draft becomes a draft again). Nothing is sent: use email.draft.send for that. With email_thread_id it is a reply: the recipient is the sender of the latest email that came in on the conversation, the subject is "Re: " plus the conversation's subject, and it goes out from the address that email arrived at. Recipients are checked to be email addresses, but a draft may have none yet. Fails with draft_not_found, invalid_recipient (details.recipient is the entry that isn't an address), draft_not_editable, address_not_found, thread_not_found, person_not_found, file_not_found, or no_address when there is no address to send from.
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 |
|---|---|
email_draft_idstringoptional | The draft to change. Left out: a new draft is created. |
email_thread_idstringoptional | The conversation this replies to. Fills in the recipient, subject and from address that you leave out. |
from_email_address_idstringoptional | The address it goes out from. Left out: the address the replied-to email arrived at, else the default address. |
from_person_idstring or nulloptional | The family member it is sent for, so it goes out as "Their Name <address>". Left out on a new draft: the person making the request. Null: send under the address's own display name. |
to_addressesstringoptional | The To recipients: addresses separated by commas, such as "Smith HVAC <office@smithhvac.example>". Left out on a reply: the sender of the latest email in the conversation. Not checked until it is sent. |
cc_addressesstringoptional | The Cc recipients, addresses separated by commas. Left out: none. Not checked until it is sent. |
subjectstringoptional | The subject. Left out on a reply: "Re: " and the conversation's subject. |
bodystringoptional | The message, in Markdown, up to 200,000 characters. It is sent as plain text and simple HTML. |
file_idsarray of stringsoptional | The files to attach, up to 20. On a change, replaces the attachments already on the draft. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.email_draft_idstringrequired | The draft that was created or changed. |
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 | address_not_found | An address that isn't there is refused. |
404 | thread_not_found | A thread that isn't there is refused. |
404 | person_not_found | A person that isn't there is refused. |
404 | file_not_found | A file that isn't there is refused. |
404 | draft_not_found | A draft that isn't there is refused. |
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | no_address | With no address at all, there is nothing to send from. |
409 | invalid_recipient |
|
409 | draft_not_editable |
|
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 new draft uses the default address and the person making the request
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0RFTSA8SXGHCC8CRZ
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Typed recipients become correspondents and recipient rows; with no person the draft goes in the address's name
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"to_addresses": "Kim Lee <Kim@Example.com>; lee@example.com",
"cc_addresses": "b@x.co",
"subject": "Hi",
"body": "Hello Kim"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
to_addresses: "Kim Lee <Kim@Example.com>; lee@example.com",
cc_addresses: "b@x.co",
subject: "Hi",
body: "Hello Kim",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"to_addresses": "Kim Lee <Kim@Example.com>; lee@example.com",
"cc_addresses": "b@x.co",
"subject": "Hi",
"body": "Hello Kim"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0XS9V884F1CCTVJ3Q
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A known correspondent is reused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"to_addresses": "kim@example.com"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
to_addresses: "kim@example.com",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"to_addresses": "kim@example.com"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0N5R2729J7P746FSP
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Everything given is used, with attachments
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"from_email_address_id": "eml_01JC0000000000000000000002",
"from_person_id": "per_01JC0000000000000000000002",
"to_addresses": "a@x.co",
"cc_addresses": "b@x.co",
"subject": "S",
"body": "B",
"file_ids": [
"fil_01JC0000000000000000000001",
"fil_01JC0000000000000000000002",
"fil_01JC0000000000000000000001"
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
from_email_address_id: "eml_01JC0000000000000000000002",
from_person_id: "per_01JC0000000000000000000002",
to_addresses: "a@x.co",
cc_addresses: "b@x.co",
subject: "S",
body: "B",
file_ids: [
"fil_01JC0000000000000000000001",
"fil_01JC0000000000000000000002",
"fil_01JC0000000000000000000001",
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"from_email_address_id": "eml_01JC0000000000000000000002",
"from_person_id": "per_01JC0000000000000000000002",
"to_addresses": "a@x.co",
"cc_addresses": "b@x.co",
"subject": "S",
"body": "B",
"file_ids": [
"fil_01JC0000000000000000000001",
"fil_01JC0000000000000000000002",
"fil_01JC0000000000000000000001"
]
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R033GN4HJJ80MWTW5T
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A null person means the address's own name
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"from_person_id": null
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
from_person_id: null,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"from_person_id": null
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0PJV4QNG92QH5C1AR
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A reply defaults recipient, subject and from address from the latest email that came in
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_thread_id": "emt_01JC0000000000000000000001",
"body": "We'\''ll take the quote."
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_thread_id: "emt_01JC0000000000000000000001",
body: "We'll take the quote.",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_thread_id": "emt_01JC0000000000000000000001",
"body": "We'll take the quote."
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0R9K03K5DNCGS8S7V
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A reply can override the defaults
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_thread_id": "emt_01JC0000000000000000000001",
"from_email_address_id": "eml_01JC0000000000000000000001",
"to_addresses": "other@x.co",
"subject": "Quote"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_thread_id: "emt_01JC0000000000000000000001",
from_email_address_id: "eml_01JC0000000000000000000001",
to_addresses: "other@x.co",
subject: "Quote",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_thread_id": "emt_01JC0000000000000000000001",
"from_email_address_id": "eml_01JC0000000000000000000001",
"to_addresses": "other@x.co",
"subject": "Quote"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R08RGZ506EJHZ1QRYV
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A reply to a thread with only outgoing mail uses the default address and no recipient
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_thread_id": "emt_01JC0000000000000000000001"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_thread_id: "emt_01JC0000000000000000000001",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_thread_id": "emt_01JC0000000000000000000001"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0TTEFW6S388WZTK1N
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A reply whose email arrived at a removed address falls back to the default
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_thread_id": "emt_01JC0000000000000000000001"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_thread_id: "emt_01JC0000000000000000000001",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_thread_id": "emt_01JC0000000000000000000001"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0FGNXPMZECDRYRJ28
{
"result": {
"email_draft_id": "emf_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Changing a draft sets only the fields given
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"subject": "New subject"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
subject: "New subject",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"subject": "New subject"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0VFRKSKDWJSEBHWR6
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}Changing a failed draft makes it a draft again and clears the problem
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"body": "Try again"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
body: "Try again",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"body": "Try again"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0JW3JM28ABR07DYQ5
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}Given To recipients replace the To recipients and leave Cc alone
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": "lee@example.com"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
to_addresses: "lee@example.com",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": "lee@example.com"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R07FGR1KZQG1T7FK51
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}An address moved from Cc to To changes its kind
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": "Kim <kim@example.com>"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
to_addresses: "Kim <kim@example.com>",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": "Kim <kim@example.com>"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R06KBH9JZG2X3DDY24
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}An empty To clears the To recipients
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": ""
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
to_addresses: "",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": ""
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0T8D36MX552KPGWYQ
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}A new name for a recipient is kept on their correspondent
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": "Kimberly <kim@example.com>"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
to_addresses: "Kimberly <kim@example.com>",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"to_addresses": "Kimberly <kim@example.com>"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0N18G41J6BMH6CBR1
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}Given file_ids replace the attachments
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"file_ids": [
"fil_01JC0000000000000000000002",
"fil_01JC0000000000000000000003"
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
file_ids: [
"fil_01JC0000000000000000000002",
"fil_01JC0000000000000000000003",
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"file_ids": [
"fil_01JC0000000000000000000002",
"fil_01JC0000000000000000000003"
]
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0EB0Q8T9YQB34BFRB
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}An empty file_ids removes every attachment
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"file_ids": []
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
file_ids: [],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"file_ids": []
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R01G52AA1Y0J8KHNTG
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}The sender can change to another person or to none
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"from_person_id": null
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
from_person_id: null,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"from_person_id": null
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0GKS8S9AQE38K00QH
{
"result": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"version": 1
}With no address at all, there is nothing to send from
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R02A7MA0VHA7KFR86E
{
"error": {
"code": "no_address",
"message": "Rigel has no email address to send from yet. No changes were applied.",
"details": {},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R02A7MA0VHA7KFR86E"
}
}An address that isn't there is refused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"from_email_address_id": "eml_01JC0000000000000000000009"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
from_email_address_id: "eml_01JC0000000000000000000009",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"from_email_address_id": "eml_01JC0000000000000000000009"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0YHWBDVCP0CWH7SC3
{
"error": {
"code": "address_not_found",
"message": "That email address isn't there any more. No changes were applied.",
"details": {
"email_address_id": "eml_01JC0000000000000000000009"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0YHWBDVCP0CWH7SC3"
}
}A thread that isn't there is refused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_thread_id": "emt_01JC0000000000000000000009"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_thread_id: "emt_01JC0000000000000000000009",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_thread_id": "emt_01JC0000000000000000000009"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R09W90P6R88D6GCNA1
{
"error": {
"code": "thread_not_found",
"message": "That conversation isn't here any more. No changes were applied.",
"details": {
"email_thread_id": "emt_01JC0000000000000000000009"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R09W90P6R88D6GCNA1"
}
}A person that isn't there is refused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"from_person_id": "per_01JC0000000000000000000009"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
from_person_id: "per_01JC0000000000000000000009",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"from_person_id": "per_01JC0000000000000000000009"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0XBT1SFJZPTTS9KBY
{
"error": {
"code": "person_not_found",
"message": "That person isn't in the household any more. No changes were applied.",
"details": {
"person_id": "per_01JC0000000000000000000009"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0XBT1SFJZPTTS9KBY"
}
}A file that isn't there is refused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"file_ids": [
"fil_01JC0000000000000000000009"
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
file_ids: [
"fil_01JC0000000000000000000009",
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"file_ids": [
"fil_01JC0000000000000000000009"
]
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0V421E5HA78Y93552
{
"error": {
"code": "file_not_found",
"message": "That file isn't there any more. No changes were applied.",
"details": {
"file_id": "fil_01JC0000000000000000000009"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0V421E5HA78Y93552"
}
}A recipient that isn't an address is refused when written
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"to_addresses": "kim@example.com, nonsense"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
to_addresses: "kim@example.com, nonsense",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"to_addresses": "kim@example.com, nonsense"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0QY2E98XJ8ZVF72TY
{
"error": {
"code": "invalid_recipient",
"message": "\"nonsense\" isn't an email address. No changes were applied.",
"details": {
"recipient": "nonsense"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0QY2E98XJ8ZVF72TY"
}
}An invalid cc is refused too
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"cc_addresses": "bad"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
cc_addresses: "bad",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"cc_addresses": "bad"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0HS20YK3FDDQ214E7
{
"error": {
"code": "invalid_recipient",
"message": "\"bad\" isn't an email address. No changes were applied.",
"details": {
"recipient": "bad"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0HS20YK3FDDQ214E7"
}
}A draft that is sending can't be changed
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"body": "x"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
body: "x",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"body": "x"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R05F9CZ6WHQRA79Q6G
{
"error": {
"code": "draft_not_editable",
"message": "That draft is already on its way or sent, so it can't be changed. No changes were applied.",
"details": {
"state": "sending"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R05F9CZ6WHQRA79Q6G"
}
}A draft that was sent can't be changed
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001",
"body": "x"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
body: "x",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001",
"body": "x"
}HTTP/1.1 409 Conflict
Content-Type: application/json
X-Request-Id: req_01K9D9S2R07BJQFJCAWB9X9EWS
{
"error": {
"code": "draft_not_editable",
"message": "That draft is already on its way or sent, so it can't be changed. No changes were applied.",
"details": {
"state": "sent"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R07BJQFJCAWB9X9EWS"
}
}A draft that isn't there is refused
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"email_draft_id": "emf_01JC0000000000000000000001"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01JC0000000000000000000001",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"email_draft_id": "emf_01JC0000000000000000000001"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0A1SNJQ4PT0BC0C9H
{
"error": {
"code": "draft_not_found",
"message": "That draft isn't here any more. No changes were applied.",
"details": {
"email_draft_id": "emf_01JC0000000000000000000001"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0A1SNJQ4PT0BC0C9H"
}
}Write a reply
With email_thread_id, the recipient, subject and from address are filled in. Nothing is sent until someone sends the draft.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSRYF6HWCJYFS2R3BEWG' \
-d '{
"email_thread_id": "emt_01M6V9CSQK00H6ZNSV7F9ENC49",
"body": "Thank you. We'\''ll be there at 3:20 pm on Thursday."
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSRYF6HWCJYFS2R3BEWG",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_thread_id: "emt_01M6V9CSQK00H6ZNSV7F9ENC49",
body: "Thank you. We'll be there at 3:20 pm on Thursday.",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSRYF6HWCJYFS2R3BEWG
{
"email_thread_id": "emt_01M6V9CSQK00H6ZNSV7F9ENC49",
"body": "Thank you. We'll be there at 3:20 pm on Thursday."
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSRYTPVRY8J2MXYP9VMA
{
"result": {
"email_draft_id": "emf_01M6V9CSRY2YJHWT6T44V5M78S"
},
"version": 145
}Change a draft
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSS0RVF2NY2SQQJJVSGV' \
-d '{
"email_draft_id": "emf_01M6V9CSRY2YJHWT6T44V5M78S",
"body": "Thank you. We'\''ll be there at 3:20 pm on Thursday, and we'\''ll bring the insurance card."
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSS0RVF2NY2SQQJJVSGV",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
email_draft_id: "emf_01M6V9CSRY2YJHWT6T44V5M78S",
body: "Thank you. We'll be there at 3:20 pm on Thursday, and we'll bring the insurance card.",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSS0RVF2NY2SQQJJVSGV
{
"email_draft_id": "emf_01M6V9CSRY2YJHWT6T44V5M78S",
"body": "Thank you. We'll be there at 3:20 pm on Thursday, and we'll bring the insurance card."
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSS0QDKCEWN3VEEE77GG
{
"result": {
"email_draft_id": "emf_01M6V9CSRY2YJHWT6T44V5M78S"
},
"version": 146
}Write a new email
Addresses are written the way an email client does: a name and an address, separated by commas.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSS2CGPCWVMR2KMDF8NE' \
-d '{
"to_addresses": "Pat Smith <pat@smithhvac.example.com>",
"subject": "Furnace quote",
"body": "Could you send the quote again?"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSS2CGPCWVMR2KMDF8NE",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
to_addresses: "Pat Smith <pat@smithhvac.example.com>",
subject: "Furnace quote",
body: "Could you send the quote again?",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/email.draft.write HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSS2CGPCWVMR2KMDF8NE
{
"to_addresses": "Pat Smith <pat@smithhvac.example.com>",
"subject": "Furnace quote",
"body": "Could you send the quote again?"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSS2TM1FJN3B85D4H0A8
{
"result": {
"email_draft_id": "emf_01M6V9CSS28T4ADS0XYSNEQG13"
},
"version": 147
}For Rigel#
Rigel's tool for this command is email_draft_write. Rigel runs this on its own, then says what it did. The agent guide has the rest.