Skip to main content

Add Message to Chat

Adds a user's message to an existing chat session and triggers an AI response. The API will automatically save both the user's message and the subsequent AI response.

Endpoint

POST /chats/messages/

Headers

NameRequiredDescription
X-API-KeyYesYour unique API Key provided by ZeroinAI
Content-TypeYesMust be set to application/json

Request Body

{
"chat_id": "generated-unique-chat-id",
"content": "Hello, I need help with my subscription."
}
FieldTypeRequiredDescription
chat_idstringYesThe ID of the chat session
contentstringYesThe user's message content

Response

Success Response (200 OK)

{
"chat_id": "generated-unique-chat-id",
"is_user": false,
"content": "Hello! I can certainly help with your subscription. Could you please provide your account email?",
"timestamp": "2023-10-28T14:32:05Z"
}

Error Responses

Status CodeDescription
400 Bad Requestchat_id is missing
401 UnauthorizedInvalid or missing API Key
402 Payment RequiredNot enough tokens remaining in the chat session
404 Not Foundchat_id not found, or the chat config linked to the API key is not found
422 Unprocessable EntityIf content is missing or invalid

Example Request

curl -X POST 'https://api.zeroinai.com/micro-apps/for-api-providers/chat-service/chats/messages/' \
-H 'X-API-Key: YOUR_UNIQUE_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"chat_id": "generated-unique-chat-id",
"content": "Hello, I need help with my subscription."
}'