Bird
0
0

You need to design a webhook payload that sends multiple event types in one request. Which design is best?

hard📝 Application Q8 of 15
Rest API - Webhooks and Events
You need to design a webhook payload that sends multiple event types in one request. Which design is best?
A{"user_signup":{"id":1},"order_placed":{"order_id":10}}
B{"event":"user_signup,order_placed","data":{"id":1,"order_id":10}}
C[{"event":"user_signup","data":{"id":1}}, {"event":"order_placed","data":{"order_id":10}}]
D{"events":[{"event":"user_signup","data":{"id":1}},{"event":"order_placed","data":{"order_id":10}}]}
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-event payload structure

    Use an array under a key like 'events' to hold multiple event objects.
  2. Step 2: Evaluate options

    {"events":[{"event":"user_signup","data":{"id":1}},{"event":"order_placed","data":{"order_id":10}}]} uses an 'events' array with separate event objects, which is clear and extensible.
  3. Final Answer:

    {"events":[{"event":"user_signup","data":{"id":1}},{"event":"order_placed","data":{"order_id":10}}]} -> Option D
  4. Quick Check:

    Multi-event payload = array of event objects [OK]
Quick Trick: Group multiple events in an array under a key [OK]
Common Mistakes:
MISTAKES
  • Combining event names in one string
  • Using top-level array without key
  • Using event names as keys without event field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes