# Organization

Schema reference for organization-level configuration: agents and their state machines.

### Agents Table

**Table Name:** `agents`\
**Description:** Agent configurations and metadata

{% tabs %}
{% tab title="Schema" %}

| Column                   | Type      | Description                       |
| ------------------------ | --------- | --------------------------------- |
| `_id`                    | string    | Internal identifier               |
| `agent_id`               | string    | Agent stable identifier           |
| `background`             | json      | Agent background information      |
| `behaviors`              | json      | Configured agent behaviors        |
| `communication_patterns` | json      | Communication style configuration |
| `created_at`             | timestamp | Creation timestamp                |
| `identity`               | json      | Agent identity configuration      |
| `initials`               | string    | Agent initials                    |
| `name`                   | string    | Agent display name                |
| `org_id`                 | string    | Organization identifier           |
| `organization`           | json      | Organization metadata             |
| `pfp`                    | json      | Agent profile media               |
| `region_name`            | string    | Deployment region                 |
| `updated_at`             | timestamp | Last update timestamp             |
| `version`                | integer   | Configuration version number      |
| {% endtab %}             |           |                                   |

{% tab title="Query Example" %}

```sql
SELECT
  agent_id,
  name,
  created_at,
  communication_patterns
FROM agents
ORDER BY created_at DESC
LIMIT 10;
```

{% endtab %}
{% endtabs %}

### Service State Machines Table

**Table Name:** `service_hierarchical_state_machines`\
**Description:** Service state machine configurations

{% tabs %}
{% tab title="Schema" %}

| Column                                     | Type      | Description                       |
| ------------------------------------------ | --------- | --------------------------------- |
| `_id`                                      | string    | State machine identifier          |
| `created_at`                               | timestamp | Creation timestamp                |
| `description`                              | string    | State machine description         |
| `global_action_guidelines`                 | json      | Global action rules               |
| `global_boundary_constraints`              | json      | Boundary constraints              |
| `global_intra_state_navigation_guidelines` | json      | Navigation rules                  |
| `name`                                     | string    | State machine name                |
| `new_user_initial_state`                   | string    | Initial state for new users       |
| `org_id`                                   | string    | Organization identifier           |
| `references`                               | json      | External references               |
| `region_name`                              | string    | Deployment region                 |
| `returning_user_initial_state`             | string    | Initial state for returning users |
| `service_hierarchical_state_machine_id`    | string    | Unique state machine ID           |
| `states`                                   | json      | State definitions                 |
| `terminal_state`                           | string    | Terminal state name               |
| `version`                                  | integer   | Configuration version             |
| {% endtab %}                               |           |                                   |

{% tab title="Query Example" %}

```sql
SELECT
  service_hierarchical_state_machine_id,
  name,
  new_user_initial_state,
  returning_user_initial_state,
  terminal_state
FROM service_hierarchical_state_machines
ORDER BY created_at DESC;
```

{% endtab %}
{% endtabs %}
