Send Chat Message
Available for: Chatflow, Agent, Chatbot, Legacy Agent apps.
Sends a message to a chat app and returns the assistant’s reply. The events in the streaming response vary by app type.
1 min read
post/chat-messages
Request example
Response
post/chat-messages
Authorization
Body
application/jsonAuto-generate conversation title. If
false, use the Rename Conversation API with auto_generate: true for async title generation.Default: true
ID of the conversation to continue. Omit it or pass an empty string to start a new conversation; the response returns a
conversation_id to send with the next message. To resume an earlier conversation, get its ID from List Conversations.Files to attach to the message. For a local file, first upload it via Upload File, then reference the returned
id as upload_file_id with transfer_method: local_file. Agent apps accept file references but do not process their contents.Values for the app's input variables, keyed by variable name. The expected names and types come from the
user_input_form field of Get App Parameters.The user's message.
Mode of response return. Defaults to blocking when omitted.
streaming(recommended): the reply arrives as Server-Sent Events.blocking: returns once generation completes. Long generations risk interruption: on Dify Cloud, the edge proxy may end the connection if the response doesn't arrive within its timeout.- Legacy Agent and Agent apps support
streamingonly; ablockingrequest fails with 400.
Options:
streamingblockingEnd-user identifier, defined by your app and unique within it. Conversations, messages, and files are visible only to requests carrying the same
user. See End User Identity.Chatflow apps only. Specify a published workflow version ID to execute. If not provided, the latest published version is used. On Dify Cloud, pinning a version requires a paid plan.
Responses
Successful response. The content type and structure depend on the response_mode parameter in the request.
- If
response_modeisblocking, returnsapplication/jsonwith aChatCompletionResponseobject. - If
response_modeisstreaming, returnstext/event-streamwith a stream of Server-Sent Events.
Complete response content.
Conversation ID.
Message creation timestamp (Unix epoch seconds).
Event type, fixed as
message.Unique ID of this response event.
Unique message ID. Use this as the
message_id parameter when calling feedback or suggested questions endpoints.App mode.
chat for Chatbot apps, agent-chat for Legacy Agent apps, advanced-chat for Chatflow apps.Task ID for request tracking and stop response API.