Templates & Variables¶
Prompt templates let you define reusable, parameterized interactions that customers can fill in and execute via the API.
Overview¶
Templates combine:
- A prompt template with
{{VARIABLE}}placeholders - A variable schema defining expected inputs
- An agent type to handle the rendered prompt
This enables structured, repeatable interactions without requiring customers to write prompts from scratch.
How Templates Work¶
Template: "Summarize the following document: {{DOCUMENT_TEXT}}"
│
▼
Customer provides: { "DOCUMENT_TEXT": "..." }
│
▼
Rendered prompt sent to agent → Response returned
Managing Templates¶
Templates are created and managed via the Dashboard:
- Go to Agent Types > select a type > Templates
- Click Create Template
- Define the template prompt with
{{VARIABLE}}placeholders - Configure variable schema (name, type, required)
- Publish the template
Using Templates via API¶
List Published Templates¶
Response:
[
{
"id": 1,
"name": "Document Summary",
"description": "Summarize a document",
"variables": [
{"name": "DOCUMENT_TEXT", "type": "string", "required": true}
]
}
]
Get Template Details¶
Store Variables (No Agent Call)¶
Use /use to store variables and get the rendered content without calling an agent:
curl -X POST https://api.ag2trust.com/api/v1/pool/templates/1/use \
-H "X-API-Key: cust_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"variables": {
"DOCUMENT_TEXT": "The quarterly report shows..."
},
"thread_id": "thread_abc123"
}'
Start Template (Store Variables + Call Agent)¶
Use /start to store variables and immediately send the rendered prompt to an agent:
curl -X POST https://api.ag2trust.com/api/v1/pool/templates/1/start \
-H "X-API-Key: cust_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"variables": {
"DOCUMENT_TEXT": "The quarterly report shows..."
},
"agent_type_slug": "summarizer"
}'
Response matches the standard pool endpoint response.
Variables¶
Variables are the building blocks of templates and context injection. See the Knowledge Base guide for full details on variable management.
Variable Types¶
| Type | Example | Description |
|---|---|---|
string | "Hello" | Text value (default) |
int | 42 | Integer number |
float | 3.14 | Decimal number |
boolean | true | True/false |
date | 2025-01-15 | Date value |
Validators¶
| Validator | Description |
|---|---|
none | No validation (default) |
email | Must be a valid email address |
url | Must be a valid URL |
phone | Must be a valid phone number |
regex | Must match a custom regex pattern |
Static vs Dynamic Variables¶
| Property | Static (is_dynamic: false) | Dynamic (is_dynamic: true) |
|---|---|---|
| Value source | Stored in DB (KMS-encrypted) | Provided at runtime via context_variables |
| Use case | Company info, policies | User-specific data |
| Persistence | Persisted | Ephemeral (per-request only) |
Naming Convention¶
Variable names must be UPPERCASE_SNAKE_CASE:
API Reference¶
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/pool/templates | List published templates |
GET | /api/v1/pool/templates/{id} | Get template with variable schema |
POST | /api/v1/pool/templates/{id}/use | Store variables (no agent call) |
POST | /api/v1/pool/templates/{id}/start | Store variables + call agent |
Best Practices¶
- Use descriptive variable names —
CUSTOMER_COMPLAINTis better thanTEXT - Add validation — Use
email,url, orregexvalidators to catch bad input early - Keep templates focused — One template per use case (e.g., "Summarize Document", "Draft Email Response")
- Use static variables for constants — Company name, support hours, and policies should be static variables, not runtime inputs
Next Steps¶
- Knowledge Base — Variable management and context injection
- Pool Endpoint — Sending messages to agents
- Agent Types — Configuring agent templates