# Write a private draft

Create a guide from Markdown, open it in Studio and edit the same revision from either place.

## Create a private draft

Grant `drafts:write` and `drafts:read`. Ask your connected client to create the guide.

> Create a private DevGuides draft titled “Keyboard focus basics.” Include a “Keyboard checks” heading and a checklist item for testing the Tab key. Give me its Studio link, ID and revision.

The client calls `create_draft`, generates a UUID for `idempotencyKey` and saves the title and `bodyMarkdown`. It receives `id`, `revision` and `editUrl`. Opening the Studio link lets you edit the same private draft. For a retry after a lost response, reuse the same creation key and identical fields.

## Choose the guide fields

| Field | How to use it |
| --- | --- |
| `title` | A required title, up to 160 characters. |
| `bodyMarkdown` | The body alone, up to 150,000 characters. Store headings, lists, fenced code, tables and media here. |
| `topics` | Up to eight distinct topics after normalization. Topic slugs contain lowercase letters, digits and hyphens, with a maximum of 32 characters each. |
| `summary` | Supply up to 400 characters for a custom summary. An empty string restores the generated excerpt. |
| `slug` | An optional permalink segment of up to 160 characters. Use lowercase letters or digits with single hyphens between words. |
| `banner` | Use the author-owned image path returned by [finishing an upload](https://www.devguides.com/docs/media). |
| `aiAssisted` | Ask the author before setting this optional label. Set it to true if the author wants readers to see “AI-assisted.” |

Store the title and topics in their fields. Studio’s Markdown download adds a title, topics and optional banner around the stored body. Passing the whole export as `bodyMarkdown` would duplicate that metadata.

## Edit the reviewed version

Ask the agent to read the draft using `read_draft`, then to apply a change.

> Append a “Browser check” section that says “Test in two browsers.” Keep my earlier checklist. Save it and show me the new Markdown and revision.

Pass the read result’s `revision` as `expectedRevision` to `update_draft`. Omitted fields retain their values. A supplied `bodyMarkdown` replaces the entire body, so include the original Markdown you intend to keep. Read the saved draft again and refresh its Studio tab to see the change.

## Recover from a conflict

When Studio or another client saves first, the stale write returns `conflict`. Keep your proposed Markdown, read the latest draft and compare the two versions. Apply the agreed changes to the newer body and send its revision with the next write. Follow the [publishing workflow](https://www.devguides.com/docs/publishing) when the author approves the result.
