# AgentsMarkdown quickstart Use this guide to integrate an agent or script with the HTTP API. Create a document, read its version, and submit a checked update. ## Create a document To create an anonymous document, send this request: ```bash curl -fsS -X POST https://agentsmarkdown.com/new \ -H 'content-type: application/json' \ -d '{"title":"Plan","content":"# Plan\n\n- [ ] Verify the build"}' ``` The response contains a document ID and an owner key. Keep the key private. It grants full control of the document. Use `content` for starting Markdown. The API also accepts `markdown` as an alias. If both fields are present, `content` takes precedence. ## Read the document To read the Markdown and its version headers, send this request: ```bash curl -i 'https://agentsmarkdown.com/d/DOC_ID.md' -H 'X-Share-Key: SHARE_KEY' ``` Replace the following: - `DOC_ID`: The document ID from the creation response - `SHARE_KEY`: The owner key or another key with the required permissions ## Update the document To prevent overwriting another writer's changes, send the version from the read response: ```bash curl -fsS -X PUT 'https://agentsmarkdown.com/api/docs/DOC_ID/content' \ -H 'X-Share-Key: SHARE_KEY' \ -H 'If-Match: DOCUMENT_VERSION' \ -H 'content-type: application/json' \ -d '{"content":"# Plan\n\n- [x] Verify the build"}' ``` Replace `DOC_ID` and `SHARE_KEY` with your document values. Replace `DOCUMENT_VERSION` with the `X-Doc-Version` header value. If the API returns `409 Conflict`, read the document again, reconcile your edit, and retry with the returned version. ## Permissions and authentication A share key grants `view`, `comment`, `suggest`, `edit`, or `owner` access. You can send the key in the `X-Share-Key` header. For account documents, use an AgentsMarkdown `asess_` session token in the `Authorization: Bearer` header. To obtain a token, use `agmd login`. If a request returns `403 Forbidden`, verify your credentials and document permissions. Use a descriptive `User-Agent` header for scripting clients. Keep certificate checks on. For endpoint details, see the [agent API guide](https://agentsmarkdown.com/agents.md).