# Operator List Items

One row per member of one of your [Operator Lists](/docs/operator_lists): which site, charge point, team, user, charge key
or vehicle is on which list. A member that is on several lists has one row per list.

Each row points at the member with `entity_type` and `entity_id`. Use `entity_type` to pick the table to join to (see
the table below). For a Hub List of locations, the `entity_type` is `site` and `entity_id` joins to
`charge_point_sites.id`.

**SQL:** `operator_list_items`

## Schema

| Column Name                | Data Type     | Description                                                                                                  |
|:---------------------------|:--------------|:-------------------------------------------------------------------------------------------------------------|
| **Primary ID**             |               |                                                                                                              |
| id                         | INTEGER       | Primary key of the membership row                                                                            |
| **Other IDs**              |               |                                                                                                              |
| list_id                    | INTEGER       | The list the member is on. References `operator_lists.id`                                                    |
| entity_id                  | INTEGER       | Id of the member, in the table given by `entity_type`                                                        |
| added_by_user_id           | INTEGER       | The user who added the member to the list, if known                                                          |
| **Timestamps**             |               |                                                                                                              |
| created_at                 | TIMESTAMP_NTZ | When the member was added to the list                                                                        |
| expires_at                 | TIMESTAMP_NTZ | When the membership expires; empty means it never expires                                                    |
| **Attributes**             |               |                                                                                                              |
| entity_type                | VARCHAR       | What kind of member the row points at: `site`, `charge_point`, `charge_points_public`, `team`, `user`, `charge_key` or `vehicle` |
| added_via                  | VARCHAR       | How the member was added: `MANUAL` (by hand) or `SYNC` (by the list's saved filter)                          |

### Joining a member to its table

| entity_type            | entity_id references                                                                                                   |
|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------|
| `site`                 | `charge_point_sites.id`                                                                                                |
| `charge_point`         | `charge_points.id`                                                                                                     |
| `charge_points_public` | The id of a charge point on the public network. `charge_points` holds your own charge points, so a public charge point may not be in it |
| `team`                 | `teams.id`                                                                                                             |
| `user`                 | `users.id`                                                                                                             |
| `charge_key`           | `charge_keys.id`                                                                                                       |
| `vehicle`              | `vehicles.id`                                                                                                          |

## Data inclusion criteria
- Members of the lists in `operator_lists`, so lists owned by your main operator or one of its sub-operators
- Members of deleted lists are included; filter on `operator_lists.deleted_at is null`

## Data flow
| Upstream tables  | Downstream tables |
|:-----------------|:------------------|
| `operator_lists` | ---               |

## Alignment
### Monta API
- Aligns with Monta API [get/operator-lists/{listId}/items](https://developer.monta.com/api/v1/operator-lists/listId/items/get) endpoint
- The API returns the items of one list and one `entity_type` per request; the table has all of them
- The table does not include the API's `label`
