Upload conversations
To upload conversations to our platform, you have two options:
- Manually upload the conversations.
- Set up an automated process that streams the conversations into the system at regular intervals, based on your preference.
Before the first upload:
- PII scrubbing is off for a new account. To remove personal information from real users' chats, turn it on first; it does not change conversations already stored, and it does not apply to the upload API. See PII scrubbing.
- Validators are off for a new account, so uploaded conversations get no alerts until you turn validators on. See Validators.
Manually upload the conversations
To manually upload conversations, use the button located at the top of the Conversation Analysis page.

After clicking the button, you can manually upload a conversation in two ways:
- Paste the conversation text in JSON format.
- Upload a JSON file from your computer.

The conversation must be uploaded in JSON or JSONL format. A specific format is provided, which you can adapt your conversations to before uploading.
A sample JSON format for adapting your conversations will be provided on the next page.
After uploading the file or pasting your conversation in JSON format, you can click the Validate button to preview how the conversation will appear before submitting it to the system.

The JSON uploaded in the image above contains a single conversation with three messages. You can review the message content, any logs (if available – simply hover over the message), and additional related data.
After reviewing the messages, you can click Upload to submit the conversation to the system. Once uploaded, the conversation will appear on the Conversation Analysis page, where models will evaluate its quality and check for any alerts that will determine its score


