> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toughtongueai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Reference

> Tough Tongue AI REST API

* Base URL: `https://api.toughtongueai.com/api/public`
* Download [OpenAPI Specification](/api-reference/openapi.json)

***

## Authentication

All requests require Bearer token authentication.
Get your API token from the [Developer Portal](https://app.toughtongueai.com/developer?tab=api-keys)

<ParamField body="input" type="string" default="check" placeholder="check" required>
  Enter `check` to test
</ParamField>

<RequestExample>
  ```json theme={null}
  {
    "input": "check"
  }
  ```
</RequestExample>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.toughtongueai.com/api/public/test \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"input": "check"}'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.toughtongueai.com/api/public/test", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ input: "check" }),
  });
  const result = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.toughtongueai.com/api/public/test',
      headers={'Authorization': 'Bearer YOUR_API_TOKEN'},
      json={'input': 'check'}
  )
  result = response.json()
  ```
</CodeGroup>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "message": "API token is valid"
  }
  ```
</ResponseExample>

***

## Endpoints

### Scenarios

| Method | Endpoint              | Description            |
| ------ | --------------------- | ---------------------- |
| GET    | `/scenarios`          | List all scenarios     |
| POST   | `/scenarios`          | Create scenario        |
| GET    | `/scenarios/{id}`     | Get scenario           |
| PATCH  | `/scenarios/{id}`     | Update scenario        |
| DELETE | `/scenarios/{id}`     | Delete scenario        |
| GET    | `/featured-scenarios` | List featured (public) |

### Sessions

| Method | Endpoint            | Description         |
| ------ | ------------------- | ------------------- |
| GET    | `/sessions`         | List sessions       |
| GET    | `/sessions/{id}`    | Get session details |
| POST   | `/sessions/analyze` | Trigger analysis    |
| POST   | `/v2/sessions`      | Create session      |

### Miscellaneous Utilities

| Method | Endpoint   | Description          |
| ------ | ---------- | -------------------- |
| POST   | `/test`    | Test API token       |
| GET    | `/balance` | Check wallet balance |

***

## Errors

In case of an error from any of the API endpoints, the response will contain `error` and `details` fields.
It shall also be accompanied with appropriate HTTP status codes.

| Code | Meaning       |
| ---- | ------------- |
| 400  | Bad request   |
| 401  | Invalid token |
| 403  | Forbidden     |
| 404  | Not found     |
| 429  | Rate limited  |
| 500  | Server error  |

```json theme={null}
{
  "error": "Error message",
  "details": {}
}
```
