Chat API Reference
Stream AI chatbot responses directly from your backend using Server-Sent Events (SSE).
Overview
Use the public Chat API when you want to call your Tellvira bot from your own backend, server-side workflow, or custom integration instead of embedding the browser widget.
Requests are server-to-server, do not require an Origin header, and reuse the same knowledge retrieval, conversation memory, and monthly plan quotas as the web widget.
Before you start
- Create an API key: Go to Account Settings > API keys to generate a secret key. API access is available on Starter and Pro plans.Open API keys
- Find your bot_id: Open Bots, select your bot, and open its Install tab to copy the bot's public ID.Open Bots
Authentication
Authenticate every request with a secret API key in the Authorization header using the Bearer scheme.
API keys use the format tv_live_ followed by 40 random characters (48 characters total). The full key is shown once at creation time in Account Settings > API keys. Up to 5 active keys are allowed per account.
Authorization: Bearer tv_live_your_api_key_hereBase URL
Send all Chat API requests over HTTPS to your Tellvira API origin:
https://api.tellvira.comEndpoint
Sends a visitor message to one of your active bots and streams the reply as Server-Sent Events.
/api/v1/public/chatHeaders
| Name | Required | Value | Description |
|---|---|---|---|
Authorization | Yes | Bearer tv_live_<40 chars> | Your secret API key. Requests with missing, revoked, or expired keys return 401. |
Content-Type | Yes | application/json | JSON request body media type. |
Accept | Recommended | text/event-stream | Indicates the client expects an SSE stream. Pre-stream auth or validation errors still return application/json. |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
bot_id | string | Yes | Public ULID of the target bot (max 64 chars). The bot must belong to the API key owner and be active. |
message | string | Yes | Visitor message text (trimmed, 1 to 500 characters by default). |
conversation_id | string (UUID) | null | No | Existing conversation UUID returned by a prior conversation event. Must belong to the same bot. Conversations expire after 24 hours of inactivity. |
Response
Successful requests return HTTP 200 with Content-Type: text/event-stream. Each event includes an event: name and a JSON-encoded data: line.
| Event | Payload fields | When sent |
|---|---|---|
conversation | conversationId: string (UUID) | Sent first on every stream. Store this ID after done arrives to continue the conversation. |
token | token: string | Sent zero or more times as the assistant generates text chunks. |
usage | used: number, limit: number, reached: boolean | Sent after the turn is saved; reports turns used vs the per-conversation turn limit (default 15 turns / 30 messages). |
lead_form | fields: Array<{ name: string, label: string, ... }> | Sent after usage when lead capture is enabled on the bot and the assistant triggers lead capture. |
done | {} (empty object) | Final event indicating the stream finished and messages and usage were committed. |
error | message: string | Sent if an internal error interrupts streaming after the 200 SSE response has started. |
Errors
Failures before streaming begins return standard JSON error envelopes with success: false, responseCode, message, errors, and an optional machine-readable code.
| HTTP status | code | Meaning | What to do |
|---|---|---|---|
401 | invalid_api_key | Missing, malformed, revoked, or expired API key. | Check the Bearer token or create a new API key in Account Settings. |
403 | account_suspended | The API key owner's account is suspended or inactive. | Contact support to restore account access. |
403 | plan_not_allowed | The owner's current plan does not include API access. | Upgrade to Starter or Pro in Billing. |
403 | bot_inactive | The requested bot is paused or inactive. | Set the bot status to Active in the dashboard. |
403 | — | Monthly plan quota for conversations, AI messages, or AI tokens is reached. | Wait for the next billing cycle or upgrade your plan. |
404 | bot_not_found | No bot with that bot_id exists for the API key owner. | Verify bot_id and ensure the API key belongs to the bot owner. |
404 | conversation_not_found | The supplied conversation_id belongs to a different bot. | Omit conversation_id to start fresh or pass one created for this bot. |
409 | — | Conversation reached the maximum message limit (30 messages by default). | Start a new conversation by omitting conversation_id. |
422 | — | Request body validation failed (field details are returned in errors). | Fix the invalid or missing fields listed in the errors object. |
429 | rate_limit_exceeded | Per-API-key or per-conversation rate limit exceeded. | Pause and retry after a short backoff. |
429 | — | Another message is currently streaming for the same conversation_id. | Wait for the in-flight stream to finish before sending the next turn. |
503 | — | Upstream AI provider or knowledge search is temporarily unavailable. | Retry with exponential backoff. |
Rate limits
| Scope | Limit | Notes |
|---|---|---|
| Per API key | 60 requests / minute (default) | Applies across all bots used with that key. |
| Per conversation | 10 requests / minute (default) | Applies when conversation_id is supplied. |
| Concurrent stream lock | 1 active turn per conversation | Concurrent requests to the same conversation_id return 429 until the active turn completes. |
| Message & session caps | 500 chars / message, 30 messages / conversation, 24h inactivity expiry | Each new or expired conversation counts once toward your monthly plan conversation quota. |
Examples
curl -N -X POST "https://api.tellvira.com/api/v1/public/chat" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"bot_id": "01J...",
"message": "Hello",
"conversation_id": null
}'Best practices
- Keep API keys on your server only—never ship tv_live_ keys in browser JavaScript, mobile app bundles, or public repositories.
- Save the conversationId from the conversation event only after you receive the done event, because messages and usage are committed when streaming completes.
- Disable client-side response buffering (for example pass -N in cURL) so tokens render incrementally.
- Use separate API keys per environment or integration so you can revoke one key without affecting others.
- Handle HTTP 429 and 503 responses with bounded exponential backoff rather than tight retry loops.