API Reference
Add a new training source (text, URL, or full website) to an agent. Use type text with data, or page/website with url. Requires Enterprise plan.
POST https://chatspark.io/api/v1/agents/{id}/training| Field | Type | Required | Description |
|---|---|---|---|
source | string | Yes | Unique identifier for this source (e.g., slug) |
type | string | Yes | One of: text, page, website |
data | string | For text | Raw text content (required when type is text) |
url | string | For page/website | URL to scrape (required when type is page or website) |
{
"source": {
"id": 1,
"source": "product-docs",
"type": "text",
"trainingUrl": null,
"title": null,
"status": "pending",
"dataCount": null,
"createdAt": "2026-02-24T12:00:00.000Z",
"updatedAt": "2026-02-24T12:00:00.000Z"
}
}curl -X POST "https://chatspark.io/api/v1/agents/ag_123/training" \
-H "Authorization: Bearer cs_live_..." \
-H "Content-Type: application/json" \
-d '{"source":"faq","type":"text","data":"Q: What are your hours? A: 9am-5pm Mon-Fri."}'curl -X POST "https://chatspark.io/api/v1/agents/ag_123/training" \
-H "Authorization: Bearer cs_live_..." \
-H "Content-Type: application/json" \
-d '{"source":"docs","type":"page","url":"https://example.com/docs"}'const res = await fetch(`https://chatspark.io/api/v1/agents/ag_123/training`, {
method: "POST",
headers: {
"Authorization": "Bearer cs_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
source: "product-faq",
type: "text",
data: "Your FAQ text here...",
}),
});
const { source } = await res.json();