> For the complete documentation index, see [llms.txt](https://docs.amigo.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.amigo.ai/developer-guide/classic-api/data-access/organization-tables.md).

# Organization Tables & Schemas

Read-only tables that hold your organization's operational data. Each page below documents the schema for a specific area (conversations, users, services, and so on) along with a small query example to get you started.

{% hint style="info" %}
Guidelines

* Read-only tables with stable, production schemas.
* All timestamps are UTC.
* IDs are strings unless otherwise noted.
* JSON columns may contain nested objects or arrays.
* Availability varies by enabled features.
  {% endhint %}

### Available Tables

## Schema Overview

{% @mermaid/diagram content="%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#D4E2E7", "primaryTextColor": "#100F0F", "primaryBorderColor": "#083241", "lineColor": "#575452", "textColor": "#100F0F"}}}%%
erDiagram
ORGANIZATION ||--o{ USER : contains
ORGANIZATION ||--o{ SERVICE : contains
USER ||--o{ CONVERSATION : starts
CONVERSATION ||--o{ MESSAGE : includes
SERVICE ||--o{ CONVERSATION : powers
CONVERSATION ||--o{ METRIC : evaluates
ROLE ||--o{ USER : assigns
SERVICE ||--o{ TOOL : uses
SIMULATION ||--o{ CONVERSATION : tests" %}

## Common Queries

```sql
-- Active conversations in last 7 days
SELECT COUNT(*) as active_conversations
FROM conversations
WHERE created_at >= CURRENT_DATE - INTERVAL '7 days'
  AND is_finished = false;

-- Daily message volume
SELECT DATE(created_at) as day,
       COUNT(*) as message_count
FROM messages
WHERE org_id = 'your-org-id'
GROUP BY DATE(created_at)
ORDER BY day DESC
LIMIT 30;

-- User engagement metrics
SELECT u.user_id,
       u.email,
       COUNT(DISTINCT c._id) as conversation_count
FROM users u
LEFT JOIN conversations c ON u.user_id = c.user_id
GROUP BY u.user_id, u.email;
```

{% hint style="success" %}
Browse the subpages below for detailed schemas and query examples for each table category.
{% endhint %}

## Subpages

{% content-ref url="/pages/3BOJjReV2ER9lG1Lbc8K" %}
[Conversation](/developer-guide/classic-api/data-access/organization-tables/conversation.md)
{% endcontent-ref %}

{% content-ref url="/pages/a1uGvjaYVzPUp011WWr3" %}
[User](/developer-guide/classic-api/data-access/organization-tables/user.md)
{% endcontent-ref %}

{% content-ref url="/pages/ndEs1qWrrK2X7MosLB7k" %}
[Service](/developer-guide/classic-api/data-access/organization-tables/service.md)
{% endcontent-ref %}

{% content-ref url="/pages/NHOEAyfQvE1rftI1Xv1J" %}
[Organization](/developer-guide/classic-api/data-access/organization-tables/organization.md)
{% endcontent-ref %}

{% content-ref url="/pages/En5P0P9K5YCaWH8kfGL4" %}
[Broken mention](broken://pages/En5P0P9K5YCaWH8kfGL4)
{% endcontent-ref %}

{% content-ref url="/pages/kfW1VPtef0THEpkpAGWK" %}
[Metric](/developer-guide/classic-api/data-access/organization-tables/metric.md)
{% endcontent-ref %}

{% content-ref url="/pages/vwZM4rALcWUQUtHwlgzE" %}
[Role](/developer-guide/classic-api/data-access/organization-tables/role.md)
{% endcontent-ref %}

{% content-ref url="/pages/p9Pj4LBiaHArMQEFLrua" %}
[Tool](/developer-guide/classic-api/data-access/organization-tables/tool.md)
{% endcontent-ref %}

{% content-ref url="/pages/AYDdEWwIANWUzmjsuYVb" %}
[Simulation](/developer-guide/classic-api/data-access/organization-tables/simulation.md)
{% endcontent-ref %}

{% content-ref url="/pages/KZSX4w1PW3wTC27TC5LO" %}
[Common Query Patterns](/developer-guide/classic-api/data-access/organization-tables/common-query-patterns.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.amigo.ai/developer-guide/classic-api/data-access/organization-tables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
