Dropbox webhooks (App Console → your app → Webhooks).
- Verification. When you add the URI, Dropbox sends
GET ?challenge=...; echo the value astext/plainwithX-Content-Type-Options: nosniff(challenge-response). It is not retried. - Notifications.
POSTwith a JSON body naming the accounts that changed:{list_folder: {accounts: ["dbid:..."]}, delta: {users: [12345]}}(delta.usersare numeric user ids, also used by team apps). There is no file data: for each account, run your cursor sync (::dropbox::sync/sync-changes). - Signature.
X-Dropbox-Signatureis the hex HMAC-SHA256 of the raw body keyed with the app secret.verify-signaturechecks it in constant time over::hot::http/raw-bodyand fails closed. Dropbox signs no timestamp, so there is no replay window; a replayed notification only triggers a harmless extra sync. - Timing. Respond within 10 seconds or Dropbox retries with
backoff for about ten minutes and may disable the webhook. Verify,
sendan event per account, return 200, and do the sync in the event handler. Several notifications for one account can arrive close together, so keep the sync idempotent.
Register two handlers on the same path: method: "GET" for the
challenge and the default POST for notifications.
Context Vars
dropbox.app.secret
Values
SIGNATURE_HEADER
SIGNATURE_HEADER: Str "x-dropbox-signature"
Functions
challenge-response
fn (request: Map): ::hot::http/HttpResponse
The response to Dropbox's verification request (pure): 200 with the
challenge query value as a text/plain body and
X-Content-Type-Options: nosniff, or 400 when there is no challenge.
dropbox-verify
meta {webhook: {service: "dropbox", path: "/dropbox/hook", method: "GET"}}
fn (request) {
::dropbox::webhooks/challenge-response(request)
}
parse-notification
fn (request: Map): Notification
Parse a notification body (pure; a webhook request or its decoded body
Map). Unknown shapes give empty lists. Does not check the signature: use
verify-notification.
Example
note ::dropbox::webhooks/parse-notification({list_folder: {accounts: ["dbid:AAH4f99"]}, delta: {users: [12345]}})
note.accounts // ["dbid:AAH4f99"]
note.users // [12345]
verify-notification
fn (request: Map): Notification
fn (request: Map, app-secret: Str): Notification
Verify and parse a Dropbox webhook POST: the Notification, or an Err
when the signature is missing or wrong. The 1-arity form uses the
dropbox.app.secret context variable and fails (halts) when it is
unset, so an unconfigured endpoint never accepts traffic.
HttpResponse ::hot::http/HttpResponse
dropbox-hook
meta {webhook: {service: "dropbox", path: "/dropbox/hook"}, secret-headers: ["x-dropbox-signature"]}
fn (request) {
note ::dropbox::webhooks/verify-notification(request)
cond {
is-err(note) => { HttpResponse({status: 403, body: "bad signature"}) }
=> {
map(note.accounts, (account) { send("dropbox:changed", {account: account}) })
HttpResponse({status: 200, body: ""})
}
}
}
verify-signature
fn (request: Map, app-secret: Str?): Bool
True when the request's X-Dropbox-Signature is the hex HMAC-SHA256
of the raw body (::hot::http/raw-body) keyed with app-secret,
compared in constant time. Fails closed: an empty or null secret, a
missing or malformed header, or a body that was re-serialised all
give false. An explicit app-secret is marked as a secret.
Example
dropbox-hook
meta {webhook: {service: "dropbox", path: "/dropbox/hook"}}
fn (request) {
secret ::hot::ctx/get("dropbox.app.secret")
if(::dropbox::webhooks/verify-signature(request, secret), "accepted", "rejected")
}
Types
Notification
Notification type {
accounts: Vec,
users: Vec,
raw: Any
}
A parsed Dropbox webhook notification.
accounts- account ids (dbid:...) fromlist_folder.accountsusers- numeric user ids fromdelta.usersraw- the decoded body