Skip to main content

Devices

A device is a named entity that can be linked to an API key and appears as device_id on GPS data. Devices allow you to distinguish between multiple GPS senders and associate GPS tracks with trips.

Device Fields

FieldTypeDescription
idUUIDDevice ID
namestringHuman-readable name
descriptionstring?Optional description
device_typestring?Free-text type label (e.g. "Truck", "Router")
is_activeboolInactive devices are ignored during resolution
created_attimestampCreation time
updated_attimestampLast update time

Create/Update Input Fields

FieldTypeContextDescription
namestringcreate (required), updateHuman-readable name
descriptionstring?create, updateOptional description
device_typestring?create, updateFree-text type label (e.g. "Truck", "Router")
is_activebool?update onlyInactive devices are ignored during resolution
api_key_idUUID?create, updateLinks the device to an API key. When set, the API key's device_id is updated to point to this device. This enables automatic device-ID resolution on GPS POST -- any GPS point ingested with that API key automatically inherits this device.

REST Endpoints

MethodPathPermissionDescription
GET/v1/devicesdevices:readList devices (paginated)
GET/v1/devices/{id}devices:readGet device by ID
POST/v1/devicesdevices:writeCreate device
PATCH/v1/devices/{id}devices:writeUpdate device
DELETE/v1/devices/{id}devices:deleteDelete device

GraphQL

Queries:

  • devices(page, limit)PaginatedDevices
  • device(id)GqlDevice

Mutations:

  • createDevice(input)GqlDevice
  • updateDevice(id, input)GqlDevice
  • deleteDevice(id)Boolean

The GqlDevice type includes an apiKey field (nullable) resolved via reverse lookup on the ApiKey table.

Create Device

POST /v1/devices
{
"name": "Peplink Router 1",
"description": "On truck Mannheim-01",
"device_type": "Router",
"api_key_id": "optional-api-key-uuid"
}

Passing api_key_id during creation links the device to the specified API key immediately. You can also set or change this later via update.

Assign an API key to a device by updating the API key:

PATCH /v1/api-keys/{keyId}
{
"device_id": "<device-uuid>"
}

Remove the link by setting "device_id": null.

Device-ID Resolution

When a GPS point is ingested via POST /v1/gps, the API resolves a device_id in order:

  1. X-Device-ID header — if present, the API validates the device exists and is_active = true. Any active device is accepted (no ownership check — GPS is system-internal).
  2. API key device_id — the authenticated API key's linked device.
  3. NULL — stored without a device reference if neither source provides one.

Deletion Behaviour

  • Deleting a device sets ApiKey.device_id = NULL (via ON DELETE SET NULL).
  • Deleting a device sets Trip.device_id = NULL (via ON DELETE SET NULL).
  • Historical GPS data retains the orphaned device_id value — this is intentional for audit continuity (no foreign key across databases).
  • Deleting a device does not delete any GPS data.

RBAC Permissions

PermissionDescription
devices:readView devices
devices:writeCreate and update devices
devices:deleteDelete devices