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

# REST API

> Trigger and retrieve Deeptrace investigations programmatically

Deeptrace provides a REST API so you can trigger investigations and retrieve results from any system.

## Quick Start

<Steps>
  <Step title="Create an API key">
    Go to **[Settings](https://app.deeptrace.com/settings) > [API Keys](https://app.deeptrace.com/api-keys)** in the Deeptrace dashboard and create a new key.
  </Step>

  <Step title="Trigger an investigation">
    Send a `POST` request to `/api/v1/investigate` with your query. You receive an `investigation_id` back immediately.
  </Step>

  <Step title="Poll for results">
    Poll `GET /api/v1/investigations/{id}` until `status` is `completed`. Investigations typically complete in a couple of minutes.
  </Step>

  <Step title="Use the results">
    Parse `investigation_text` for the full root cause analysis, or link to `https://app.deeptrace.com/investigation/{id}` for the web view with citations.
  </Step>
</Steps>

## Endpoints

### Investigations

<CardGroup cols={2}>
  <Card title="Trigger Investigation" icon="play" href="/trigger-investigation">
    Start a new investigation asynchronously.
  </Card>

  <Card title="Get Investigation" icon="magnifying-glass" href="/get-investigation">
    Retrieve status and results of an investigation.
  </Card>
</CardGroup>

### Chat

<CardGroup cols={2}>
  <Card title="Send Chat Message" icon="message" href="/send-chat">
    Send a message and get an AI-powered response.
  </Card>

  <Card title="Get Chat" icon="comments" href="/get-chat">
    Retrieve a chat with full conversation history.
  </Card>

  <Card title="List Chats" icon="list" href="/list-chats">
    Get a paginated list of chats for your team.
  </Card>
</CardGroup>

## Error Codes

| Status Code | Description                                     |
| ----------- | ----------------------------------------------- |
| `400`       | Invalid request body or missing required fields |
| `401`       | Missing or invalid API key                      |
| `403`       | Expired or revoked API key                      |
| `404`       | Resource not found                              |
| `422`       | Validation error                                |
| `500`       | Internal server error                           |
