Handle webhook payload versions
Validate the current unversioned webhook envelope by event type, distinguish file version from schema version, and tolerate additive fields safely.
Last reviewed
The current Dosya webhook envelope has no schema-version field. Its stable outer shape is id, type, created, workspace_id, and data; data.version on an upload is the file version, not a payload schema version.

Steps
- Verify the signature over the raw request body, parse JSON, and require top-level string
id, supportedtype, numericcreated, stringworkspace_id, and objectdata. - Accept only the current event types
file.uploaded,file.deleted, andshare.accessed. Route malformed or unsupported input to a durable quarantine rather than guessing at a schema. Attach the event ID only when the top-levelidpassed validation; otherwise record a receiver-generated trace ID. - For
file.uploaded, validatefile_id,name, bytesize, nullablefolder_id, integerversion, and booleanis_new_version. Use that version only for ordering revisions of the named file. - For
file.deleted, validatefile_id,name, and booleanpermanent. A move to trash sendsfalse, while a permanent file or folder purge sendstruefor each erased file. - For
share.accessed, requireshare_id, sensitivetoken,accessed_at, and anaccess_typeofview,download, ordownload_all. A bundleviewcan have bothfile_idandfolder_idset tonull; validate the identifiers allowed by that access type instead of requiring one globally. Do not write the token to diagnostics. - Ignore additional fields your consumer does not need, then test with one extra property and one missing required property. The additive sample should process, while malformed input should be quarantined visibly without a partial side effect.
Because there is no schema version to route today, code that requires payload.version will reject every valid Dosya event. Branch by type and keep event-specific validation isolated so a future contract can be added deliberately.

Expected result
Current payloads pass type-specific validation, additive properties do not break processing, and data.version remains a file revision number. Malformed events fail visibly without leaking the share token or applying partial work.
Every payload reports an unknown version. Remove the top-level schema-version requirement; no such field is emitted in the current implementation.
A new field causes rejection. Change strict object equality to required-field validation while retaining type checks for the fields your consumer uses.
Related guides
Was this helpful?
Loading helpfulness results…
Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.
Questions and replies
Ask about the steps in this guide. Questions are reviewed before publication.
Keep account details, credentials and private files out of public questions. Use private support for those.
Loading questions…
Sign in to your Dosya account to ask a question.