> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Enrollment

> Enroll devices in VPP programs through Connect, and what your backend does after.

A user enrolls a device in a VPP program through Connect. The enrollment attaches to the device and records the user's consent. After that, your backend acts on webhooks.

## Requirements

| Requirement | Detail |
| :- | :- |
| VPP is on | Switch **VPP** on in [Console](https://console.flatpeak.com/settings) > **Settings**. Until then no program is offered and no device can enroll. The [test VPP programs](/docs/energy-api/guides/platform/test-vpp-programs.md) ignore the switch |
| The device is ready | It has `hardware.hardware_id` and its `capabilities`. See the [VPP quickstart](/docs/energy-api/guides/vpp/quickstart.md) |
| `vpp_enabled` is `true` | It defaults to the account switch. Set it to `false` on devices that must never be dispatched: demo units, or models you have not certified for remote control. It does not end an existing enrollment |
| A connected tariff | If the location has none, Connect asks the user to connect one |

## Programs

VPP operators create the programs. Flatpeak offers a device the live programs that match its location, device type, the program's rules, and the finest sampling interval your account declares in the [Console](https://console.flatpeak.com). A paused program shows only to devices already enrolled in it. Read what a device can join with [list VPP programs](/docs/energy-api/reference/vpp-programs/list.md).

Four parts of the program decide what an enrollment commits you to.

| Field | Meaning |
| :- | :- |
| `managed` | `true`: a managed tariff. The VPP operator runs the device with plans, and its tariff replaces the user's. `false`: VPP events only |
| `enrollment.dispatch_test_required` | `true`: the device must deliver a `TEST` event before approval. `false`: no test |
| `telemetry_requirements` | The sampling intervals the device must meet, for state and for its own meter records. The device's `telemetry` group shows the effective duty |
| `terms` | What binds the user and the VPP operator: `rewards`, `opt_out_policy` and `notice_days`. The VPP operator pays the user, and Flatpeak keeps the ledger |

Each entry in `terms.rewards` pays its `rate`, in the program's `currency_code`, on one `basis`: `FIXED` per calendar period, `EVENT` per event delivered in full, `DELIVERED_KWH` per kWh delivered, or `COMMITTED_KWH` per kWh of the device's locked share of an event.

Connect shows the rewards on the Join screen. The enrollment keeps a copy of the `terms` it joined with, under `terms`, and a later change to the program applies only to later enrollments.

## Enroll in Connect

VPP uses the same sessions, launch and callback as the [tariff flow](/docs/energy-api/guides/tariffs/connect.md).

1. [Create a Connect session](/docs/energy-api/reference/connect-sessions/create.md) with the `device_id`. Add `operator_id` to offer one VPP operator's programs only.
2. Start it with `flow` set to `VPP`: `?connect_session=<connect_session_id>&flow=VPP` in a WebView, or `"flow": "VPP"` on the [`session_start`](/docs/energy-api/reference/connect/tariff/start-session) route through the API.
3. If you build your own UI, implement the [VPP pages](/docs/energy-api/reference/connect/vpp/programs.md).

| `flow` | Connect does |
| :- | :- |
| `TARIFF` | Connects the tariff only |
| `VPP` | Connects a tariff if the location has none, then enrolls the device |
| `AUTO` | Picks the flow from the session context |

With `flow=VPP`, a user with an enrollment lands on [VPP summary](/docs/energy-api/reference/connect/vpp/summary.md): review the program, see rewards, skip an event, or unenroll. A user without one lands on [VPP Programs](/docs/energy-api/reference/connect/vpp/programs.md).

## Managed tariffs

A managed tariff is listed on the Programs page, but the user signs up for it with the VPP operator and consents afterwards.

1. The user selects the managed tariff. Connect returns [`session_redirect`](/docs/energy-api/reference/connect/tariff/redirects#operator-sign-up) with `redirect_type` `OPERATOR_SIGNUP`. Open `redirect_url` in the system browser and close Connect. No enrollment exists yet.
2. The user signs up on the VPP operator's site.
3. The VPP operator sends the user back to your app by [universal link](/docs/energy-api/reference/connect/vpp/universal-links.md), with a new Connect session. Start it: Connect shows consent, then creates the enrollment.

[Create a VPP enrollment](/docs/energy-api/reference/vpp-enrollments/create.md) does not accept a managed tariff; it returns `422` `operator_signup_required`.

## After enrollment

Enrollment continues after the Connect session ends.

1. Subscribe to the VPP [events](/docs/energy-api/guides/platform/events.md) in [Console](https://console.flatpeak.com/webhooks) > **Webhooks**.
2. Send [telemetry](/docs/energy-api/guides/vpp/telemetry.md) at the interval the device's `telemetry` group sets.
3. At step `TESTING_DISPATCH`, Flatpeak issues a short `TEST` event. Fetch it, confirm it and deliver it.
4. From `ACTIVE`, follow the device's instructions. See [Dispatch](/docs/energy-api/guides/vpp/dispatch.md).

Every state and step is on [Enrollment states](/docs/energy-api/guides/vpp/enrollment-states.md).

Consent does not expire. `consents` on the device holds what each VPP operator is granted now, and [consent history](/docs/energy-api/reference/vpp-enrollments/consent-history.md) keeps every grant and revocation, each with an ID the VPP operator sees too.

## Unenroll

The user unenrolls in Connect, or you call [unenroll a device](/docs/energy-api/reference/vpp-enrollments/unenroll.md), and the enrollment moves to `LEAVING` at step `UNENROLLING`. The VPP operator then approves the request. It cannot refuse, and the enrollment ends within the `notice_days` of its `terms` at the latest.

Unenroll before you delete a device. [Delete a device](/docs/energy-api/reference/devices/delete.md) returns `409` until the enrollment is `ENDED` or `REJECTED`.

## History

An ended enrollment is kept, and a later enrollment is a separate object. At most one enrollment per device is non-terminal, and that is the current one. [List VPP enrollments](/docs/energy-api/reference/vpp-enrollments/list.md) returns them all, most recent first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.