# Operator Lists

One row per list your operator (or one of its sub-operators) has created in Monta, for example the Hub Lists that
group your sites or charge points by product. A list can hold one type of entity (see `list_type`). The members of
each list are in [Operator List Items](/docs/operator_list_items).

Deleted lists stay in the table with `deleted_at` set. Filter on `deleted_at is null` to get the lists that are in
use.

**SQL:** `operator_lists`

## Schema

| Column Name                | Data Type     | Description                                                                                                  |
|:---------------------------|:--------------|:-------------------------------------------------------------------------------------------------------------|
| **Primary ID**             |               |                                                                                                              |
| id                         | INTEGER       | Primary key of the list                                                                                      |
| **Other IDs**              |               |                                                                                                              |
| operator_id                | INTEGER       | The operator that owns the list. References `operators.id`                                                   |
| created_by_user_id         | INTEGER       | The user who created the list, if known                                                                      |
| **Timestamps**             |               |                                                                                                              |
| created_at                 | TIMESTAMP_NTZ | When the list was created                                                                                    |
| updated_at                 | TIMESTAMP_NTZ | When the list was last updated                                                                               |
| deleted_at                 | TIMESTAMP_NTZ | When the list was deleted; empty while the list is in use                                                    |
| **Filters**                |               |                                                                                                              |
| is_main_operator_match     | BOOLEAN       | True if the list belongs to your main operator                                                               |
| is_parent_operator_match   | BOOLEAN       | True if the list belongs to an operator that has your main operator as its parent                            |
| **Attributes**             |               |                                                                                                              |
| name                       | VARCHAR       | Name of the list                                                                                             |
| description                | VARCHAR       | Free-text description of the list; may be empty                                                              |
| source                     | VARCHAR       | How the members are managed: `MANUAL` (picked by hand) or `FILTER` (kept in line with a saved filter)        |
| list_type                  | VARCHAR       | The one entity type the list can hold: `user`, `team`, `charge_point`, `charge_points_public`, `site`, `charge_key` or `vehicle`. Empty if the list is not limited to one type |
| item_expiry_days           | INTEGER       | Default lifetime in days (1-365) of members added to the list; empty means members never expire              |

## Data inclusion criteria
- Lists owned by your main operator or by one of its sub-operators (`operators.id = operator_id`)

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

## Alignment
### Monta API
- Aligns with Monta API [get/operator-lists](https://developer.monta.com/api/v1/operator-lists/get) endpoint
- The table does not include the API's `itemCount` and `itemCounts` (count the rows in `operator_list_items` instead), the saved filter (`filterDefinition`), or the sync fields (`syncMode`, `lastSyncedAt`, `lastSyncStatus`, `pendingSyncRun`)
- The table also returns deleted lists; see `deleted_at`
