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.

Four panels show validating the current unversioned envelope, branching on the event type, distinguishing file version from schema version, and accepting additive fields.
Four panels show validating the current unversioned envelope, branching on the event type, distinguishing file version from schema version, and accepting additive fields. Open full-size screenshot.

Steps

  1. Verify the signature over the raw request body, parse JSON, and require top-level string id, supported type, numeric created, string workspace_id, and object data.
  2. Accept only the current event types file.uploaded, file.deleted, and share.accessed. Route malformed or unsupported input to a durable quarantine rather than guessing at a schema. Attach the event ID only when the top-level id passed validation; otherwise record a receiver-generated trace ID.
  3. For file.uploaded, validate file_id, name, byte size, nullable folder_id, integer version, and boolean is_new_version. Use that version only for ordering revisions of the named file.
  4. For file.deleted, validate file_id, name, and boolean permanent. A move to trash sends false, while a permanent file or folder purge sends true for each erased file.
  5. For share.accessed, require share_id, sensitive token, accessed_at, and an access_type of view, download, or download_all. A bundle view can have both file_id and folder_id set to null; validate the identifiers allowed by that access type instead of requiring one globally. Do not write the token to diagnostics.
  6. 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.

Reference for “Handle webhook payload versions”: Dosya REST API overview page with Get API Key and View SDKs links.
Reference for “Handle webhook payload versions”: Dosya REST API overview page with Get API Key and View SDKs links. Open full-size screenshot.

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.

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.

    Check the outcome before you retry

    Use these shared checks when a task needs a second look.