Tolly

Tolly API Documentation

Authentication

All API requests require authentication using your API key. Include your API key in the Authorization header:

Authorization: Bearer your-api-key-here

API Endpoint

The Tolly API provides a single endpoint for resolving functions:

POST https://api.tolly.dev/v1/execute/{function_name}

Request Format

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)"
}

Complete Example

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"]
    }
  }'

JavaScript Example

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();

Response Format

The API returns a JSON response with your resolved data:

{
  "result": {
    "category": "authentication",
    "priority": "high",
    "sentiment": "negative"
  }
}