Send a message to the assistant
POST
/api/drafts/{id}/messages
const url = 'https://forge.example.com/api/drafts/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/messages';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"text":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://forge.example.com/api/drafts/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/messages \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "text": "example" }'The answer streams back as text/event-stream. Refusals before the stream starts are problem documents: 403 when the classification is off for AI, 409 when the assistant is not set up or a turn is already running, 429 when the month’s allowance is used up. To stop a turn, close the request.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”id
required
string format: uuid
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
text
required
string
Example generated
{ "text": "example"}Responses
Section titled “Responses”The assistant’s answer as it is written, as server-sent events: text for its words, activity when it checks or changes the model, draft when the draft changes, tier when the draft moves to the Deep tier, then done; or error when the turn cannot finish, keeping what was written so far.
Media typetext/event-stream
string
default
Section titled “default”A refusal or an error, as a problem document. A model or draft you may not see answers 404, as one that does not exist.
Media typeapplication/problem+json
object
type
string
title
string
status
integer
detail
string
instance
string
Example generated
{ "type": "example", "title": "example", "status": 1, "detail": "example", "instance": "example"}