Skip to main content
Base URL: https://api.toughtongueai.com/api/public All requests require Bearer token authentication.

Authentication

curl https://api.toughtongueai.com/api/public/scenarios \
  -H "Authorization: Bearer YOUR_API_TOKEN"
Get your token from Developer Portal → API Keys.
Proxy API calls through your backend. Never expose tokens client-side.

Core Workflows

1. Create Scenario

curl -X POST https://api.toughtongueai.com/api/public/scenarios \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sales Cold Call",
    "ai_instructions": "You are a skeptical VP of Engineering...",
    "is_public": true
  }'
Response:
{
  "id": "scenario_abc123",
  "name": "Sales Cold Call",
  "is_public": true
}

2. Create Session

curl -X POST https://api.toughtongueai.com/api/public/v2/sessions \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "scenario_id": "scenario_abc123",
    "user_email": "trainee@company.com",
    "metadata": {"team": "sales"}
  }'
Response:
{
  "session_id": "session_xyz789",
  "embed_url": "https://app.toughtongueai.com/embed/session/session_xyz789"
}

3. Analyze Session

curl -X POST https://api.toughtongueai.com/api/public/sessions/analyze \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"session_id": "session_xyz789"}'
Response:
{
  "overall_score": 85,
  "strengths": ["Strong opening", "Good questions"],
  "improvements": ["Handle objections more confidently"]
}

Backend Proxy Example

import express from "express";

const app = express();
const TTAI_TOKEN = process.env.TTAI_TOKEN;

app.post("/api/analyze", async (req, res) => {
  const response = await fetch("https://api.toughtongueai.com/api/public/sessions/analyze", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${TTAI_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ session_id: req.body.session_id }),
  });
  res.json(await response.json());
});

Endpoint Reference

Scenarios

MethodEndpointDescription
GET/scenariosList scenarios
POST/scenariosCreate scenario
GET/scenarios/{id}Get scenario
PATCH/scenarios/{id}Update scenario
DELETE/scenarios/{id}Delete scenario

Sessions

MethodEndpointDescription
GET/sessionsList sessions
GET/sessions/{id}Get session
POST/sessions/analyzeAnalyze session
POST/v2/sessionsCreate session

Utilities

MethodEndpointDescription
POST/testTest token
GET/balanceCheck balance

Error Codes

CodeMeaning
400Invalid parameters
401Invalid token
403Insufficient permissions
404Resource not found
429Rate limited
500Server error
Error format:
{
  "error": "Message",
  "details": {}
}

Best Practices

  1. Cache scenarios — they rarely change
  2. Poll or use callbacks — check session completion via iframe events or polling
  3. Retry with backoff — handle transient failures
  4. Log errors — monitor API health
Next: API Reference →