Analysis Templates allow you to define reusable structured data extraction schemas for call analysis. Each template includes prompts and a JSON schema that defines what information should be extracted from call transcripts.Analysis templates are saved as objects in agent configurations, not as references. This means agents continue working even if you delete a template.
Endpoints#
List Analysis Templates#
Retrieve all analysis templates for your organization.Request#
Response#
{
"analysisTemplates": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"org_id": "7461b868-afc1-4fe2-871a-5e7c0f3d5772",
"name": "Customer Satisfaction Survey",
"description": "Extract customer satisfaction metrics and feedback",
"system_prompt": "You are analyzing a customer service call. Extract key satisfaction indicators.",
"user_prompt": "Analyze this call transcript and extract the required data.\n\nTranscript: {{transcript}}",
"schema": {
"type": "object",
"properties": {
"satisfaction_level": {
"type": "string",
"description": "Overall customer satisfaction",
"enum": ["very_satisfied", "satisfied", "neutral", "dissatisfied", "very_dissatisfied"]
},
"main_issues": {
"type": "array",
"description": "List of issues discussed"
},
"issue_resolved": {
"type": "boolean",
"description": "Whether the customer's issue was resolved"
}
}
},
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
}
]
}
Create Analysis Template#
Create a new analysis template.Request Body#
| Field | Type | Required | Description |
|---|
name | string | Yes | Display name for the template |
description | string | No | Description of what this template extracts |
system_prompt | string | No | System instructions for the analysis AI |
user_prompt | string | No | User prompt with {{transcript}} placeholder |
schema | object | Yes | JSON Schema defining extracted data structure |
Example Request#
Response (201 Created)#
{
"analysisTemplate": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"org_id": "7461b868-afc1-4fe2-871a-5e7c0f3d5772",
"name": "Lead Qualification",
"description": "Qualify sales leads based on call content",
...
}
}
Get Analysis Template#
Retrieve a specific analysis template by ID.GET /analysis-templates/{id}
Parameters#
| Name | In | Type | Description |
|---|
id | path | UUID | Analysis template UUID |
Request#
Response#
{
"analysisTemplate": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Customer Satisfaction Survey",
...
}
}
Update Analysis Template#
Update an existing analysis template. Only provided fields will be updated.PATCH /analysis-templates/{id}
Parameters#
| Name | In | Type | Description |
|---|
id | path | UUID | Analysis template UUID |
Request Body#
All fields are optional. Only include fields you want to update.Example Request#
Response#
{
"analysisTemplate": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Customer Satisfaction Survey v2",
...
}
}
Delete Analysis Template#
Delete an analysis template.DELETE /analysis-templates/{id}
Deleting a template does not affect agents that are using it. The analysis configuration is stored as an object in the agent, not as a reference.
Parameters#
| Name | In | Type | Description |
|---|
id | path | UUID | Analysis template UUID |
Request#
Response#
Using Analysis Templates with Agents#
Analysis templates define reusable configurations. When you select a template for an agent, the configuration is copied to the agent's analysis_plan field.Agent Analysis Plan Structure#
{
"analysis_plan": {
"structuredDataPlan": {
"enabled": true,
"schema": {
"type": "object",
"properties": {
"satisfaction_level": {
"type": "string",
"enum": ["very_satisfied", "satisfied", "neutral", "dissatisfied"]
}
}
},
"messages": [
{
"role": "system",
"content": "You are analyzing a customer service call..."
},
{
"role": "user",
"content": "Analyze this call transcript...\n\nTranscript: {{transcript}}"
}
]
},
"minMessagesThreshold": 3
}
}
Schema Definition#
The schema field follows JSON Schema specification. Supported types:| Type | Description | Example |
|---|
string | Text values | "type": "string" |
integer | Whole numbers | "type": "integer", "minimum": 1, "maximum": 10 |
number | Decimal numbers | "type": "number" |
boolean | true/false | "type": "boolean" |
array | Lists | "type": "array", "items": { "type": "string" } |
object | Nested objects | "type": "object", "properties": {...} |
Example: Complete Schema#
{
"type": "object",
"properties": {
"sentiment": {
"type": "string",
"description": "Overall call sentiment",
"enum": ["positive", "neutral", "negative"]
},
"satisfaction_score": {
"type": "integer",
"description": "Customer satisfaction 1-10",
"minimum": 1,
"maximum": 10
},
"issue_resolved": {
"type": "boolean",
"description": "Whether the issue was resolved"
},
"topics": {
"type": "array",
"description": "Topics discussed",
"items": { "type": "string" }
},
"follow_up": {
"type": "object",
"description": "Follow-up action if needed",
"properties": {
"required": { "type": "boolean" },
"reason": { "type": "string" }
}
}
}
}
Prompt Placeholders#
User prompts support the following placeholders:| Placeholder | Description |
|---|
{{transcript}} | Full call transcript |
{{schema}} | Your JSON Schema (auto-injected) |
{{endedReason}} | Why the call ended |
Error Responses#
| Status | Description |
|---|
| 400 | Invalid request (e.g., invalid schema format) |
| 401 | Unauthorized (invalid or missing API key) |
| 403 | Forbidden (no access to this resource) |
| 404 | Analysis template not found |
{
"error": "Analysis template not found"
}