Skip to main content

Create Chat

Creates a new chat session. A chat_id is generated and returned, which is required for adding messages and other chat-specific operations.

Endpoint

POST /chats/

Headers

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

Request Body

{
"token_limit": 1000.0
}
FieldTypeRequiredDescription
token_limitfloatYesThe maximum number of tokens this chat session can consume

Response

Success Response (200 OK)

{
"chat_id": "generated-unique-chat-id",
"created_at": "2023-10-28T14:30:00Z",
"agent_name": "Support Pro Agent",
"creator_company_name": "Your Company Inc.",
"token_limit": 1000.0,
"token_used": 0.0,
"deleted": false,
"messages": []
}

Error Responses

Status CodeDescription
401 UnauthorizedInvalid or missing API Key
404 Not FoundChat configuration associated with the API Key not found
422 Unprocessable EntityIf token_limit is missing or invalid

Example Request

curl -X POST 'https://api.zeroinai.com/micro-apps/for-api-providers/chat-service/chats/' \
-H 'X-API-Key: YOUR_UNIQUE_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"token_limit": 1000.0
}'