All API requests require authentication using your API key. Include your API key in the Authorization header:
Authorization: Bearer your-api-key-hereThe Tolly API provides a single endpoint for resolving functions:
POST https://api.tolly.dev/v1/execute/{function_name}Send a POST request with the following JSON structure:
{
"input": {
// Your input data here
},
"schema": {
// Zod schema for output validation (optional)
},
"description": "Description of the function (optional)"
}Here's a complete example using cURL:
curl -X POST https://api.tolly.dev/v1/execute/labelTicket \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-here" \
-d '{
"input": {
"ticket": {
"title": "Can't login to my account",
"description": "I've been trying to log in for the past hour but keep getting an error message. This is urgent as I need to access my project files for a client meeting tomorrow.",
"userEmail": "john.doe@company.com"
},
"availableCategories": [
"authentication",
"billing",
"technical-support",
"feature-request"
]
},
"schema": {
"type": "object",
"properties": {
"category": { "type": "string" },
"priority": { "type": "string", "enum": ["low", "medium", "high", "urgent"] },
"sentiment": { "type": "string", "enum": ["positive", "neutral", "negative"] }
},
"required": ["category", "priority", "sentiment"]
}
}'Using fetch in JavaScript:
async function callTollyAPI() {
try {
const response = await fetch('https://api.tolly.dev/v1/execute/labelTicket', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-api-key-here'
},
body: JSON.stringify({
input: {
ticket: {
title: 'Can't login to my account',
description: 'I've been trying to log in for the past hour but keep getting an error message. This is urgent as I need to access my project files for a client meeting tomorrow.',
userEmail: 'john.doe@company.com'
},
availableCategories: [
'authentication',
'billing',
'technical-support',
'feature-request'
]
},
schema: {
type: 'object',
properties: {
category: { type: 'string' },
priority: { type: 'string', enum: ['low', 'medium', 'high', 'urgent'] },
sentiment: { type: 'string', enum: ['positive', 'neutral', 'negative'] }
},
required: ['category', 'priority', 'sentiment']
}
})
});
const result = await response.json();
console.log(result);
} catch (error) {
console.error('Error:', error);
}
}
callTollyAPI();The API returns a JSON response with your resolved data:
{
"result": {
"category": "authentication",
"priority": "high",
"sentiment": "negative"
}
}