Important tip: Make sure the conversation format is linked to the agent who conducted the conversation.
Automated process to upload conversations
📋 Prerequisites
Before you start, you'll need:
- ✅ An API Key (you create it yourself on the API Keys page)
- ✅ Your conversations data in the correct format
- ✅ A tool to make HTTP requests (curl, Postman, or your programming language)
🔑 Your API Key
Create your API key on the API Keys page: click the three dots next to your email at the bottom of the sidebar, then select API Keys. The key is shown only once. It looks like this:
avk_f623d99c542ab07d9545XXXX
Important: Keep your API key secure! Don't share it publicly or commit it to version control.
🎯 Quick Start: Send Your First Conversation
Step 1: Create a Conversation
Every conversation starts with creating a conversation record:
curl -X POST https://app.avon-ai.com/api/conversations \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY_HERE" \
-d '{
"conversation_id": "conv_001",
"agent": "support_bot_01",
"timestamp": "2024-01-15T10:30:00Z",
"is_resolved": false,
"csat_score": 4.5
}'
Response:
{
"conversation_id": "conv_001",
"agent": "support_bot_01",
"timestamp": "2024-01-15T10:30:00Z",
"is_resolved": false,
"csat_score": 4.5,
"created_at": "2024-01-15T10:30:05Z",
"status": "success"
}
⚠️ Step 2 is required.
POST /conversationscreates the conversation record only, without any messages. If you stop after Step 1, the conversation appears in AvonAI with no messages and nothing to analyze. Messages can only be added withPOST /messages. The manual-upload JSON format with an inlinemessagesarray is not accepted by this API: unknown fields inPOST /conversationsare ignored.
Step 2: Add Messages to the Conversation
Now add the messages (customer questions, agent responses) to your conversation:
# Customer's first message
curl -X POST https://app.avon-ai.com/api/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY_HERE" \
-d '{
"message_id": "msg_001",
"conversation_id": "conv_001",
"role": "customer",
"sender_id": "customer_123",
"content": "Hello, I need help with my order",
"timestamp": "2024-01-15T10:31:00Z"
}'
# Agent's response
curl -X POST https://app.avon-ai.com/api/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY_HERE" \
-d '{
"message_id": "msg_002",
"conversation_id": "conv_001",
"role": "agent",
"sender_id": "agent_001",
"content": "I will be happy to help! Can you provide your order number?",
"timestamp": "2024-01-15T10:31:30Z"
}'
# Customer's follow-up
curl -X POST https://app.avon-ai.com/api/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY_HERE" \
-d '{
"message_id": "msg_003",
"conversation_id": "conv_001",
"role": "customer",
"sender_id": "customer_123",
"content": "Sure, my order number is ORD-12345",
"timestamp": "2024-01-15T10:32:00Z"
}'
That's it! Your conversation with 3 messages is now in AvonAI! 🎉
When Validation Results Appear
AvonAI waits until a conversation has been idle for 30 minutes before it validates it. The 30 minutes start when AvonAI receives the last POST /conversations or POST /messages request for that conversation, and every new message starts them again. Validation results appear within 60 minutes after the last message arrives, including the 30-minute wait.
If you add messages to a conversation that was already validated, it is validated again 30 minutes after the new messages.
Conversations you upload manually on the Conversation Analysis page skip the 30-minute wait and are validated right away.
Only the validators enabled at that time run. Every validator is off for a new account.
PII scrubbing does not apply to this API. Conversations and messages sent with
POST /conversationsandPOST /messagesare stored as sent, even when PII scrubbing is on. Remove personal information before you send them, or use a method that scrubs (manual upload, S3 or Azure Blob, BigQuery).
📖 API Reference
Base URL
https://app.avon-ai.com/api
Authentication
All requests require your API key in the header:
X-API-Key: YOUR_API_KEY_HERE
Create Conversation
Endpoint: POST /conversations
Required Fields:
| Field | Type | Description | Example |
|---|---|---|---|
conversation_id | string | Unique conversation ID | "conv_001" |
agent | string | Agent/bot identifier | "support_bot_01" |
timestamp | string | ISO 8601 timestamp | "2024-01-15T10:30:00Z" |
is_resolved | boolean | Whether the customer's issue was resolved | false |
Optional Fields:
| Field | Type | Description |
|---|---|---|
csat_score | number | Customer satisfaction (0-5) |
user_data | object | Custom metadata |
user_group_id | string | Your own label for a group of users, such as a customer segment or business unit (up to 200 characters). Reports and dashboards can group conversations by it. |
missing_info | boolean | true when information is missing from the conversation |
additional_info | object | Any extra metadata about the conversation as key-value pairs, such as language or channel. Every key is shown in the conversation's More Information panel. See Additional Info |
is_resolved means the customer's issue was resolved, not that the chat session has ended. Send false when the issue was left open, even if the conversation is over. Resolved conversations count toward the Resolution Rate metric.
Example:
{
"conversation_id": "conv_001",
"agent": "support_bot_01",
"timestamp": "2024-01-15T10:30:00Z",
"is_resolved": false,
"csat_score": 4.5,
"user_data": {
"source": "mobile_app",
"language": "en"
},
"additional_info": {
"channel": "web_chat",
"agent_version": "2.1.0"
}
}
Conversation fields are set once, when the conversation is created. The API has no endpoint to update them, and a second POST /conversations with the same conversation_id is ignored. If you upload a conversation while it is still going on, send is_resolved, csat_score, user_data, user_group_id, missing_info and additional_info with their final values in the first request, or create the conversation only after it ends.
Add Message
Endpoint: POST /messages
Required Fields:
| Field | Type | Description | Example |
|---|---|---|---|
message_id | string | Unique message ID | "msg_001" |
conversation_id | string | Parent conversation ID | "conv_001" |
role | string | "customer", "agent", or "system" | "customer" |
sender_id | string | Who sent the message | "customer_123" |
content | string | Message text (must not be empty) | "Hello, I need help" |
timestamp | string | ISO 8601 timestamp | "2024-01-15T10:31:00Z" |
Optional Fields:
| Field | Type | Description |
|---|---|---|
logs | array | Additional event logs |
Example:
{
"message_id": "msg_001",
"conversation_id": "conv_001",
"role": "customer",
"sender_id": "customer_123",
"content": "Hello, I need help with my order",
"timestamp": "2024-01-15T10:31:00Z",
"logs": [
{"name": "Step Name", "content": "Step details or result"}
]
}
💻 Code Examples
Python
import requests
from datetime import datetime
API_KEY = "YOUR_API_KEY_HERE"
BASE_URL = "https://app.avon-ai.com/api"
headers = {
"Content-Type": "application/json",
"X-API-Key": API_KEY
}
# Create conversation
conversation = {
"conversation_id": "conv_001",
"agent": "support_bot",
"timestamp": datetime.utcnow().isoformat() + "Z",
"is_resolved": False
}
response = requests.post(
f"{BASE_URL}/conversations",
headers=headers,
json=conversation
)
print(f"Conversation created: {response.json()}")
# Add message
message = {
"message_id": "msg_001",
"conversation_id": "conv_001",
"role": "customer",
"sender_id": "customer_123",
"content": "Hello, I need help",
"timestamp": datetime.utcnow().isoformat() + "Z"
}
response = requests.post(
f"{BASE_URL}/messages",
headers=headers,
json=message
)
print(f"Message added: {response.json()}")
JavaScript (Node.js)
const axios = require('axios');
const API_KEY = 'YOUR_API_KEY_HERE';
const BASE_URL = 'https://app.avon-ai.com/api';
const headers = {
'Content-Type': 'application/json',
'X-API-Key': API_KEY
};
// Create conversation
async function createConversation() {
const conversation = {
conversation_id: 'conv_001',
agent: 'support_bot',
timestamp: new Date().toISOString(),
is_resolved: false
};
const response = await axios.post(
`${BASE_URL}/conversations`,
conversation,
{ headers }
);
console.log('Conversation created:', response.data);
return response.data;
}
// Add message
async function addMessage(conversationId) {
const message = {
message_id: 'msg_001',
conversation_id: conversationId,
role: 'customer',
sender_id: 'customer_123',
content: 'Hello, I need help',
timestamp: new Date().toISOString()
};
const response = await axios.post(
`${BASE_URL}/messages`,
message,
{ headers }
);
console.log('Message added:', response.data);
return response.data;
}
// Run
createConversation()
.then(conv => addMessage(conv.conversation_id))
.catch(error => console.error('Error:', error));
cURL (Bash Script)
#!/bin/bash
API_KEY="YOUR_API_KEY_HERE"
BASE_URL="https://app.avon-ai.com/api"
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S)Z
# Create conversation
CONV_ID="conv_$(date +%s)"
curl -X POST "$BASE_URL/conversations" \
-H "Content-Type: application/json" \
-H "X-API-Key: $API_KEY" \
-d "{
\"conversation_id\": \"$CONV_ID\",
\"agent\": \"support_bot\",
\"timestamp\": \"$TIMESTAMP\",
\"is_resolved\": false
}"
# Add message
curl -X POST "$BASE_URL/messages" \
-H "Content-Type: application/json" \
-H "X-API-Key: $API_KEY" \
-d "{
\"message_id\": \"msg_$(date +%s)\",
\"conversation_id\": \"$CONV_ID\",
\"role\": \"customer\",
\"sender_id\": \"customer_123\",
\"content\": \"Hello, I need help\",
\"timestamp\": \"$TIMESTAMP\"
}"
🔍 Best Practices
1. Use Unique IDs
Always generate unique IDs for conversations and messages:
- ✅ Good:
conv_20240115_1030_abc123 - ❌ Bad:
conv_1(might conflict)
2. Include Timestamps
Always use ISO 8601 format with timezone:
- ✅ Good:
2024-01-15T10:30:00Z - ❌ Bad:
2024-01-15 10:30:00
3. Order Messages Chronologically
Send messages in the order they occurred to maintain conversation flow.
4. Handle Errors Gracefully
Always check the response status and handle errors:
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Success!")
else:
print(f"Error {response.status_code}: {response.json()}")
5. Stay Within the Rate Limit
Each API key can send 600 upload requests per 5 minutes. Both POST /conversations and POST /messages count toward the same limit, and the window is rolling: it always covers the last 5 minutes.
Every message is a separate request. A conversation with 10 messages takes 11 requests, so one API key uploads about 55 such conversations per 5 minutes, or about 650 per hour.
When you go over the limit, Avon answers 429 Too Many Requests with a Retry-After header (in seconds) and an empty body. To handle it:
- Wait for the number of seconds in
Retry-After, then send the same request again. Do not retry immediately: the requests that follow get429too until the window has room. - Keep a steady pace of at most 2 requests per second instead of sending in bursts.
- Do not parse the body of a
429response as JSON. It is empty.
Retrying is safe. A conversation_id that already exists is ignored, and a message with the same conversation_id and message_id is not added twice.
import time
def post_with_retry(url, headers, data):
while True:
response = requests.post(url, headers=headers, json=data)
if response.status_code != 429:
return response
time.sleep(int(response.headers.get("Retry-After", "60")))
There is no batch endpoint. To upload a large history (thousands of conversations), plan it with the pace above or contact your Avon account manager before you start.
❓ Common Questions
Q: Where do I get my API key?
A: Create it yourself on the API Keys page. The key sends data to the account you are signed in to.
Q: Can I test the API before going to production?
A: Yes! Use your API key with the production endpoint. Your data is isolated to your account.
Q: What happens if I send the same conversation ID twice?
A: The second request is ignored: the existing conversation is not changed, and the response is still successful. To add messages to an existing conversation, call POST /messages with its conversation_id.
Q: What happens if I send the same message twice?
A: Message IDs are unique within a conversation. If a message with the same conversation_id and message_id already exists, the request succeeds, the stored message is not changed, and the response returns the stored message. This makes it safe to resend a message after a timeout or a 429. To send a different message, use a new message_id.
Q: My conversation shows up with no messages. What went wrong?
A: Most likely POST /conversations was called but POST /messages was not. Add the messages with POST /messages using the same conversation_id.
Q: How do I know which tenant my data goes to?
A: Your API key is automatically linked to your account. All data goes to your isolated database.
Ready to get started? Grab your API key and send your first conversation! 🚀