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
| Name | Required | Description |
|---|---|---|
X-API-Key | Yes | Your unique API Key provided by ZeroinAI |
Content-Type | Yes | Must be set to application/json |
Request Body
{
"chat_id": "generated-unique-chat-id",
"content": "Hello, I need help with my subscription."
}
| Field | Type | Required | Description |
|---|---|---|---|
chat_id | string | Yes | The ID of the chat session |
content | string | Yes | The 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 Code | Description |
|---|---|
| 400 Bad Request | chat_id is missing |
| 401 Unauthorized | Invalid or missing API Key |
| 402 Payment Required | Not enough tokens remaining in the chat session |
| 404 Not Found | chat_id not found, or the chat config linked to the API key is not found |
| 422 Unprocessable Entity | If 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."
}'