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

# Data Warehouse

> Query your data directly with SQL. Available for companies with access enabled.

# Data Warehouse

Treble provides a Data Warehouse that lets you query your operational data directly with SQL. This gives you the flexibility to build custom reports, connect BI tools, and analyze your data without depending on the Treble team.

<Note>
  Access to the Data Warehouse is available only for companies that request onboarding. If you are interested, contact your Account Manager or reach out to support to start the process.
</Note>

## What can you query?

* History of conversations handled by your agents
* Messages sent and received in each conversation
* Transfers between agents
* Agent availability and connection times
* Daily agent productivity
* Detail and metrics of outbound campaign deliveries
* Inbound and outbound sessions

## Connection

Once access is enabled, you will receive credentials to connect:

| Parameter    | Value                                |
| ------------ | ------------------------------------ |
| **Host**     | Provided by Treble                   |
| **Port**     | `8443` (HTTPS) / `9440` (Native TLS) |
| **Database** | `client_analytics`                   |
| **User**     | Provided by Treble                   |
| **Password** | Provided by Treble                   |

You can use any ClickHouse-compatible client: DBeaver, DataGrip, `clickhouse-client`, or connect directly from Google Sheets, Metabase, Looker, or another BI tool.

## Security and Limits

* **Secure data:** Your data is protected by privacy policies. Only your company can access your account information.
* **Read-only:** Your user cannot modify, create, or delete data.
* **Protection limits:** Queries have a maximum time of 30 seconds and row and memory limits to ensure system stability.

## Update Frequency

* Data has a **maximum delay of 3 hours** with respect to real-time operations.
* Tables contain data from the **last 3 months**.
* Some tables (agent, team, tag dimensions) may have a higher update frequency, close to 10 minutes.

## Best Practices

To write efficient queries and make the most of ClickHouse's columnar structure, check the [Query Optimization](/en/docs/data-warehouse/query-optimization) guide.

## Available Tables

### Fact tables

Contain the events and transactions of your operation.

| Table                                                                            | What does it answer?                                                  | Granularity                |
| -------------------------------------------------------------------------------- | --------------------------------------------------------------------- | -------------------------- |
| [`fact_conversations`](/en/docs/data-warehouse/fact-conversations)               | How many conversations were handled? By whom? How long did they last? | 1 row per conversation     |
| [`fact_agent_messages`](/en/docs/data-warehouse/fact-agent-messages)             | What was said in each conversation? Who sent each message?            | 1 row per message          |
| [`fact_redirections`](/en/docs/data-warehouse/fact-redirections)                 | How many transfers occurred? From whom to whom?                       | 1 row per transfer         |
| [`fact_agent_status_changes`](/en/docs/data-warehouse/fact-agent-status-changes) | When did agents connect and disconnect?                               | 1 row per status change    |
| [`fact_agent_daily`](/en/docs/data-warehouse/fact-agent-daily)                   | What was each agent's productivity per day?                           | 1 row per agent per day    |
| [`fact_sessions`](/en/docs/data-warehouse/fact-sessions)                         | How many sessions did the campaign have? Inbound or outbound?         | 1 row per session          |
| [`fact_deployment_status`](/en/docs/data-warehouse/fact-deployment-status)       | What was the result of each outbound delivery?                        | 1 row per delivery         |
| [`fact_deployment_daily`](/en/docs/data-warehouse/fact-deployment-daily)         | How many deliveries per campaign per day? Delivery and response rate? | 1 row per campaign per day |
| [`fact_hsm_responses`](/en/docs/data-warehouse/fact-hsm-responses)               | What did users reply to HSM templates?                                | 1 row per response         |
| `fact_target_events`                                                             | Which conversion goals were met? *(Coming soon)*                      | 1 row per goal met         |

### Dimension tables (dims)

Contain reference information you can join with the fact tables.

| Table                                                  | Description                                 |
| ------------------------------------------------------ | ------------------------------------------- |
| [`dim_agents`](/en/docs/data-warehouse/dimensions)     | Agents: name, email, active/inactive status |
| [`dim_tags`](/en/docs/data-warehouse/dimensions)       | Assignment queues or tags                   |
| [`dim_teams`](/en/docs/data-warehouse/dimensions)      | Work teams                                  |
| [`dim_hsm`](/en/docs/data-warehouse/dimensions)        | HSM templates (WhatsApp templates)          |
| [`dim_agent_tags`](/en/docs/data-warehouse/dimensions) | Agent ↔ tag ↔ team relation                 |

## Quick Example

```sql theme={null}
-- Conversations handled in the last 7 days
SELECT
    created_at,
    conversation_id,
    agent_name,
    status,
    finish_type
FROM client_analytics.fact_conversations
WHERE created_at >= now() - INTERVAL 7 DAY
ORDER BY created_at DESC
LIMIT 100
```
