Webhook

class Webhook @JvmOverloads constructor(objectMapper: ObjectMapper = ObjectMapperFactory.default)

Helpers for verifying WorkOS webhook payloads.

This class is independent of com.workos.WorkOS — a webhook handler typically does not have an API key and only needs to validate incoming signatures.

Constructors

Link copied to clipboard
constructor(objectMapper: ObjectMapper = ObjectMapperFactory.default)

accepts an ObjectMapper; the default is the shared SDK mapper.

Types

Link copied to clipboard
object Companion

Constants for webhook signature verification.

Functions

Link copied to clipboard
fun constructEvent(payload: String, signatureHeader: String, secret: String, toleranceMillis: Long = DEFAULT_TOLERANCE_MILLIS): JsonNode

Validate the WorkOS-Signature header against payload and return the parsed event body as a JsonNode. Callers that want a typed view can deserialize the node to a generated model with ObjectMapper.treeToValue, or use constructTypedEvent to do so in a single call.

Link copied to clipboard
fun constructTypedEvent(payload: String, signatureHeader: String, secret: String, toleranceMillis: Long = DEFAULT_TOLERANCE_MILLIS): WorkOSEvent

Verify the signature and return a strongly-typed WorkOSEvent.

Link copied to clipboard
fun createSignature(timestamp: String, data: String, key: String): String

Compute the expected HMAC-SHA256(timestamp.payload) signature.

Link copied to clipboard
fun verifyHeader(payload: String, signatureHeader: String, secret: String, toleranceMillis: Long)

Throws SignatureException if the signature is invalid or expired.