write_document
Create a draft, edit it, comment on it, archive it, or send it to a person for approval with an API key.
At a glance
A key works on drafts. It cannot publish a document, approve one or send one back: the approver does that in Alchex. Every answer is 200 with a message, and most carry a link to the document.
A key cannot delete a document: deleting needs a team Owner, and a key is never one. Archive the document instead. write_document/delete answers 404 tool_not_found, and "status": "Deleted" sent to archive answers 403 not_allowed_for_api_key.
Create a draft
The body must read as finished:
- It starts with
#and the title, then lines naming the owner, what it applies to, and when it is reviewed. - Its
##sections are exactly its type's, in order. A policy has Purpose, Scope, Roles and Responsibilities, Policy Statements, Implementation, Exceptions, Compliance, Review and References. A procedure has Purpose, Scope, Roles and Responsibilities, Procedure, Records, Exceptions, Review and References. Any other type has the six sections above. - It has no text in square brackets left to fill in.
A body that breaks a rule is refused with 400 and a code: not_reader_ready, structure_differs or placeholder_in_body. The message says what to fix.
Edit a draft
Each edit replaces the exact text in find with replace, up to 100 edits a request. An empty find adds replace at the end. An empty replace removes the text. Text a person changed since is not overwritten: the edit waits as a suggestion, and the message says so.
Comment
quote is optional text from the document that the new thread points at.
Archive
Send nothing else with it. A document a control depends on cannot be archived.
Send for approval
Name the approver by name or email. Left out, Alchex picks the only person who may approve; with several, it is refused with 400 refused, and the message lists them. The approver decides on a fixed copy; the draft stays editable meanwhile.