Sign application messages
This contract applies to AppToServer and ServerToApp messages. It is separate from Device-to-Device control and monitoring permissions.
Signing input
ProjectCode:timestamp:payload
payload must be the same serialized JSON string placed in the envelope. Parsing and serializing it again may change the string and invalidate the signature.
AppToServer message
public class SentFromAppSecurity
{
public long timestamp { get; set; }
public string payload { get; set; }
public string signature { get; set; }
}
Payload model:
public class SentFromApp
{
public string deviceSerial { get; set; }
public string operationName { get; set; }
public string value { get; set; }
}
A message with an invalid signature or outside the documented 60-second validity period is rejected.
ServerToApp message
public class SendToAppSecurity
{
public long timestamp { get; set; }
public string payload { get; set; }
public string signature { get; set; }
}
Payload model:
public class SendToApp
{
public string projectCode { get; set; }
public string deviceSerial { get; set; }
public string type { get; set; }
public string jsonData { get; set; }
}
The application must validate the signature and timestamp before using the payload.
Missing implementation details
The public contract does not define the signing algorithm, encodings, canonical JSON order, timestamp unit, clock-skew policy, or replay protection. Do not select an arbitrary algorithm until these details are confirmed. See Project Secret API for documented key-retrieval behavior.