Overview
The Device Enrollment Edge Function manages the complete device lifecycle: generating enrollment tokens, validating devices, and integrating with Tailscale for network access. Endpoint:/functions/v1/device-enrollment
Authentication: Required (Authorization header with Supabase JWT)
Actions
Create Pending Device
Admin action to create a pending device for a user with pre-configured Tailscale auth key. Action:create_pending_device
Target user ID (defaults to authenticated user)
Organization ID
Device name (defaults to “Pending Device”)
Device type:
laptop, desktop, mobile, tablet, windows, macosOperating system (max 50 chars)
Optional Tailscale auth key (uses org config if not provided)
Whether device was created
UUID of created device
Token for device enrollment (share with user)
Token expiration timestamp (24 hours)
Example Request
Generate Token
User-initiated action to generate an enrollment token for their new device. Action:generate_token
Device name (defaults to “New Device”)
Device type (defaults to “laptop”)
Operating system
Whether token was generated
Enrollment token (UUID format)
Created device ID
Token expiration (24 hours from now)
Whether Tailscale auth key is configured
Enroll Device
Silent enrollment when device provides its fingerprint. Action:enroll
Unique device fingerprint (alphanumeric with hyphens, max 100 chars)
Device name
Device type
Operating system
Enrollment success status
Device ID (existing or newly created)
Device status:
active or existing statusResult message
Example Request
Verify Token
Validates an enrollment token and returns Tailscale configuration. Action:verify
Enrollment token from generate_token or create_pending_device
Device type to update
Device fingerprint
Validation success
Device ID
Device name from registration
Organization name
Tailscale authentication key for device setup
Tailscale tags to apply (e.g.,
["tag:prod"])Tailscale ACL group
Token expiration timestamp
Example Request
Check Tailscale Status
Checks if a device has successfully connected to Tailscale network. Action:check_tailscale_status
Device ID (passed via this field for compatibility)
Request success
Device status
Whether device is connected to Tailscale
Tailscale hostname (if connected)
Tailscale IP address (if connected)
Input Validation
Device Name
- Type: String
- Length: 1-100 characters
- Required for most actions
Device Type
- Type: String
- Allowed values:
laptop,desktop,mobile,tablet,windows,macos - Validates against whitelist
Operating System
- Type: String
- Length: 1-50 characters
Fingerprint
- Type: String
- Pattern: Alphanumeric with hyphens (
[a-zA-Z0-9-]+) - Length: Max 100 characters
- Must be unique per user
TypeScript Interfaces
TypeScript
Device Statuses
pending- Device created but not enrolledactive- Device enrolled and activeinactive- Device deactivatedrevoked- Device access revoked
Trust Levels
low- Default for pending devicesmedium- Silent enrollment without Tailscalehigh- Enrolled with Tailscale verification
Audit Events
All actions are logged todevice_events and audit_logs tables:
pending_device_createdenrollment_initiatedenrolledtoken_validatedtailscale_connected
Error Responses
Error message
Authorization header required- Missing authInvalid device name- Name validation failedInvalid device type- Type not in allowed listToken inválido o expirado- Invalid or expired tokenNo Tailscale auth key configured- Missing Tailscale config
Related Tables
devices- Device recordsdevice_events- Device activity logorganization_tailscale_config- Tailscale configuration per org