API referenceTutorialsmarkdownbrain.ai

Create comment thread

create_thread

ThroughForm
HTTPPOST https://api.markdownbrain.ai/v1/threads
MCPtool create_thread
CLImdbrain call create_thread

Start a comment thread anchored to a text range of a file, with a first comment. Name the file with path or with file_id — exactly one of the two. The quote IS the address: give the exact text the comment is about and the server finds it. No character offsets — nothing you hold tells you one, and counting them means re-reading the file. If the quote appears more than once the call is refused, listing each occurrence with its surrounding text, so you can retry with a longer quote (or with prefix/suffix) in one round trip.

Who may call it: agents and people.

Writes: yes.

Arguments

NameTypeRequiredTravels inDescription
file_idstringnoJSON bodyfile_node id of the file to comment on — or use path
pathstringnoJSON bodyWorkspace-relative path of the file to comment on
workspace_idstringnoJSON bodyOnly needed to disambiguate a path that exists in more than one workspace you can see
quotestringyesJSON bodyThe exact source text the comment anchors to. Make it long enough to occur once
prefixstringnoJSON bodySource immediately BEFORE the quote — only needed to say which occurrence you mean
suffixstringnoJSON bodySource immediately AFTER the quote — only needed to say which occurrence you mean
bodystringyesJSON bodyThe first comment's markdown body

Success

201 with application/json.

Example request

curl -X POST https://api.markdownbrain.ai/v1/threads \
  -H "Authorization: Bearer $MDBRAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path":"specs/12-onboarding.md","workspace_id":"00000000-0000-4000-8000-000000000010","quote":"Each invitation expires after seven days.","body":"Should an expired invitation tell the person who sent it?"}'
mdbrain call create_thread \
  --path specs/12-onboarding.md \
  --workspace-id 00000000-0000-4000-8000-000000000010 \
  --quote 'Each invitation expires after seven days.' \
  --body 'Should an expired invitation tell the person who sent it?'

Example response

Written from the code rather than captured from a call.

{
  "thread_id": "00000000-0000-4000-8000-000000000201",
  "file_id": "00000000-0000-4000-8000-000000000102"
}

Refusals

A refusal is a status code with { error: { code, message } }. See Errors.