# Application Users

Contains application user records with associated operator information. 
Combines user application data with operator details to provide comprehensive 
user context including team assignments, permissions, and deletion tracking.
Includes timestamps for audit trails and marketing preferences.

**SQL:** `application_users`

## Schema

| Column Name                              | Data Type     | Description                                                                                  |
|:-----------------------------------------|:--------------|:---------------------------------------------------------------------------------------------|
| **Primary ID**                           |               |                                                                                              |
| id                                       | INTEGER       | Primary key                                                                                  |
| **Other IDs**                            |               |                                                                                              |
| operator_id                              | INTEGER       | Unique identifier for the operator associated with this application user                     |
| user_id                                  | INTEGER       | Unique identifier for the user account                                                       |
| application_id                           | INTEGER       | Unique identifier for the application the user has access to                                 |
| default_team_id                          | INTEGER       | Identifier for the user's default team assignment within the application                     |
| deleted_by_user_id                       | INTEGER       | Identifier of the user who performed the deletion, null if record is active                  |
| **Timestamps**                           |               |                                                                                              |
| created_at                               | TIMESTAMP_NTZ | Timestamp when the application user record was originally created                            |
| updated_at                               | TIMESTAMP_NTZ | Timestamp when the application user record was last modified                                 |
| deleted_at                               | TIMESTAMP_NTZ | Timestamp when the application user record was deleted, null if active                       |
| terms_read_at                            | TIMESTAMP_NTZ | Timestamp when the user last read or acknowledged the terms of service                       |
| operator_deleted_at                      | TIMESTAMP_NTZ | Timestamp when the associated operator was deleted, null if operator is active               |
| application_marketing_emails_accepted_at | TIMESTAMP_NTZ | Timestamp when the user accepted marketing emails for this application, null if not accepted |

## Data inclusion criteria
This table works with `operators` table, requiring that `operator_id` is among the partner's `operators.id` records.

## Data flow 
| Upstream tables     | Downstream tables |
|:--------------------|:------------------|
| `operators` | `users`   |

## Alignment
### Monta API
- Aligns with Monta API [get/users](https://developer.monta.com/api/v1/users/get) endpoint
