When to use OpenAPI webhooks or callbacks in a freight API
Use a callback to describe a request tied to a parent API operation. Use top-level webhooks for notifications independent of another API call. This describes the HTTP contract; it does not specify which transport events the business must accept.
Choose the contract based on how the notification starts.
The OpenAPI 3.1.1 specification defines callback operations linked to a parent operation and top-level webhooks for independent incoming requests. Document the sender, recipient response, correlation key and applicable payload version. Specify authentication, retries and delivery semantics as explicit operational policies rather than assuming the OpenAPI definition implements them.
A booking response and a standing status feed have different contracts.
A synthetic freight API sends a booking result tied to a submitted booking operation. That result can be described as a callback. A separate standing status feed registered outside the API can be described under webhooks. Both may carry the same shipment reference, but their trigger, accepted response and retry policy can differ.
Test the contract before a partner integrates.
- Check that generated documentation shows the request direction and expected responses.
- Test missing correlation, duplicate delivery and an unsupported schema version.
- A successful receiver response is not proof that the shipment reached a business milestone.