decode

Decodes a Resend webhook request body with json, without verifying its signature.

A request that has not been verified may be forged, so receive webhooks with verifyAndDecode, or verify the signature with the Resend SDK's Webhooks.verify before calling this.

Unknown fields are ignored, so an email.* event carrying fields these models do not declare still decodes. Only email.* events are supported: Data requires email_id and from, which other event families (such as contact.* and domain.*) do not send, so their payloads throw kotlinx.serialization.MissingFieldException. An endpoint subscribed to other events should read type first, for example with json.parseToJsonElement(body).jsonObject["type"], and decode only email.* ones.

Return

the decoded message

Parameters

body

the raw JSON request body

Throws

kotlinx.serialization.SerializationException

if body is not a valid webhook payload