Skip to content
Rigel docs
Open Rigel

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#

Write an email draft, or change one: parameters
FieldDescription
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.

Write an email draft, or change one: request body fields
FieldDescription
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.

at most 5,000 characters
cc_addressesstringoptional

The Cc recipients, addresses separated by commas. Left out: none. Not checked until it is sent.

at most 5,000 characters
subjectstringoptional

The subject. Left out on a reply: "Re: " and the conversation's subject.

at most 998 characters
bodystringoptional

The message, in Markdown, up to 200,000 characters. It is sent as plain text and simple HTML.

at most 200,000 characters
file_idsarray of stringsoptional

The files to attach, up to 20. On a change, replaces the attachments already on the draft.

at most 20 items

Response#

200 The command was applied.

Write an email draft, or change one: response fields
FieldDescription
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.

Write an email draft, or change one: errors
StatusCodeWhen
400validation_failedA field is missing, misspelled or out of range. details.fields lists each problem.
401unauthenticatedThe request has no valid session.
404address_not_foundAn address that isn't there is refused.
404thread_not_foundA thread that isn't there is refused.
404person_not_foundA person that isn't there is refused.
404file_not_foundA file that isn't there is refused.
404draft_not_foundA draft that isn't there is refused.
404not_foundThe household doesn't exist, or you aren't a member of it.
409no_addressWith no address at all, there is nothing to send from.
409invalid_recipient
  • A recipient that isn't an address is refused when written.
  • An invalid cc is refused too.
409draft_not_editable
  • A draft that is sending can't be changed.
  • A draft that was sent can't be changed.
409idempotency_key_reusedThe 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

Request, curl
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 '{}'
Request, TypeScript
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();
Request, HTTP
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

{}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
  ]
}'
Request, TypeScript
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();
Request, HTTP
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"
  ]
}
Response, 200
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

Request, curl
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
}'
Request, TypeScript
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();
Request, HTTP
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
}
Response, 200
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

Request, curl
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."
}'
Request, TypeScript
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();
Request, HTTP
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."
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 200
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

Request, curl
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>"
}'
Request, TypeScript
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();
Request, HTTP
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>"
}
Response, 200
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

Request, curl
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": ""
}'
Request, TypeScript
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();
Request, HTTP
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": ""
}
Response, 200
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

Request, curl
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>"
}'
Request, TypeScript
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();
Request, HTTP
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>"
}
Response, 200
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

Request, curl
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"
  ]
}'
Request, TypeScript
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();
Request, HTTP
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"
  ]
}
Response, 200
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

Request, curl
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": []
}'
Request, TypeScript
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();
Request, HTTP
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": []
}
Response, 200
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

Request, curl
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
}'
Request, TypeScript
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();
Request, HTTP
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
}
Response, 200
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

Request, curl
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 '{}'
Request, TypeScript
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();
Request, HTTP
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

{}
Response, 409
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 404
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 404
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 404
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

Request, curl
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"
  ]
}'
Request, TypeScript
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();
Request, HTTP
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"
  ]
}
Response, 404
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 409
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 409
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 409
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 409
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

Request, curl
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"
}'
Request, TypeScript
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();
Request, HTTP
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"
}
Response, 404
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.

Request, curl
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."
}'
Request, TypeScript
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();
Request, HTTP
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."
}
Response, 200
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

Request, curl
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."
}'
Request, TypeScript
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();
Request, HTTP
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."
}
Response, 200
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.

Request, curl
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?"
}'
Request, TypeScript
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();
Request, HTTP
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?"
}
Response, 200
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.

Rigel is in early access, and sign-up is by invitation. Open Rigel