Bird
0
0

You want to design a webhook payload for a "user_deleted" event that includes the user ID and deletion reason. Which JSON payload design is best for clarity and easy parsing?

hard📝 Application Q15 of 15
Rest API - Webhooks and Events
You want to design a webhook payload for a "user_deleted" event that includes the user ID and deletion reason. Which JSON payload design is best for clarity and easy parsing?
A{ "event": "user_deleted", "timestamp": "2024-06-01T17:00:00Z", "data": { "user_id": 456, "reason": "requested by user" } }
B{ "user_deleted": true, "user": 456, "reason": "requested by user" }
C{ "event": "user_deleted", "user_id": 456, "reason": "requested by user" }
D{ "event": "user_deleted", "timestamp": "2024-06-01T17:00:00Z", "user": { "id": 456, "reason": "requested by user" } }
Step-by-Step Solution
Solution:
  1. Step 1: Check for standard webhook fields

    { "event": "user_deleted", "timestamp": "2024-06-01T17:00:00Z", "data": { "user_id": 456, "reason": "requested by user" } } includes event name, timestamp, and a nested data object holding user_id and reason, which is clear and standard.
  2. Step 2: Compare other options for clarity and parsing

    { "user_deleted": true, "user": 456, "reason": "requested by user" } lacks event and timestamp keys properly named. { "event": "user_deleted", "user_id": 456, "reason": "requested by user" } mixes data fields at root level, less organized. { "event": "user_deleted", "timestamp": "2024-06-01T17:00:00Z", "user": { "id": 456, "reason": "requested by user" } } nests reason inside user object, which is less intuitive.
  3. Final Answer:

    { "event": "user_deleted", "timestamp": "2024-06-01T17:00:00Z", "data": { "user_id": 456, "reason": "requested by user" } } -> Option A
  4. Quick Check:

    Standard event + timestamp + data object = { "event": "user_deleted", "timestamp": "2024-06-01T17:00:00Z", "data": { "user_id": 456, "reason": "requested by user" } } [OK]
Quick Trick: Use event, timestamp, and data object for clear payloads [OK]
Common Mistakes:
MISTAKES
  • Omitting timestamp
  • Mixing data fields at root level
  • Nesting unrelated fields inside user

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes