chat

Send Chat Message

Changed on

Send a message to a chat started through the API. Returns at once with the turn to poll. A message sent while a turn is still working joins that turn (joined: true): Chat takes it into the work in progress, and the turn's reply and charge cover both messages.

When a turn ends with stop_reason needs_input, Chat waits on the questions in its reply.questions: send answers (by question index and option label), a message that answers them in words, or both. The answer starts the next turn (answered: true).

Returns 402 when the balance is below 3 credits for this message and for each turn still running, 409 for a chat started in the app.

post/v1/chat/{chat_id}/messages

Request

  • Base URL
    https://api.happenstance.ai (the document declares no server; this is the origin it was published from)
  • Auth
    HTTP bearer

Path parameters

chat_idstring required

Request body

messagestring nullable

The message to send, in plain text. While Chat waits on its questions (a turn with stop_reason needs_input), a message answers them in words.

Response

Successful Response

chat_idstring required

The chat's id

urlstring required

The chat in the Happenstance app

turn_idstring required

The turn to poll: the one this message started, or the running turn it joined

status'queued' | 'running' | 'completed' | 'failed' | 'cancelled' required

The turn's status

joinedboolean

True when the message joined the turn that was still running: Chat takes it into that turn's work, and the turn's reply and charge cover both messages

answeredboolean

True when the message or answers answered Chat's open questions

warningstring nullable

Warning message when credit balance is low

Changes