CoAP Packet Structure

The following diagram shows the structure of a CoAP packet

Version (2 bits) - CoAP version. Always 01 T (2 bits) - Transaction type TKL (4 bits) - Token length Code (8 bits) - Request or response code

Request codes

BinaryCodeType
GET100000001
POST200000010
PUT300000011
DELETE400000100

Response codes

TypeCodeBinary
Created2.01
Deleted2.02
Changed2.04
Content2.05
Bad Request4.00
Unauthorized4.01
Not found (resource)4.04
Method not allowed4.05

Message ID (16 bits) - Unique identifier for the packet. Used for duplicate detection. Token (up to 64 bits) - Used to match a response with a request Options (x bits) - Both requests and responses may include a list of one or more options. Payload Marker (8 bits) - Marks the beginning of the payload. Always 11111111

Example for publishing an event

For this, we are going to show the packet structure of a device publishing an Event to Wia. The packet itself, along with the payload, should be transmitted in hex format.

This shows a POST request (Code: 02) being submitted to the path "events" with the payload structure {"accessToken":"d_sk_abc123","name":"hello-wia","data":"12345"}.

To test with your own device, make a request replacing d_sk_abc123 with your device's access token.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard