# Write documents on objects

AI agent getting started? Read [Agents: start here](https://docs.openeng.io/agents/start-here.md) first.

Edit and promote an object's body, whether Markdown or code, and comment on passages.

Source: https://docs.openeng.io/guides/documents/

An object’s body holds its longer document, written in Markdown or in code. Edit the draft, check what changed, then promote it to make it the body's current text.

## Prepare an object for a document

A body is long-form content attached to an object, separate from its properties. Use it for a specification or report that should branch with the record. A draft saves your editing work; promotion applies that draft to the object's body on the selected branch.

The published object type declares `bodyFormats`, a list of one or more formats from `markdown`, `python`,
`json`, `yaml`, `typescript`, `javascript`, `plaintext`, `modelica`, `sysml` and `starlark`.
A later version may add formats but never drop one.

A body is made of blocks, and every block has a kind, which is one of those formats. A block's kind must be one the type's `bodyFormats` lists, and all blocks of a body share one kind. A Markdown body may hold many blocks. A body in any other format is one block of one kind. A save that breaks these rules is refused `body-wrong-format`: a block's kind is outside the type's `bodyFormats`, kinds are mixed, or a non-Markdown body has more than one block.
Add that field through [a type change set](https://docs.openeng.io/configure/types.md), validate and publish it, then create an object using
the new definition. The turbine demo does not include document bodies.

## Edit and promote a body

1. Open the object details panel. The tabs are **Properties**, **Subscribers**, **Comments** and **History**. **Body** appears only when the type declares a body.
2. Edit the text in the body editor; a code body opens in a code editor. The draft saves automatically; wait for **Draft saved at** before promoting it.
3. Choose **Promote draft** (apply the saved document draft to this branch). In the **Reason for this change** field, write a commit-message reason (see [Propose, compare and merge](https://docs.openeng.io/guides/change-control.md#develop-the-change)), then choose **Promote**. The latest edit is saved before promotion. On success, the page says **Draft promoted. This is now the object's body.** If the draft already matched, nothing changes.

### When editing is blocked

If another person holds the draft lock, the body stays read-only and shows who is editing and when the lock expires. Wait for them to finish. A project administrator can choose **Break lock**, which ends their editing; any unsaved text stays with them and is not merged.

1. If your lock expires while you edit, editing stops and your text stays on screen.
2. Choose **Reacquire lock** to continue.
3. If the draft changed while you did not hold the lock, copy your text before reloading; the page keeps your text locally.

If the body's text changed after you opened the draft, promotion stops. The comparison shows your draft beside the current body, block by block, without overwriting either.

1. Use **Copy draft text** if you need to keep your text.
2. Close the comparison.
3. Decide what to carry into a fresh draft.

See [refusals](https://docs.openeng.io/reference/refusals.md) for platform rejection reasons and guidance.

### Check a code body

`readObject` answers `bodyCheck` exactly when the body holds a block of Python, JavaScript, TypeScript, JSON or YAML. It is `runnable`, or `not-runnable` with a reason (`no-script`, `wrong-format`, `block-count` or `syntax-error`) and the line and column of up to 20 syntax errors. A syntax error does not stop you saving or promoting a draft. Markdown, plain text, Modelica, SysML and Starlark bodies are not checked, and `bodyCheck` is absent for them.

## Try a short specification

On a working branch, open an object prepared for a Markdown body. Write a heading and one requirement paragraph, wait for the saved-draft indicator, then promote it. Reopen the object on that branch and confirm the paragraph is present. Main stays unchanged until the branch is merged.

## Review a body change

Submit the branch for review when the body is ready. In the branch comparison, body changes appear by block with **Added**, **Removed**, **Changed** or **Moved**, and the text before and after. A moved block keeps its text; the comparison shows it once. The history view also records body changes. When either side of a changed block is not Markdown, each entry also carries its changes line by line, each line `same`, `added` or `removed`. The same holds for a merge conflict: a body block carries `oursLines` (base to ours) and `theirsLines` (base to theirs). A merge still works block by block.

## Comment on a passage

1. In the read-only body, select text that appears once in a single block. The comment composer quotes the selected passage.
2. Write the comment and choose **Send**. The comment is attached to that passage; its annotation appears beside the body block.

A selection that crosses blocks, appears more than once, or includes formatting such as bold, code or a link cannot anchor a passage. Select a unique plain text span in one block instead. Comments whose passage was changed or deleted appear as flagged or orphaned annotations.

## Discard a draft

1. Copy any text you want to keep. Discarding deletes the draft without sending it to trash.
2. Choose **Discard draft**.
3. Read the warning: discarding throws away the draft and releases the lock without changing the object's body.
4. Confirm **Discard the draft**.

A draft on a deleted branch is retained in draft storage for the people who saved it. The platform has no way yet to list that trash, so a person cannot restore such a draft themselves.

## For agents

Use `openeng help objects-sdk <method>` for each request shape. Draft methods include `acquireDraft`, `saveDraft`, `promoteDraft`, `releaseDraft`, `discardDraft`, `readDraftLock` and `breakDraftLock`. They use the selected project and branch with an `objectId`; saves also send the last `draftHash`. A save renews the five-minute lock. `promoteDraft` also sends a `reason` that says why the body is published; the platform writes it first in the commit message.

The CLI skill's **Draft and comment routes** section covers those calls, body changes in object history and branch comparisons, restore permissions, and anchored comments. Read [CLI reference](https://docs.openeng.io/reference/cli.md) for command syntax. A type's object view must use `ObjectBody` as its root; a body declaration in `bodyFormats` separately makes the drawer's **Body** tab available. Each block is `{ kind, text, position }`; pick the kind from the type's `bodyFormats`.
