Why is my webhook data missing fields?
Usually because the field was never in the payload. A sender may send a thin event carrying only an id and a type, send only the fields that changed, or shape the payload for a different API version than the documentation you read. Check which before changing your code: log the raw payload of one affected event and look for the field. If it is absent, fetch the full object from the sender's API by its id; if it is present, your parser or transform is dropping it.
Absent or empty?
// Tell absent fields from null or empty ones in a raw payload.
// paths use dots, for example 'customer.email'
export function checkFields (payload, paths) {
const absent = []
const empty = []
for (const path of paths) {
let node = payload
let found = true
for (const key of path.split('.')) {
if (node !== null && typeof node === 'object' && key in node) node = node[key]
else { found = false; break }
}
if (!found) absent.push(path)
else if (node === null || node === '') empty.push(path)
}
return { absent, empty }
}Absent, empty, or dropped
- Absent in the raw payload — the sender did not send it. Fetch the object by id from the sender's API when you need it, or subscribe to an event type that carries it.
- Present but
nullor empty — the sender sent it with no value. That is data, not a bug; decide what your code does with it. - Present in the raw payload, missing in your store — your parser or transform drops it. Run the transform against that exact payload and compare.
Stop it reaching your database
Check required fields at the boundary, before anything is written. In Slashbin a Golden Model does that check on every event: anything that does not match lands in the dead-letter queue with the validation error attached, and your downstream code only sees events that passed. See Golden Model.
Need somewhere for the next project's webhooks to land? Slashbin's Free plan takes an account, not a card.
Start Free
(opens in a new tab)