Send a message in a conversation
const url = 'https://api.siteassist.io/v2/conversations/123e4567-e89b-12d3-a456-426614174000/messages';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"content":"Hello! Can you help me understand how to use this feature?","stream":false,"pageContext":{"url":"https://example.com/help","title":"Help Center - Getting Started","content":"Welcome to our help center. Here you can find answers to common questions..."}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.siteassist.io/v2/conversations/123e4567-e89b-12d3-a456-426614174000/messages \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "content": "Hello! Can you help me understand how to use this feature?", "stream": false, "pageContext": { "url": "https://example.com/help", "title": "Help Center - Getting Started", "content": "Welcome to our help center. Here you can find answers to common questions..." } }'Send a message to an AI assistant in a conversation. Supports both streaming and non-streaming responses. Rate limiting and usage quotas are enforced per project.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The unique identifier of the conversation to send the message to
Example
123e4567-e89b-12d3-a456-426614174000Request Body
Section titled “Request Body”Request body for sending a message to an AI assistant in a conversation
object
If set to true, the model response data will be streamed to the client as it is generated using server-sent events. When streaming is enabled, the response will be sent as text/event-stream with incremental updates. When disabled, the complete response will be returned as application/json.
Example
falseThe message content to send to the assistant. This is the user’s input that will be processed by the AI.
Example
Hello! Can you help me understand how to use this feature?Optional context information about the user’s current page and interaction. This helps the assistant provide more relevant responses.
object
The URL of the page where the message was sent from. Used to provide context to the assistant about the user’s current location.
Example
https://example.com/helpThe title of the page where the message was sent from. Provides additional context about the user’s current page.
Example
Help Center - Getting StartedThe content of the page where the message was sent from. Can be used to provide the assistant with relevant page information.
Example
Welcome to our help center. Here you can find answers to common questions...Any text that was selected by the user on the page before sending the message. This can provide specific context about what the user is asking about.
Example
How do I reset my password?Example
{ "content": "Hello! Can you help me understand how to use this feature?", "stream": false, "pageContext": { "url": "https://example.com/help", "title": "Help Center - Getting Started", "content": "Welcome to our help center. Here you can find answers to common questions..." }}Responses
Section titled “Responses”Successfully processed the message and generated a response from the AI assistant
Server-sent events stream containing incremental updates of the AI assistant’s response. Each event contains a JSON object with type and relevant data. The stream includes start/end markers, text deltas, and completion information.
Example
data: {"type":"start"}
data: {"type":"start-step"}
data: {"type":"text-start","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","providerMetadata":{"openai":{"itemId":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18"}}}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"Hello! "}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"How "}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"can "}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"I "}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"assist "}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"you "}
data: {"type":"text-delta","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18","delta":"today?"}
data: {"type":"text-end","id":"msg_68c276dd2b3481a2bb6da153039cf9cd093857e78e8e8f18"}
data: {"type":"finish-step"}
data: {"type":"finish"}
data: [DONE]Complete response from the AI assistant when streaming is disabled. Contains the full response content, finish reason, and token usage statistics.
object
Array of steps that make up the complete AI response
A single step in the AI response generation process
object
Array of content blocks in the response. Each block contains the generated content with its type and data.
object
The reason why the model stopped generating content. Common values include ‘stop’, ‘length’, ‘content_filter’, etc.
Token usage statistics for this response
object
Number of tokens in the input prompt
Number of tokens in the generated response
Total number of tokens used (input + output)
Number of tokens used for reasoning (for models that support it)
Number of input tokens that were cached and reused
Example
{ "steps": [ { "content": [ { "type": "text", "text": "Hello! How can I assist you today?" } ], "finishReason": "stop", "usage": { "inputTokens": 2409, "outputTokens": 11, "totalTokens": 2420, "reasoningTokens": 0, "cachedInputTokens": 0 } } ]}Message successfully received and queued for human agent handling. This response is returned when the conversation is marked for human intervention rather than AI processing.
Simple text confirmation that the message was received and queued for human agent handling
Example
Message sentBad Request - The request body or parameters are invalid
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Invalid request body. Content is required.", "code": "INVALID_REQUEST_BODY", "details": { "field": "content" } }}Unauthorized - Authentication token is missing or invalid
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Authentication required", "code": "UNAUTHORIZED" }}Payment Required - A higher pricing plan is required to access the resource
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "A higher pricing plan is required to access this feature", "code": "PAYMENT_REQUIRED", "details": { "currentPlan": "free", "requiredPlan": "pro", "feature": "advanced_ai_models" } }}Forbidden - Access denied to the requested resource
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Access denied to this conversation", "code": "FORBIDDEN" }}Not Found - The requested resource was not found
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Conversation not found!", "code": "CONVERSATION_NOT_FOUND", "details": { "conversationId": "123e4567-e89b-12d3-a456-426614174000" } }}Conflict - The request could not be completed due to a conflict
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Resource already exists", "code": "CONFLICT", "details": { "resource": "conversation", "conflictingField": "id" } }}Unprocessable Entity - The request was well-formed but contains semantic errors
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Validation failed", "code": "VALIDATION_ERROR", "details": { "field": "content", "reason": "Content exceeds maximum length of 10000 characters" } }}Too Many Requests - Rate limit exceeded or quota reached
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Rate limit exceeded. Please try again later.", "code": "RATE_LIMIT_EXCEEDED", "details": { "retryAfter": 60 } }}Internal Server Error - An unexpected error occurred
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "An internal server error occurred", "code": "INTERNAL_SERVER_ERROR" }}Bad Gateway - The server received an invalid response from an upstream server
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Service temporarily unavailable", "code": "BAD_GATEWAY", "details": { "service": "ai_model_service" } }}Service Unavailable - The server is temporarily unable to handle the request
object
object
Human-readable error message describing what went wrong
Machine-readable error code for programmatic handling
Additional error details and context
object
Example
{ "error": { "message": "Service temporarily unavailable", "code": "SERVICE_UNAVAILABLE", "details": { "retryAfter": 30 } }}