Request and response objects
The minimal command sequence, required and recommended request fields, the response format, and error handling.
Every message is a plain JSON object. You choose the id field, and the core returns it unchanged. That lets you match responses to requests even when working in parallel.
Minimal sequence
Section titled “Minimal sequence”{"id":"ping-1","cmd":"ping"}{"id":"open-1","cmd":"open","path":"/absolute/input.docx","document_id":"my-document"}{"id":"model-1","cmd":"model"}{"id":"insert-1","cmd":"mutate","operation_kind":"insert-text","paragraph_index":0,"offset":0,"text":"Hello from the API. ","document_id":"my-document","transaction_order":1,"transition_kind":"api-insert"}{"id":"save-1","cmd":"save","path":"/absolute/output.docx"}{"id":"shutdown-1","cmd":"shutdown"}Required and recommended fields
Section titled “Required and recommended fields”| Field | Purpose | Rule |
|---|---|---|
id |
Request/response correlation | Optional. Any JSON value — a string, a number. Returned unchanged, so it should be unique among requests whose response hasn’t arrived yet |
cmd |
Session command name | One of the names listed in the supported_commands field of the greeting message |
path |
Input or output file | Absolute path only |
document_id |
Stable document identity | Pass it in open and in edits. It determines how strictly the order is checked — see the box below |
transaction_order |
Order of changes | Increases monotonically: 1, 2, 3… |
transition_kind |
Reason or transition type | A short diagnostic label |
operation_kind |
Semantic operation | Required for mutate. For example, insert-text |
paragraph_index |
The paragraph number the edit applies to | Required for mutate. Zero-based numbering |
offset |
The edit’s position within the paragraph | Optional, defaults to 0. Counted in characters, not bytes or UTF-16 units |
text |
The text to insert | Needed by every kind that inserts something. Without it, the insertion does nothing |
delete_count |
How many characters to delete | Optional, defaults to 0 — so a delete without this field successfully deletes nothing. Needed by delete-text and replace-text |
Response format
Section titled “Response format”Success:
{"id":"ping-1","ok":true,"cmd":"ping","elapsed_ms":0,"result":{"pong":true}}Refusal:
{"id":"bad-1","ok":false,"cmd":"mutate","elapsed_ms":0,"error":"..."}