CoAP · Study deck
CoAP Method/Multicast Contracts
A room controller wants a lamp on.
Broker Bex is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Map CoAP GET, POST, PUT, and DELETE to compact method codes and expected response-code families.
- Use safe and idempotent method properties to decide what can be retried, cached, or sent by multicast.
- Explain why multicast CoAP requests are Non-confirmable and why replies are unicast responses spread across a Leisure window.
- Capture method, response-code, Location option, Token, and multicast-response evidence for a CoAP API review.
Major section
Start With the Duplicate Command
A lost reply may cause a retry.
- The safe design must show which requests can repeat and which physical actions must happen only once.
- An application programming interface is a defined way for software parts to request work or data; API is its short name.
- A protocol means the shared rules for a message exchange.
Major section
Start With the Duplicate Command (continued)
CoAP means Constrained Application Protocol, a compact web-style message system for small devices.
- This runway does not prove every group or resource design is safe.
- The deeper sections explain method codes, repeat-safe behavior, created-resource locations, multicast response timing, and the evidence each result requires.
- A light switch can safely retry a GET /state, but retrying a badly designed POST /toggle might turn the light back off.
Major section
Overview: Four Methods, Familiar REST Semantics, Compact Codes
Every response carries a Code too, grouped into families.
- Class 2 is success ( 2.05 Content for a GET, 2.01 Created, 2.04 Changed, 2.02 Deleted).
- Class 4 is a client error ( 4.04 Not Found, 4.05 Method Not Allowed, 4.00 Bad Request).
- Safe: it never changes state.
Major section
Overview: Four Methods, Familiar REST Semantics, Compact Codes (continued)
Class 5 is a server error ( 5.00 Internal Server Error, 5.03 Service Unavailable).
- A client can branch on the class alone before it ever parses a payload.
- On the wire, the method names become tiny numeric method codes: GET is 0.01, POST is 0.02, PUT is 0.03, and DELETE is 0.04.
- Success is 2.05 Content with the representation in the payload.
Major section
Practitioner: Safe and Idempotent Decide What You Can Retransmit and Multicast
If the same device receives POST /readings three times without an application record ID, it may store three readings.
- A safe method never changes server state; only GET is safe.
- Deleting twice still ends deleted; retry is safe.
- A duplicated POST may create twice; rely on server dedup.
Major section
Under the Hood: What the Codes Say, and Why Multicast Has No ACK
Response codes carry more than success or failure.
- Multicast changes the messaging layer, not the meaning of the codes.
- A server that has nothing relevant may simply stay silent.
- 2.01 Created Answer to a POST/PUT that made a resource; carries Location options naming the new URI.
Major section
Under the Hood: What the Codes Say, and Why Multicast Has No ACK (continued)
To keep many servers from replying in the same instant and swamping a constrained link, each server waits a random interval within a Leisure period before answering, and its reply is a unicast Non-confirmable message.
- The client therefore has to tolerate anywhere from zero to many responses, correlating each one to its request by the Token.
- The outbound request has one Token and one multicast destination, then the client receives zero, one, or many unicast replies from different source endpoints.
- Idempotent means the resource remains absent; later status may be Deleted or Not Found.
Major section
Retry a Desired State, Then Count Discovery Replies
For a worked method example, assume the lamp starts off.
- A POST that means toggle changes off to on on its first execution, then on to off if the server executes it again as a new operation.
- The compact Code byte carries a class and detail.
Major section
Retry a Desired State, Then Count Discovery Replies (continued)
Message-level duplicate detection helps within its scope, but it does not make every later POST repeat-safe.
- These outcomes explain why the client must interpret response codes before treating a returned body as the requested content.
- This calculation explains the byte value; it does not mean that every successful method returns the same response.
- Created content has its own location, which the client retains from the returned Location options.
Major section
Retry a Desired State, Then Count Discovery Replies (continued)
If their unicast replies are spread over an illustrative 6 s response window, the mean offered response rate is 2 replies per second.
- That average does not guarantee even spacing: random delays can still place replies close together.
- The discovery client must accept content from zero, one or many endpoints and preserve each source address.
- Missing content can also result from loss, scope, sleeping endpoints or access policy.
Deck summary
Key takeaways
A lost reply may cause a retry.
- CoAP means Constrained Application Protocol, a compact web-style message system for small devices.
- Every response carries a Code too, grouped into families.
- Class 5 is a server error ( 5.00 Internal Server Error, 5.03 Service Unavailable).
- If the same device receives POST /readings three times without an application record ID, it may store three readings.
Retrieval practice
Recall check 1 of 3

Broker Bex says: answer from memory, then check your reasoning.
Q1A CoAP client sends GET to a resource that does not exist on the server. What response Code should it expect?
Show answer
Answer: A 4.04 Not Found is the class 4 (client error) response for a resource that does not exist, mirroring HTTP 404.
Retrieval practice
Recall check 2 of 3

Broker Bex says: answer from memory, then check your reasoning.
Q2You want to discover CoAP resources across a subnet with one request. Which message type and method are correct?
Show answer
Answer: A Multicast requests must be Non-confirmable, and GET is the safe, idempotent read used for discovery at /.well-known/core on the All CoAP Nodes multicast address.
Retrieval practice
Recall check 3 of 3

Broker Bex says: answer from memory, then check your reasoning.
Q3A client POSTs a new sensor record and the server assigns its URI. Which response and options best represent success?
Show answer
Answer: C When POST creates a subordinate resource the server assigns, it returns 2.01 Created and reports the new URI through Location options.
Print reference
Answers
Answer key.
- A · 4.04 Not Found is the class 4 (client error) response for a resource that does not exist, mirroring HTTP 404.
- A · Multicast requests must be Non-confirmable, and GET is the safe, idempotent read used for discovery at /.well-known/core on the All CoAP Nodes multicast address.
- C · When POST creates a subordinate resource the server assigns, it returns 2.01 Created and reports the new URI through Location options.