Zero-touch enrollment for company-owned Android
For this first iteration, all zero-touch-enrolled Android hosts land in "Unassigned" — there's no per-fleet routing yet (tracked separately in #51479)
Goal
| User story |
|---|
| As an IT admin managing Android devices used by my Android app dev team, |
| I want to ship new Android devices to devs and have them automatically enroll in Fleet when they're first booted |
| so that I can make sure these devices are managed. |
Changes
Product
- [x] UI changes: Figma wireframes
- [x] CLI (fleetctl) usage changes: No changes.
- [x] YAML changes: No changes.
- [x] REST API changes: https://github.com/fleetdm/fleet/pull/51970
- [x] Fleet's agent (fleetd) changes: No changes.
- [x] Fleet server configuration changes: No changes.
- [x] Exposed, public API endpoint changes: No changes.
- [x] fleetdm.com changes: No changes.
- [x] GitOps mode UI changes: No changes.
- [x] GitOps generation changes: No changes.
- [x] Activity changes: No changes.
- [x] Permissions changes: No changes.
- [x] Changes to paid features or tiers: Fleet Premium only
- [x] My device and fleetdm.com/better changes: No changes.
- [x] Usage statistics: No changes.
- [x] Other reference documentation changes: No changes
- [ ] First draft of test plan added
- [ ] Once shipped, requester has been notified
- [x] Once shipped, dogfooding issue has been filed: https://github.com/fleetdm/fleet/issues/55170
Engineering
Use enterprises.enrollmentTokens.create(). The difference is just the parameters you pass:
// Current (line 614-621):
token := &androidmanagement.EnrollmentToken{
// Default duration is 1 hour
OneTimeOnly: true,
}
// Zero-touch would be:
token := &androidmanagement.EnrollmentToken{
Duration: "31536000s", // e.g. 1 year
OneTimeOnly: false, // reusable across multiple devices
AllowPersonalUsage: "PERSONAL_USAGE_DISALLOWED", // zero-touch = company-owned only
}
-
[ ] Test plan is finalized
-
[x] Contributor API changes: No changes
-
[ ] Feature guide changes: TODO
- Document the fact that if the reseller enters the device info incorrectly into the zero-touch portal, then it will not be recognized by Google and won't be booted up with zero-touch enrollment. If this happens, link them to the form which allows them to input the correct info which allows it to show up in the zero-touch portal.
- Also document that EUA is out of scope for this version (many customers use EUA and idp variables for their certs and this will block them from it). Zero-touch intentionally bypasses end-user authentication (RequiresEnrollOTAAuthentication) because there is no browser-based IdP flow during zero-touch provisioning (see here)
-
[x] Database schema migrations:
CREATE TABLE `android_zero_touch_tokens` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`team_id` INT UNSIGNED DEFAULT NULL,
`token_name` VARCHAR(255) NOT NULL, -- AMAPI resource name (for revocation)
`token_value` VARCHAR(1024) NOT NULL, -- the actual token
`expires_at` DATETIME(6) NOT NULL,
`created_at` DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`updated_at` DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (`id`),
UNIQUE KEY `idx_zt_team_id` (`team_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
| Column | Purpose |
|---|---|
| team_id | NULL = no team (default fleet). Unique key ensures one token per team. |
| token_name | AMAPI resource name. Needed if we ever want to call enrollmentTokens.delete() to revoke. |
| token_value | What goes into EXTRA_ENROLLMENT_TOKEN in the DPC extras JSON. |
| expires_at | From AMAPI's expirationTimestamp. Fleet can warn when approaching expiration. |
The DPC extras JSON is computed on the fly from token_value.
- [ ] Load testing: Not required. Token creation is an admin action done once (or rarely on regeneration). No per-device or periodic load.
- [ ] Pre-QA load test: None
- [ ] Load testing/osquery-perf improvements: None
ℹ️ Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".
Risk assessment
- Requires testing in a hosted environment: No. A token is generated locally via AMAPI and the DPC extras JSON is pasted into the zero-touch portal creating a configuration to a local fleet instance. The portal and AMAPI will then work against a local fleet instance
- Requires load testing: NO
- Risk level: LOW
- Risk description: N/A
Test plan
Make sure to go through the list and consider all events that might be related to this story, so we catch edge cases earlier.
Core flow
- On a Fleet Premium instance with Android MDM turned on, go to Settings > Integrations > Mobile device management (MDM). Verify the Android zero-touch section renders with a Setup button.
- Click Setup. Verify the page (
/settings/integrations/mdm/android-zero-touch) matches the Figma wireframes: title, Back to MDM link, Android zero-touch portal link, the "hosts will automatically enroll to the Unassigned fleet" note, the DPC extras code block, the copy button, and the "Select Add configuration…" instructions. - Verify the token is generated on first page load: one row in
android_zero_touch_tokens(team_idNULL,global_or_team_id0,token_name=enterprises/<id>/enrollmentTokens/<...>,expires_atfar in the future), and the AMAPI token hasoneTimeOnly: false,allowPersonalUsage: PERSONAL_USAGE_DISALLOWED,policyName= the default policy, andadditionalData={"fleet_id":null}. - Navigate away and back (and reload). Verify the same DPC extras JSON is shown, no second row is written, and no second AMAPI token is created.
- Copy the DPC extras with the copy button. Verify the clipboard content is valid JSON and matches what's displayed.
- In the Google zero-touch portal, create a configuration: Android Device Policy as the EMM DPC, paste the copied JSON into DPC extras, fill in company name / support email / support phone, and set it as the account's default configuration. Apply it to the test device.
- Factory reset the registered test device and boot it with network access. Do not scan a QR code or take any manual enrollment action. Verify it provisions itself: the configured company name and contact info are shown during setup, Android Device Policy installs, and enrollment completes with no human interaction.
- Verify the device ends up fully managed (company-owned), not a work profile on a personal device — no option to add a personal account, personal usage disallowed.
- In Fleet, verify a new host appears in Unassigned, platform Android, MDM status enrolled, marked company-owned (not personal/BYOD), with host details populated (serial, model, OS version, storage, etc.).
- Verify the fleet's settings land on the host: setup experience software, configuration profiles, certificates, and OS settings (see the sections below).
Setup experience, software, and end user authentication
- [x] Configure setup experience software for Unassigned before enrolling. Verify the apps install automatically after zero-touch enrollment and appear in the host's activity as setup experience installs.
- [x] Verify the host's self-service software list is correct after enrollment.
- [x] Verify enrollment succeeds when Unassigned has no setup experience software configured (no stuck/erroring job).
- [x] With end user authentication (EUA) turned on, run a zero-touch enrollment. Zero-touch tokens carry no
idp_uuidand skip the EUA check that the QR/BYOD token endpoint enforces, so the device enrolls with no IdP prompt. Confirm with product that bypassing EUA is intended, and verify the host has no IdP-derived "Used by" value and that the display name falls back to the device-derived name.
Profiles and certificates
- [x] Verify configuration profiles scoped to Unassigned apply after enrollment and reach Verified, including label-scoped profiles.
- [x] Verify profiles using
$FLEET_VAR_HOST_*host variables resolve with the zero-touch host's values. - [x] Verify certificates are issued at enrollment and show up under host details > certificates.
- [x] Add a profile after the host is enrolled. Verify it applies.
Host re-enrollment
- [x] Factory reset an already-enrolled zero-touch host and let it re-provision. Verify the same host record is reused (stable
enterprise_specific_id), no duplicate host is created, host details refresh, setup experience software re-installs, certificates are re-issued, and profiles re-apply. - [x] Delete the host in Fleet, then factory reset and let it re-enroll. Verify the host comes back cleanly (see fleet assignment below).
- [x] Use Host details > Actions > Turn off MDM on a zero-touch host. For a company-owned device this issues an AMAPI device delete, which factory resets the device — and because the zero-touch configuration still applies, the device re-provisions and re-enrolls on the next boot. Verify that behavior and confirm with product that it's expected (a zero-touch device can't be unenrolled from Fleet alone; the portal configuration has to be removed first).
- [x] Run Wipe and Lock on a zero-touch host, then let the device re-provision. Verify the host state in Fleet is correct afterward.
Host re-enrollment when the fleet has changed
- [x] Transfer the zero-touch host to fleet "A", then factory reset and let it re-enroll. Prior-fleet memory (
android_devices.team_id) takes precedence over the token'sfleet_id: null, so the host should return to A, not Unassigned. Confirm with product that this is the expected behavior for this iteration. - [x] Transfer to "A", delete the host, then factory reset and re-enroll. The
android_devicesrow survives host deletion, so the host returns to "A". Same mechanism as #53076 — confirm expected behavior before signing off. - [x] Transfer to "A", delete fleet A, then re-enroll. The FK is
ON DELETE SET NULL, so the host should land in Unassigned. - [x] After the host lands back in "A", verify A's profiles/software/OS settings apply — not Unassigned's.
Token lifecycle and portal configuration
- [x] Turn Android MDM off. Verify
android_zero_touch_tokensis emptied, the MDM settings section falls back to the "first turn on Android MDM" card, and the command palette entry disappears. - [x] Turn Android MDM back on and open the page. Verify a new token is generated and the DPC extras differ from the pre-disable value.
- [x] Leave the stale DPC extras in the zero-touch portal and factory reset a device. Verify the failure mode on the device (enrollment error, no silent half-enrollment), that nothing lands in Fleet, and document the on-device error so it can go in the guide.
- [x] Verify the old token is actually dead after Android MDM is turned off — Fleet deletes the local rows but does not call
enrollmentTokens.delete, so confirm enterprise deletion invalidates it on Google's side. - [x] Verify enrolling two (or more) devices from the same configuration works — the token is reusable (
oneTimeOnly: false). - [x] Transfer a device between zero-touch portals / zero-touch accounts, both while enrolled in Fleet and while unenrolled. Verify Fleet's host state is sane in both cases.
UI
- [x] Verify that all UI changes specified in the Figma wireframes are correctly implemented.
- [x] Verify expected UI states: loading spinner while the configuration is fetched,
DataErrorwhen the API fails, premium message on Fleet Free. - [x] Fleet Free: the MDM settings section shows the premium message, and visiting
/settings/integrations/mdm/android-zero-touchdirectly shows the premium message without calling the endpoint. - [x] Android MDM off: the section shows the "turn on Android MDM" card with no Setup button; visiting the page URL directly shows an error state rather than a blank page.
- [x] The API response includes
expires_at, but the page doesn't display it — confirm with design whether expiration should be shown. - [x] Back to MDM returns to the MDM settings page.
- [x] Command palette: "Android zero-touch" appears only on Premium with Android MDM configured, is findable by its keywords, and navigates to the page.
- [x] GitOps mode: verify the page behaves acceptably (note that simply loading it provisions a long-lived enrollment token server-side).
- [x] Verify the code block wraps/scrolls and the copy button works at Fleet's smaller breakpoints.
API
- [x]
GET /api/v1/fleet/android_enterprise/zero_touch_configurationreturns 200 with the DPC extras for a global admin on Premium with Android MDM configured. - [x] Verify the response shape matches the API reference — the design PR (#51970) documents a bare DPC-extras object while the implementation returns
dpc_extras+expires_at. One of the two needs to change. → #54104 - [x] Fleet Free → the standard "requires Fleet Premium" error, and no row is written to
android_zero_touch_tokens. - [x] No Android enterprise configured → 404 with a meaningful message.
- [x] Unauthenticated → 401. Authenticated non-admin → 403 (global maintainer, observer, observer+, GitOps, fleet admin/maintainer/observer). The endpoint is global-admin-only.
- [x] Calling the endpoint twice returns the same token: one DB row, one AMAPI token.
- [x] Two concurrent first-time calls (unique key on
global_or_team_id): verify one wins and the other returns a clean error or the same token — not a raw duplicate-key 500 — and that no orphaned AMAPI token is left behind. → #54106 - [x] Simulate an AMAPI failure during token creation. Verify a meaningful error is returned and no partial row is persisted. (verified in code with a mocked AMAPI client)
- [x] With a MySQL read replica configured, verify the first call creates and reads from the primary (no "not found" flapping right after creation). (verified in code against a lagging test replica)
- [x] Verify the endpoint appears in the list when adding an API-only user, with the same display name, method, and path as the API reference, and that an API-only admin can call it. → #54103
- [x] Verify the token value doesn't leak: not in server logs, not in
fleetctl generate-gitopsoutput, not in debug/support output, not returned by any non-admin endpoint. (It's stored unencrypted inandroid_zero_touch_tokens— worth raising with engineering.)
Permissions
- [x] Verify role restrictions are applied correctly for global roles (admin, maintainer, observer, observer+, GitOps) — only global admin can read the zero-touch configuration.
- [x] Verify role restrictions are applied correctly for fleet-level roles (no access).
Premium gating
- [x] Verify the feature is blocked on Fleet Free in the frontend (section and page show the premium message).
- [x] Verify the feature is blocked on Fleet Free in the backend (API returns the premium error, not just hidden in the UI).
Upgrade / data migration
- [x] Upgrade from the previous release rather than a fresh install. Verify the
android_zero_touch_tokensmigration applies and the page works. - [x] Verify existing Android hosts (QR/BYOD enrolled before the upgrade) are unaffected and stay in their fleets.
Regression: existing Android enrollment paths
This story changed how the team is resolved from enrollment token data for all new Android hosts, so re-test the existing flows:
- [x] BYOD work profile enrollment via QR code with a fleet enroll secret → host lands in that fleet, IdP association is set, display name comes from the IdP account.
- [x] Fully managed (company-owned) QR enrollment → still works and lands in the right fleet.
- [x] An enrollment token created before the upgrade, used after it (legacy
EnrollSecret/IdpUUIDpayload) → still resolves to the right fleet. - [x] Re-enrollment of an existing QR-enrolled host → unchanged behavior.
Feature in isolation (MDM / platform independence)
- [x] Verify the feature works on a fully configured server (Apple, Windows, and Android MDM all enabled).
- [x] Verify the feature works on an Android-only deployment with Apple MDM off and Windows MDM off — page, endpoint, enrollment, profiles, and setup experience.
Supplemental testing
Testing notes
Confirmation
- [x] Engineer: Added comment to user story confirming successful completion of test plan (include any special setup, test data, or configuration used during development/testing if applicable).
- [x] QA: Added comment to user story confirming successful completion of test plan.
- [x] QA: Determined whether this story needs Playwright automation.
- Needs automation: Yes / No
- If yes, filed a follow-up issue in the :help-qa project with status "Needs automation":
@noahtalerman, added ~activation-blocker to this for customer-veeder as they require this before moving forward with their Android migration. Current milestone is okay, but we wouldn't want to go past that for them.
QA Pass with notes on rc-minor-fleet-v4.93.0. Zero-touch enrollment of a real Samsung (Android 16) into Unassigned, re-enrollment after wipe/delete/MDM off-on, profiles/certs/setup experience, API + role matrix, Free, and Android-only (Apple + Windows MDM off). The unreleased issues below are small and don't block the flow.
| # | Area | Case | Result |
|---|---|---|---|
| 1 | Core | Setup page + DPC extras, copy button, token created once and reused across reloads | ✅ |
| 2 | Core | Factory reset → device provisions itself, fully managed, lands in Unassigned, host details populated | ✅ |
| 3 | Setup / profiles | Setup experience apps, profiles with $FLEET_VAR_HOST_*, label include-any / exclude-any / include-all (incl. re-scoping), certificates with variables (mTLS confirmed), profile added after enrollment |
✅ (setup app status: #52617) |
| 4 | Re-enrollment | Factory reset / wipe → same host record; delete host → clean new record; prior-fleet memory (Mobile) and deleted fleet → Unassigned | ✅ |
| 5 | Actions | Lock, clear passcode, wipe, custom commands (reboot, clear app data, lost mode: device results reported back) | ✅ |
| 6 | Token lifecycle | Android MDM off → tokens cleared, UI falls back; back on → new token; stale DPC extras fail with nothing landing in Fleet; two devices from one config; portal transfer (old instance keeps the host until deleted) | ✅ |
| 7 | API | 200 global admin, 401 unauth, 403 for every other global/fleet role, 404 with Android MDM off, idempotent, no token leak (logs, generate-gitops, debug archive) | ✅ |
| 8 | API | Concurrent first-time calls | ❌ #54106 |
| 9 | API | API-only user endpoint list / response shape vs docs | ❌ #54103, #54104 |
| 10 | API | AMAPI failure (no partial row) and read replica (primary reads) | ✅ verified in code |
| 11 | Premium gating | Free: API 402, section + page show the premium message, no request, no palette entry | ✅ |
| 12 | Isolation | Android-only (Apple + Windows MDM off): page, endpoint, enrollment, profiles, setup experience | ✅ |
| 13 | UI | Error state when the endpoint fails | ✅ generic "Something's gone wrong" |
Issues found
| Issue | Origin | Severity |
|---|---|---|
| #54103 Zero-touch endpoint can't be selected for API-only users | This story | Medium |
| #54104 API response doesn't match the REST API reference | This story | Medium |
| #54106 Concurrent first requests fail with "Duplicate entry" and leave orphaned tokens | This story | Low-medium |
| #54102 Fleet admins can open global-admin-only MDM pages by URL (incl. zero-touch) | Released | Low |
| #54105 Company-owned Android hosts show "Pending" after Android MDM is turned off | Released | Low |
| #52617 Setup apps marked "Failed" after installing (added a third trigger seen here) | Released | Medium |
Devices ship and wake enrollment happens by touch fleet gathers them in
@pintomi1989 @kellykroening @kc9wwh @andreasn-work Can you notify your customers on this issue that we shipped this issue?
Notified veeder and yelenam at release. 🖖
notified customer-antonella
notified customer-susanoo
Notified customer-rosner 10/15. Closing
Devices ship and boot token whispers in the cloud fleet gathers them all