Core Concepts
Understand the Chatsby AI data model — Agents, Sources, Conversations, Messages, and how they relate to each other.
Before you start building with the Chatsby API, you need to understand how resources are organized. This guide covers every resource type, their fields, relationships, lifecycle states, and the conventions the API uses for identifiers, timestamps, and idempotency.
Resource Hierarchy
The Chatsby data model follows a clear hierarchy. Every resource belongs to an Account, and resources relate to each other in a predictable tree structure:
Account
├── Agent
│ ├── Source (knowledge base content)
│ ├── Source
│ └── Conversation
│ ├── Message (user)
│ ├── Message (assistant)
│ └── Message (user)
├── Agent
│ ├── Source
│ └── Conversation
│ └── Message
└── Webhook Endpoint (account-level)
The key relationships:
- An Account owns multiple Agents.
- An Agent has multiple Sources (its knowledge base) and multiple Conversations (user interactions).
- A Conversation contains an ordered sequence of Messages.
- Webhook Endpoints are configured at the account level and fire events for all agents.
Agent Resource
An Agent is the central resource in Chatsby. It represents a configured AI chatbot with a specific personality, knowledge base, and behavioral parameters. Every conversation and source belongs to exactly one agent.
Agent Object
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier. Format: agent_ followed by 10 alphanumeric characters. |
name | string | Human-readable name for the agent (e.g., "Customer Support Bot"). Max 100 characters. |
model | string | The underlying AI model. Options: gpt-4-turbo, gpt-4o, gpt-3.5-turbo. Default: gpt-4o. |
system_prompt | string | Instructions that define the agent's behavior, tone, and constraints. Max 4,000 characters. |
temperature | number | Controls response randomness. Range: 0.0 to 2.0. Default: 0.7. Lower values produce more deterministic responses. |
max_tokens | integer | Maximum number of tokens in the agent's response. Range: 1 to 4096. Default: 1024. |
status | string | Current state: active, paused, or deleted. |
created_at | string | ISO 8601 timestamp of when the agent was created. |
updated_at | string | ISO 8601 timestamp of the last modification. |
Example Agent Object
{
"id": "agent_1a2b3c4d5e",
"name": "Customer Support Bot",
"model": "gpt-4o",
"system_prompt": "You are a helpful customer support agent for Acme Corp. Be concise and professional. If you don't know the answer, say so honestly.",
"temperature": 0.5,
"max_tokens": 1024,
"status": "active",
"created_at": "2025-03-10T08:00:00Z",
"updated_at": "2025-03-12T14:30:00Z"
}Source Resource
A Source represents a piece of knowledge that an agent can use to answer questions. Sources are processed and indexed when created so the agent can retrieve relevant content at query time.
Source Object
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier. Format: src_ followed by 10 alphanumeric characters. |
type | string | The kind of source: website, text, file, or qa. |
content | string | The source data. For website, this is a URL. For text, this is raw text. For file, this is a file reference. For qa, this is a JSON string of question-answer pairs. |
status | string | Processing state: pending, processing, trained, or failed. |
character_count | integer | Number of characters extracted from the source after processing. |
agent_id | string | The ID of the agent this source belongs to. |
created_at | string | ISO 8601 timestamp of when the source was created. |
Example Source Object
{
"id": "src_abc123defg",
"type": "website",
"content": "https://acmecorp.com/help",
"status": "trained",
"character_count": 24580,
"agent_id": "agent_1a2b3c4d5e",
"created_at": "2025-03-10T08:15:00Z"
}Source Types
Each source type has specific behavior:
| Type | Content Field | Description |
|---|---|---|
website | URL string | Chatsby crawls the URL and extracts text content. Subpages can optionally be followed. |
text | Raw text string | Plain text provided directly. Useful for FAQs, policies, or custom instructions. |
file | File reference | Upload a PDF, DOCX, or TXT file. Content is extracted and indexed. |
qa | JSON string | An array of {"question": "...", "answer": "..."} objects for precise Q&A matching. |
Conversation Resource
A Conversation represents an interaction session between an end user and an agent. It is created when the first message is sent and accumulates messages over its lifetime.
Conversation Object
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier. Format: conv_ followed by 10 alphanumeric characters. |
agent_id | string | The ID of the agent this conversation belongs to. |
metadata | object | Custom key-value pairs attached to the conversation (max 20 keys). |
created_at | string | ISO 8601 timestamp of when the conversation started. |
updated_at | string | ISO 8601 timestamp of the last message in the conversation. |
messages | array | Ordered array of Message objects in this conversation. |
Example Conversation Object
{
"id": "conv_xyz789abcd",
"agent_id": "agent_1a2b3c4d5e",
"metadata": {
"user_id": "usr_12345",
"plan": "premium"
},
"created_at": "2025-03-15T14:30:00Z",
"updated_at": "2025-03-15T14:32:00Z",
"messages": [
{
"role": "user",
"content": "What is your return policy?",
"timestamp": "2025-03-15T14:30:00Z"
},
{
"role": "assistant",
"content": "Our return policy allows returns within 30 days of purchase...",
"sources_used": [
{ "id": "src_abc123defg", "title": "Return Policy Page" }
],
"timestamp": "2025-03-15T14:30:02Z"
}
]
}Message Resource
A Message is a single exchange within a conversation. Messages are immutable — once created, they cannot be edited or deleted independently.
Message Object
| Field | Type | Description |
|---|---|---|
role | string | Who sent the message: user or assistant. |
content | string | The text content of the message. |
sources_used | array | (Assistant messages only) Array of source references used to generate the response. Each object has id and title. |
timestamp | string | ISO 8601 timestamp of when the message was created. |
The sources_used field provides transparency into which knowledge base content informed the agent's response. This is useful for debugging and for building citation UIs.
Resource Lifecycle
Resources in Chatsby follow predictable lifecycle patterns:
Agents
create → active → (paused) → deleted
- Active — The agent is ready to receive conversations and respond to messages.
- Paused — The agent exists but does not accept new conversations. Existing conversations remain accessible. Useful for maintenance windows.
- Deleted — The agent and all its associated sources and conversations are permanently removed. This action is irreversible.
Sources
create → pending → processing → trained
→ failed
- Pending — The source has been submitted but processing has not started.
- Processing — The source is being crawled, extracted, or indexed.
- Trained — Processing is complete and the content is available to the agent.
- Failed — Processing encountered an error. Check the error details and retry.
When a source transitions to trained or failed, a source.trained or source.failed webhook event is fired if you have webhooks configured.
Conversations
create (first message) → active → deleted
Conversations are created implicitly when the first message is sent. They remain active indefinitely until explicitly deleted via the API.
Idempotency
For write operations (POST, PATCH, DELETE), you can include an Idempotency-Key header to safely retry requests without creating duplicate resources.
curl -X POST https://api.chatsby.co/v1/agents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: unique-request-id-abc123" \
-d '{"name": "Support Bot", "model": "gpt-4o"}'The idempotency key must be a unique string (UUIDs work well). If you send the same request with the same idempotency key within 24 hours, the API returns the original response instead of creating a duplicate resource. This is essential for safely retrying failed network requests.
Idempotency keys are scoped to your account and expire after 24 hours. After expiration, the same key can be reused for a new request.
Timestamps
All timestamps in the API are in ISO 8601 format and UTC timezone:
2025-03-15T14:30:00Z
The trailing Z indicates UTC. The API does not accept or return timestamps in other timezones. Convert to the user's local timezone in your application layer.
Resource Identifiers
Every resource has a unique identifier with a type prefix for readability:
| Resource | Prefix | Example |
|---|---|---|
| Agent | agent_ | agent_1a2b3c4d5e |
| Source | src_ | src_abc123defg |
| Conversation | conv_ | conv_xyz789abcd |
| Webhook Endpoint | whep_ | whep_hook12345 |
Identifiers are:
- Globally unique — No two resources of any type share the same ID.
- Immutable — An ID never changes after creation.
- URL-safe — Alphanumeric characters only, safe to use in URL paths.
- Case-sensitive — Always use the exact casing returned by the API.
Relationships Between Resources
Understanding how resources reference each other is important for building correct API queries:
| Relationship | How to query |
|---|---|
| Agent's sources | GET /v1/agents/{agent_id}/sources |
| Agent's conversations | GET /v1/agents/{agent_id}/conversations |
| Conversation's messages | Included in GET /v1/conversations/{id} response |
| Source's parent agent | The agent_id field on the source object |
| Message's parent conversation | Messages are always returned within a conversation object |
Resources cannot be moved between parents. A source cannot be reassigned to a different agent — you must delete it and create a new one under the target agent.
On this page
- Resource Hierarchy
- Agent Resource
- Agent Object
- Example Agent Object
- Source Resource
- Source Object
- Example Source Object
- Source Types
- Conversation Resource
- Conversation Object
- Example Conversation Object
- Message Resource
- Message Object
- Resource Lifecycle
- Agents
- Sources
- Conversations
- Idempotency
- Timestamps
- Resource Identifiers
- Relationships Between Resources