# Data model

> What an account contains, how the pieces relate, and what each kind of user (and your
> API token) can see.

![Parklio account structure](/img/diagrams/data_overview.svg)

## Accounts

An **account** is your organization in Parklio. It owns everything else: account users,
API tokens, lots, zones, products and Gateways. For an integration, Parklio provisions
a dedicated API account; see [What you need](/get-started/what-you-need).

## Account users and roles

**Account users** are the people who log in to an account, each identified by an email
address and assigned to one or more lots. Each has one of three roles:

| Role | Can do |
| --- | --- |
| **Super Admin** | Everything in the account: create and delete lots, see every lot, manage all account users and invitations, and create **API tokens**. New lots are assigned to every Super Admin automatically. |
| **Admin** | On the lots assigned to them: update lot details, manage members, groups and tariffs, and see users with the same or a lower role. |
| **Operator** | On the lots assigned to them: work with products and access, and update a lot's or zone's spot counts. Can't create or delete zones, or manage lot share views. |

On the lots they're assigned to, every role can add and manage products, LPR cameras,
operation tokens and lot whitelists, and share access.

Only a Super Admin can create API tokens. See [Authentication](/api/authentication).

### What an API token sees

Requests made with an API token act as the account's **first Super Admin**:

- **Lots and Gateways:** every one in the account.
- **Products, zones, LPR cameras and parking places:** those in the lots that Super Admin
  is assigned to. New lots are assigned to Super Admins automatically, but a Super Admin
  can be removed from a lot ([`DELETE /v2/lots/{id}/managers/{managerId}`](/api/endpoints/lots-remove-lot-manager)),
  and its products then disappear from your token's view. Keep your first Super Admin on
  every lot you integrate with.
- **A product with no zone** isn't visible to any token.

## Lots and zones

A **lot** is a parking location. Its fields include `name`, `address`, `latitude`,
`longitude`, `timezone`, and the occupancy counters `spot_count` and `occupied_count`.

A lot is split into **zones**, for example levels or pricing areas. Each zone belongs to
one lot and has its own `spot_count` and `occupied_count`.

Products and LPR cameras sit in a zone; Gateways belong to a lot.

## Products

**Products** are the hardware you control: barrier, gate, chain, bollard and brain. A
product has a `lot_id` and a `zone_id`. They talk only over Bluetooth, so the cloud
reaches them through a Gateway, and phones reach them directly.

Product types, states and the operations each supports are in
[Products and operations](/concepts/products-and-operations).

LPR cameras are a separate resource, also placed in a zone; see the
[LPR cameras reference](/api/endpoints/lpr-cameras-find-all).

## Gateways

A **Gateway** belongs to a lot. It connects to the Parklio cloud over Ethernet or a mobile
network, and relays commands and status to the products it can reach over Bluetooth.

A Gateway's `status` is `online` while it's connected to the cloud and `offline`
otherwise. Changes arrive as the realtime
[`gateway_status`](/realtime/events#gateway_status) event.

## What's paired where

| Thing | Added to the account by | Where it lives |
| --- | --- | --- |
| Product | The Connect app (pairing) | A zone in a lot |
| Gateway | The Connect app | A lot |
| LPR camera | The API ([`POST /v2/lpr-cameras`](/api/endpoints/lpr-cameras-assign)) | A zone |
| Parking detection (cameras, mapping) | Parklio technicians | A lot and its zones |

The API has no endpoints for pairing products or Gateways.

## Next

- [Products and operations](/concepts/products-and-operations)
- [Access and keys](/concepts/access-and-keys)
