OpenAI is partnering with Hacktron to find vulnerabilities in its systems. Read the announcement.

Skip to content Hacktron Sign in [S]
Hacktron Sign in [S] Customers Docs Contact Sign in

Edit a context document

1 min
, View, ChatGPT, Claude, Perplexity, OpenAPI

Copy page

Edit a context document

View MarkdownOpen in ChatGPTOpen in ClaudeOpen in PerplexityDownload OpenAPI

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 edits replaces its old_text with new_text, in order. old_text must appear exactly once in the document as GET /context-documents/{id} returns it.
  • append adds 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

ParameterDescription
id
string, required

Body

A required application/json body.

FieldDescription
edits
array of object
Replacements, applied in order.
edits[].old_text
string, required
Text to replace; it must appear exactly once in the document.
edits[].new_text
string, required
Replacement text; empty deletes old_text.
append
string
Markdown to add at the end of the document.

Responses

200 OK

FieldDescription
id
string (uuid), required
name
string, required
kind
string, required
One of threat_model, application_threat_model, or document.
updated_at
string (date-time), required
readable
boolean, 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.

[↓] [↑] [enter] to visit
Menu
[M]
Next in menu
[J]
Previous in menu
[K]
Find
[F]
Ask
[A]
Sign in
[S]
Copy page
[C]
Listen
[L]
Justification
[R]
Language
[G]
Dark mode
[D]
High contrast
[H]
Shortcuts
[I]
Close
[Esc]