Skip to main content
POST
/
track
curl --request POST \
  --url https://api.useturret.com/track \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --data @- <<EOF
{
  "name": "User submitted prompt",
  "metadata": {
    "prompt": "What's the weather like in San Francisco?"
  }
}
EOF
{
  "success": true,
  "message": "Event tracked successfully",
  "event_id": "evt_1234567890abcdef"
}

Overview

The /track endpoint is the core of Turret’s API. Use it to send user events with metadata for automatic semantic analysis and clustering.

Request Body

name
string
required
A descriptive name for the event (e.g., “User submitted prompt”, “Feedback received”)
metadata
object
required
An object containing free-form text data to be analyzed. This should include the actual text content you want Turret to cluster.

Example Request

curl -X POST https://api.useturret.com/track \
  -H "X-Api-Key: your_project_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "User submitted prompt",
    "metadata": {
      "prompt": "What's the weather like in San Francisco?",
    }
  }'

Response

success
boolean
Indicates if the event was successfully tracked
message
string
Human-readable message about the result
event_id
string
Unique identifier for the tracked event

Example Response

{
  "success": true,
  "message": "Event tracked successfully",
  "event_id": "evt_1234567890abcdef"
}

Common Use Cases

Track User Prompts

{
  "name": "LLM prompt submitted",
  "metadata": {
    "prompt": "Write a product description for wireless headphones",
    "model": "gpt-4",
    "user_intent": "marketing_content",
    "session_context": "bulk_content_generation"
  }
}

Track User Feedback

{
  "name": "User provided feedback",
  "metadata": {
    "feedback": "The response was helpful but could be more specific",
    "rating": 4,
    "original_prompt": "How do I optimize my database queries?",
    "improvement_suggestion": "Include specific examples for my database type"
  }
}

Track Feature Usage

{
  "name": "Feature used",
  "metadata": {
    "feature_name": "advanced_search",
    "user_query": "find all documents about machine learning",
    "search_context": "research_project",
    "results_found": 47
  }
}

Error Responses

Invalid API Key (401)

{
  "success": false,
  "error": "Invalid API key",
  "code": "INVALID_API_KEY"
}

Missing Required Fields (400)

{
  "success": false,
  "error": "Missing required field: name",
  "code": "MISSING_REQUIRED_FIELD"
}

Rate Limit Exceeded (429)

{
  "success": false,
  "error": "Rate limit exceeded. Try again in 1 hour.",
  "code": "RATE_LIMIT_EXCEEDED",
  "retry_after": 3600
}

Best Practices

Event Names

  • Use descriptive, consistent names
  • Follow a naming convention (e.g., “user_action_object”)
  • Avoid generic names like “event” or “action”

Metadata Structure

  • Include the actual text you want analyzed
  • Provide context about where/when the event occurred
  • Add relevant user or session information
  • Keep individual text fields under 10,000 characters

Error Handling

  • Always check the success field in the response
  • Implement retry logic with exponential backoff
  • Don’t let tracking failures break your application flow
The quality of your insights depends on the quality of your metadata. Include rich, contextual information to get the most value from Turret’s clustering.

Authorizations

X-Api-Key
string
header
required

Your project API key from the Turret dashboard

Body

application/json

Event data to track

name
string
required

A descriptive name for the event

Required string length: 1 - 255
Example:

"User submitted prompt"

metadata
object
required

An object containing free-form text data to be analyzed

Example:
{
"prompt": "What's the weather like in San Francisco?"
}

Response

Event successfully tracked

success
boolean

Indicates if the event was successfully tracked

Example:

true

message
string

Human-readable message about the result

Example:

"Event tracked successfully"

event_id
string

Unique identifier for the tracked event

Example:

"evt_1234567890abcdef"