Skip to content

func-api-devices-register-post

Description

Registers a FireFly device with FireFly-Cloud by creating a record in the firefly-devices DynamoDB table. Called by the HW-Reg application during the Cloud Registration step.

The request must include a valid one-time X-Registration-Key header. The function validates the key against the firefly-registration-keys table, then writes the device record (including the email of the user who generated the key as registered_by_email) and deletes the consumed key. Registration is idempotent: if the UUID already exists, the function returns 204 immediately without modifying the existing record.

This endpoint does not require a Cognito JWT — it is authenticated solely by the one-time registration key.

Invocation

Invoked by API Gateway on an HTTP POST /devices/register request.

Sequence Diagram

Sequence Diagram

API Endpoints

MethodPathAuthDescription
POST/devices/registerRegistration key (header)Register a device

Request Headers

HeaderRequiredDescription
X-Registration-KeyYes6-character one-time key generated by POST /registration-keys

Request Body

json
{
  "uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "product_id": "FFC0806-2505",
  "product_hex": "0x08062505",
  "device_class": "controller",
  "public_key": "<base64-encoded uncompressed P-256 point>",
  "registering_application": "Hardware-Registration-and-Configuration",
  "registering_version": "2025.04.01",
  "mcu": { ... },
  "network": [ ... ],
  "partitions": [ ... ]
}
FieldTypeRequiredDescription
uuidstringYesDevice UUID (RFC 4122 format)
product_idstringYesHuman-readable product identifier (e.g. FFC0806-2505)
product_hexstringYesHex product identifier (e.g. 0x08062505)
device_classstringYesDevice class (e.g. controller)
public_keystringYesBase64-encoded uncompressed P-256 ECDSA public key (65 bytes, prefix 0x04)
registering_applicationstringYesName of the application performing registration
registering_versionstringYesVersion of the registering application
mcuobjectYesMCU info (model, revision, cores, cpu_freq_mhz, idf_version, flash_chip_size, flash_chip_speed, flash_chip_mode, psram_size, features)
networkarrayNoNetwork interfaces ([{ "interface": "wifi", "mac_address": "AA:BB:CC:DD:EE:FF" }])
partitionsarrayNoPartition table entries

DynamoDB Record

The function writes the following item to the firefly-devices table:

AttributeDescription
uuidDevice UUID (partition key)
product_idHuman-readable product identifier
product_hexHex product identifier
device_classDevice class
public_keyBase64-encoded P-256 public key
registration_dateISO-8601 timestamp of registration
registering_applicationName of the application that performed registration
registering_versionVersion of the registering application
mcuMCU information object
registered_by_emailEmail of the user who generated the registration key
networkNetwork interfaces (if provided)
partitionsPartition table (if provided)

Response Codes

CodeReason
204 No ContentDevice registered successfully (or already registered)
400 Bad RequestMissing or invalid field, malformed UUID, invalid public key
401 UnauthorizedMissing, invalid, or expired X-Registration-Key
500 Internal Server ErrorUnhandled exception

See the API Reference for full schema documentation.

Deployment

See the deployment workflow documentation for workflow steps, infrastructure dependencies, and failure scenarios.