Skip to main content

Overview

The synchronous chat endpoint sends a message to the AI assistant and waits for a complete response. Use this endpoint when your integration needs an immediate answer and can tolerate request latency up to 60 seconds.

When to use sync chat

  • The caller (application or user) is waiting for the answer
  • Request volume is moderate (M2M endpoints are rate limited to 5 req/sec per client IP)
  • Your integration can handle response latency of 5-60 seconds
  • You want the simplest integration pattern
For high-volume or background workloads, consider async chat.

Authentication

This endpoint requires an API key in the X-API-Key header:
The API key must belong to a tenant that owns the specified site. If the key is expired, revoked, or from a different tenant, the request fails with 401 or 403.

Request body

string
required
The user’s question or statement. Required.
string
A stable identifier for the conversation. If omitted, a new session is created. For follow-up questions, include the same session_id to maintain context.Format: typically a UUID or stable string unique to the user/channel.Example: user-123-web, conversation-abc-def, or a UUID.
string
The user’s email address. Required when creating a new session (no session_id provided). Optional for follow-up messages in an existing session.The email is used to associate chat history with a user account.
string
The AI model to use for this request. If omitted, defaults to the site’s configured default model or gpt-4o-mini.Common values: gpt-4o-mini, gpt-4-turbo, claude-3-5-sonnet-20241022.Check available models for your tenant.
string
Language for the assistant’s response. If omitted, the assistant chooses based on the input message.Example values: en, tr, es, fr, de.
string
Locale code for the UI context (used for formatting, not response language).Example: en-US, tr-TR.

Request example

Response schema

string
The session identifier for this conversation. Use this in follow-up requests to maintain context.
string
A unique identifier for this chat request. Use it to reference this specific Q&A pair when submitting feedback or checking logs.
string
The assistant’s response to the user’s message.
integer
A score from 0-100 indicating confidence in the answer (higher is more confident). Omitted if not available.
string
Enum: low, medium, high. Summarizes the confidence score. Omitted if not available.
string
Human-readable explanation of the confidence level (e.g., “Based on multiple supporting documents”). Omitted if not available.

Response example

Error responses

400 Bad Request

Missing or invalid fields in the request body.
Common causes:
  • Missing message field
  • Invalid JSON structure
  • Missing email for a new session (no session_id provided)

401 Unauthorized

API key is missing, invalid, expired, or revoked.
Common causes:
  • Malformed or missing X-API-Key header
  • Key has been revoked
  • Key has expired
  • Key belongs to a different tenant

403 Forbidden

The API key’s plan does not include M2M API access.

404 Not Found

The site does not exist or does not belong to the authenticated tenant.
Common causes:
  • Wrong site ID in the path
  • Site has been deleted
  • Site belongs to a different tenant

429 Too Many Requests

Rate limit exceeded. M2M endpoints allow up to 5 requests per second (rate limiting is applied per client IP and request path). When this limit is exceeded, requests are rejected until the window resets — wait at least one second before retrying.
Implement exponential backoff (e.g., 1s, 2s, 4s, 8s).

500 Internal Server Error

An unexpected error occurred on the Uppzy side.
Rare, but can happen if:
  • The RAG service is temporarily unavailable
  • The LLM provider is unreachable
  • An internal service dependency failed
Implement bounded retries with backoff.

Implementation tips

Session strategy

Choose a stable session_id that groups related messages:
  • Per user: user-123 keeps all conversations for that user together
  • Per channel: slack-channel-abc for messaging integrations
  • Per thread: support-ticket-456 for support systems
Consistency matters: the same user should use the same session ID across requests.

Handling confidence

Check confidence_level or confidence_score to decide whether to:
  • Show the answer directly to users
  • Flag low-confidence answers with “This answer may be incomplete”
  • Route high-uncertainty cases to a human agent

Timeout handling

The endpoint has a 60-second ceiling. In practice:
  • Simple answers return in 1-5 seconds
  • Complex queries or cold LLM starts may take 10-30 seconds
  • Embeddings generation or very large RAG sets can exceed 30 seconds
If your HTTP client times out before the endpoint completes, the request may still process on the server. Use the request_id to poll the async status endpoint if needed.

Retry strategy

Implement exponential backoff for transient failures: