Sessions

Send a message

POST https://api.129.212.147.181.sslip.io/v1/sessions/{session}/messages

One turn of the conversation, in any phase. Send what the user typed as text, or answer pending_question with a typed answer (from a widget). Answering an earlier question again changes that answer.

Returns the turn: the user's message, the assistant's reply (its question is what to ask next, or null) and the session after both. If the model fails, reply.status is failed with an error; the session is unchanged and you can send the message again.

Path parameters

session string required

Headers

Authorization string required
Bearer dg_test_… or Bearer dg_live_…
Docgen-Subject string optional
Your reference for the end user (a user ID, a hash; never an email). A session is bound to the subject it was created with, and every call on it must send the same value or it is 404. Set it from your own login, never from what the browser sent. Required to create and list sessions unless your organisation has subjects turned off.
Idempotency-Key string optional
Retrying with the same key and body returns the original response. Kept 24 hours.

Body

text string
What the user typed.
answer Answer object
answers array of Answer objects
Several answers at once, usually every question of pending_step. All are checked first: one bad answer rejects the message and nothing is saved. Send answer or answers, not both.

Returns

200 OK: a Turn object. The turn.

Errors

StatusCodeWhat to do
422parameter_missingSend text, answer, or both.
422question_invalidAnswer pending_question.id, or a question already answered.
422answer_invaliderror.fields says what the question expects; for a form question, one of its option values.
409turn_in_progressAnother message to this session is being handled. Retry when it returns.
409session_closedThe session was closed and takes no more messages. Start a new one.
404session_not_foundCheck the ID, and that Docgen-Subject is the subject the session was created for.
410session_deletedThe session was deleted with its conversation and answers. Start a new one.
503provider_unavailableThis turn needs a model; live keys get this until one is configured.

Any endpoint can also return the common errors (bad key, rate limit, idempotency).