Publish¶
- Summary: The publish API is used to publish data from the devices to the middleware. To access this API, the device API key obtained after device registration must be used.
Request¶
Endpoint:
https://localhost/entity/publishMethod:
POSTSecurity Scheme: Device credentials
Required Headers:
Header Name Description to Name of the device to which the message is being published subject Subject of the message, e.g. temperature,logs,errors, etc.message-type Either of public,protected,privateordiagnosticsBody: The message from the device that conforms to the schema specified during registration
Example Request:
curl -ik -X POST \ https://localhost/entity/publish -H 'Content-Type: application/json' \ -H 'id: company/streetlight' \ -H 'apikey: yJv7sxFginCYPHq4v4ji-XTLP-Ya0stw' \ -H 'to: company/streetlight' \ -H 'subject: data' \ -H 'message-type: protected' \ -d '{ "ambientLux": "10000", "power": "73.26", "caseTemp": 34.5 }'
Responses¶
202 Accepted- The message has been accepted for publishing
400 Bad RequestIf any of the required headers are missing from the request:
{ "error": "inputs missing from headers" }
If the provided
tois not a valid entity:{ "error": "to is not a valid entity" }
If the provided
message-typeis not valid:{ "error": "message-type is not valid" }
If the provided
tois different fromidandmessage-typeis other thancommand:{ "error": "message-type can only be command" }
If the provided
idis not a valid entity:{ "error": "id is not a valid entity" }