Write a new document
documents.document.write_new
POST/api/v1/households/{household_id}/commands/documents.document.write_new
- Command
- Rigel runs it
- Applies offline
Creates a Markdown or HTML document with the given text. Use Markdown for notes and anything people will edit; use HTML when layout matters (a printable one-pager) and people will ask you to change it. HTML must use semantic elements and no scripts. Pass links to attach it to records (a trip plan to the trip, a guide to a person). From an app, pass app so the document says where it came from. Refused with folder_not_found, record_not_found, or content_too_long.
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 |
|---|---|
titlestringrequired | The document's title, as written, 1–300 characters. |
kindone of: markdown, htmlrequired | markdown for notes and shared editing; html for laid-out pages. |
contentstringrequired | The document's text, in the chosen format. At most 2,000,000 characters. |
folder_idstringoptional | The folder to file it in; leave out to leave it unfiled. |
linksarray of objectsoptional | Records to link the new document to, such as the furnace it is the manual for. A record listed twice is linked once, with the last note. |
links[].record_idstringrequired | The ID of any record in the household, such as tsk_01JC0000000000000000000000. |
links[].notestringoptional | Why they are linked, when it isn't obvious: "manual", "quote", "warranty". |
appone of: meals, recipes, shopping, inventory, calendar, email, tasks, documents, chat, maintenanceoptional | The app this document is being made for or from, recorded as its source. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.document_idstringrequired | The new document. |
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 | folder_not_found | A folder that is gone. |
404 | record_not_found |
|
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | idempotency_key_reused | The Idempotency-Key was already used for a different command. |
Examples#
These are real. Each scenario is one of the command's test cases, run on a household when this site was built, and the response is what the API returned.
A Markdown document a person wrote
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Summer trip ideas",
"kind": "markdown",
"content": "# Ideas"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Summer trip ideas",
kind: "markdown",
content: "# Ideas",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Summer trip ideas",
"kind": "markdown",
"content": "# Ideas"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0T02G30A79FMPP958
{
"result": {
"document_id": "doc_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Filed in a folder, with an empty text
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Notes",
"kind": "markdown",
"content": "",
"folder_id": "fld_01JC0000000000000000000001"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Notes",
kind: "markdown",
content: "",
folder_id: "fld_01JC0000000000000000000001",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Notes",
"kind": "markdown",
"content": "",
"folder_id": "fld_01JC0000000000000000000001"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0GCPGA5R71ZPZGN4M
{
"result": {
"document_id": "doc_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}Linked to records, once each with the last note
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Guide",
"kind": "html",
"content": "x",
"links": [
{
"record_id": "per_01JC0000000000000000000001",
"note": "about"
},
{
"record_id": "per_01JC0000000000000000000002"
},
{
"record_id": "per_01JC0000000000000000000001",
"note": "again"
}
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Guide",
kind: "html",
content: "x",
links: [
{
record_id: "per_01JC0000000000000000000001",
note: "about",
},
{
record_id: "per_01JC0000000000000000000002",
},
{
record_id: "per_01JC0000000000000000000001",
note: "again",
},
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Guide",
"kind": "html",
"content": "x",
"links": [
{
"record_id": "per_01JC0000000000000000000001",
"note": "about"
},
{
"record_id": "per_01JC0000000000000000000002"
},
{
"record_id": "per_01JC0000000000000000000001",
"note": "again"
}
]
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0KF781FTMZZKKQ10X
{
"result": {
"document_id": "doc_01JC4N0000MBGE5RJ6Q7V6V6T8"
},
"version": 1
}A folder that is gone
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Notes",
"kind": "markdown",
"content": "",
"folder_id": "fld_01JC0000000000000000000001"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Notes",
kind: "markdown",
content: "",
folder_id: "fld_01JC0000000000000000000001",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Notes",
"kind": "markdown",
"content": "",
"folder_id": "fld_01JC0000000000000000000001"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R083QHYC8H3PAZ44JK
{
"error": {
"code": "folder_not_found",
"message": "That folder isn't there any more. No changes were applied.",
"details": {
"folder_id": "fld_01JC0000000000000000000001"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R083QHYC8H3PAZ44JK"
}
}A record that is gone
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Notes",
"kind": "markdown",
"content": "",
"links": [
{
"record_id": "per_01JC0000000000000000000001"
}
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Notes",
kind: "markdown",
content: "",
links: [
{
record_id: "per_01JC0000000000000000000001",
},
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Notes",
"kind": "markdown",
"content": "",
"links": [
{
"record_id": "per_01JC0000000000000000000001"
}
]
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0R20VQ36RJA02R0MF
{
"error": {
"code": "record_not_found",
"message": "There is no record with that ID, so it can't be linked. No changes were applied.",
"details": {
"record_id": "per_01JC0000000000000000000001"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0R20VQ36RJA02R0MF"
}
}A record ID with an unknown prefix
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"title": "Notes",
"kind": "markdown",
"content": "",
"links": [
{
"record_id": "zzz_01JC0000000000000000000001"
}
]
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Notes",
kind: "markdown",
content: "",
links: [
{
record_id: "zzz_01JC0000000000000000000001",
},
],
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"title": "Notes",
"kind": "markdown",
"content": "",
"links": [
{
"record_id": "zzz_01JC0000000000000000000001"
}
]
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0MXK12ZDZWTX08T85
{
"error": {
"code": "record_not_found",
"message": "There is no record with that ID, so it can't be linked. No changes were applied.",
"details": {
"record_id": "zzz_01JC0000000000000000000001"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0MXK12ZDZWTX08T85"
}
}Write a note about a piece of equipment
links keep it with the records it's about, and app says which app it came from.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CTA4B3VSHTN5C4CHS81E' \
-d '{
"title": "Furnace notes",
"kind": "markdown",
"content": "# Furnace notes\n\nThe furnace is in the utility closet in the basement.\n\n## The filter\n\nIt takes one 16x25x1 filter. The slot is on the right side, behind the blower door. Write the date on the frame.\n\n## Who to call\n\nSmith Heating & Air installed it. Pat Smith is the person to ask for, before 10 am: 555-0142.\n",
"folder_id": "fld_01M6V9CT9VW92QWV5HRBAXVASH",
"links": [
{
"record_id": "ast_01M6V9CSVCMZFAP6ZN5WANZ6M8",
"note": "Care notes"
}
],
"app": "maintenance"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CTA4B3VSHTN5C4CHS81E",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Furnace notes",
kind: "markdown",
content: "# Furnace notes\n\nThe furnace is in the utility closet in the basement.\n\n## The filter\n\nIt takes one 16x25x1 filter. The slot is on the right side, behind the blower door. Write the date on the frame.\n\n## Who to call\n\nSmith Heating & Air installed it. Pat Smith is the person to ask for, before 10 am: 555-0142.\n",
folder_id: "fld_01M6V9CT9VW92QWV5HRBAXVASH",
links: [
{
record_id: "ast_01M6V9CSVCMZFAP6ZN5WANZ6M8",
note: "Care notes",
},
],
app: "maintenance",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CTA4B3VSHTN5C4CHS81E
{
"title": "Furnace notes",
"kind": "markdown",
"content": "# Furnace notes\n\nThe furnace is in the utility closet in the basement.\n\n## The filter\n\nIt takes one 16x25x1 filter. The slot is on the right side, behind the blower door. Write the date on the frame.\n\n## Who to call\n\nSmith Heating & Air installed it. Pat Smith is the person to ask for, before 10 am: 555-0142.\n",
"folder_id": "fld_01M6V9CT9VW92QWV5HRBAXVASH",
"links": [
{
"record_id": "ast_01M6V9CSVCMZFAP6ZN5WANZ6M8",
"note": "Care notes"
}
],
"app": "maintenance"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CTA4D5E3RJ8S1R1TG1WJ
{
"result": {
"document_id": "doc_01M6V9CTA49AN0VKX4EC3Q8R0A"
},
"version": 300
}Write a note for a project
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CTA89W9MP9H731DBTY33' \
-d '{
"title": "Playroom plan",
"kind": "markdown",
"content": "# Playroom plan\n\nPaint and shelves before the holidays.\n\n## Walls\n\nNia is choosing the color. Ben paints once the shelves are ordered.\n\n## Shelves\n\nOak, built in along the east wall. The carpenter'\''s quote is due this week.\n",
"folder_id": "fld_01M6V9CT9VW92QWV5HRBAXVASH",
"links": [
{
"record_id": "tsk_01M6V9CT2Z01QVT17DRMSXTW4W"
}
],
"app": "tasks"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CTA89W9MP9H731DBTY33",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Playroom plan",
kind: "markdown",
content: "# Playroom plan\n\nPaint and shelves before the holidays.\n\n## Walls\n\nNia is choosing the color. Ben paints once the shelves are ordered.\n\n## Shelves\n\nOak, built in along the east wall. The carpenter's quote is due this week.\n",
folder_id: "fld_01M6V9CT9VW92QWV5HRBAXVASH",
links: [
{
record_id: "tsk_01M6V9CT2Z01QVT17DRMSXTW4W",
},
],
app: "tasks",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CTA89W9MP9H731DBTY33
{
"title": "Playroom plan",
"kind": "markdown",
"content": "# Playroom plan\n\nPaint and shelves before the holidays.\n\n## Walls\n\nNia is choosing the color. Ben paints once the shelves are ordered.\n\n## Shelves\n\nOak, built in along the east wall. The carpenter's quote is due this week.\n",
"folder_id": "fld_01M6V9CT9VW92QWV5HRBAXVASH",
"links": [
{
"record_id": "tsk_01M6V9CT2Z01QVT17DRMSXTW4W"
}
],
"app": "tasks"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CTA8H0ZK4321P53XAGEV
{
"result": {
"document_id": "doc_01M6V9CTA8APRK3KGY0M9RKB4W"
},
"version": 301
}Write a printable page
Use html when layout matters. It must use semantic elements and no scripts.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CTAB722KP69T9EG100KV' \
-d '{
"title": "Babysitter sheet",
"kind": "html",
"content": "<h1>Babysitter sheet</h1>\n<h2>Bedtimes</h2>\n<ul>\n <li>Theo: 7:30 pm, one story</li>\n <li>Nia: 8:30 pm, reading allowed until 9:00</li>\n</ul>\n<h2>Numbers</h2>\n<ul>\n <li>Ada: 555-0161</li>\n <li>Ben: 555-0162</li>\n</ul>\n",
"folder_id": "fld_01M6V9CT9X97T5BFYDED4FC8FW"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CTAB722KP69T9EG100KV",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
title: "Babysitter sheet",
kind: "html",
content: "<h1>Babysitter sheet</h1>\n<h2>Bedtimes</h2>\n<ul>\n <li>Theo: 7:30 pm, one story</li>\n <li>Nia: 8:30 pm, reading allowed until 9:00</li>\n</ul>\n<h2>Numbers</h2>\n<ul>\n <li>Ada: 555-0161</li>\n <li>Ben: 555-0162</li>\n</ul>\n",
folder_id: "fld_01M6V9CT9X97T5BFYDED4FC8FW",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/documents.document.write_new HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CTAB722KP69T9EG100KV
{
"title": "Babysitter sheet",
"kind": "html",
"content": "<h1>Babysitter sheet</h1>\n<h2>Bedtimes</h2>\n<ul>\n <li>Theo: 7:30 pm, one story</li>\n <li>Nia: 8:30 pm, reading allowed until 9:00</li>\n</ul>\n<h2>Numbers</h2>\n<ul>\n <li>Ada: 555-0161</li>\n <li>Ben: 555-0162</li>\n</ul>\n",
"folder_id": "fld_01M6V9CT9X97T5BFYDED4FC8FW"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CTABKE86X87FA145S2B8
{
"result": {
"document_id": "doc_01M6V9CTABNCYZEX66AV1YAYHY"
},
"version": 302
}For Rigel#
Rigel's tool for this command is documents_document_write_new. Rigel runs this on its own, then says what it did. The agent guide has the rest.