Edit a context document
Edits a threat model or a Markdown or text context document in place, as the editor in Hacktron does. Send edits, append, or both. You need the member role or above.
- Each of up to 20
editsreplaces itsold_textwithnew_text, in order.old_textmust appear exactly once in the document asGET /context-documents/{id}returns it. appendadds Markdown at the end of the document, after a blank line.- Edits to a threat model are kept as your team’s own, so later syncs leave those lines alone.
A request whose edits change nothing returns 400 Bad Request, and so does a document over 2 MB, which you edit in Hacktron instead. If the document changes while the edit is applied, for example by a threat model sync, the API returns 409 Conflict. Read the document again and redo the edit.
Request
POST /context-documents/{id}/edit
Send an API key with the write scope in the X-Api-Key header.
Path parameters
| Parameter | Description |
|---|---|
idstring, required |
Body
A required application/json body.
| Field | Description |
|---|---|
editsarray of object | Replacements, applied in order. |
edits[].string, required | Text to replace; it must appear exactly once in the document. |
edits[].string, required | Replacement text; empty deletes old_text. |
appendstring | Markdown to add at the end of the document. |
Responses
200 OK
| Field | Description |
|---|---|
idstring (uuid), required | |
namestring, required | |
kindstring, required | One of threat_model, application_threat_model, or document. |
updated_atstring (date-time), required | |
readableboolean, required | Whether the content is text this API returns; PDFs open in Hacktron. |
400 Bad Request
A replacement’s text isn’t in the document exactly once, the edits change nothing, or the document isn’t text.
409 Conflict
The document changed while the edit was applied, such as by a threat model sync; read it again and redo the edit.