Overview
Client-mode connectors for the Dropbox API v2 that move plant files between the broker and Dropbox. A typical flow writes a shift report, batch record or alarm snapshot as a JSON or CSV file into a plant folder, reads a recipe or configuration file back when a line changes over, watches an inbox folder for files that people drop in (cursor plus longpoll, no polling loop), moves processed files to an archive folder, and hands out a temporary link or a shared link to a report. File requests let technicians and suppliers upload photos, certificates and PDFs into a plant folder without a Dropbox account. Dropbox splits its API over three hosts with different request formats, so the template fileDropboxRestApi.lot holds three connectors:
The connectors carry 38 events (36 POST, 2 GET; 13 writes, no delete). Topics use
storage/dropbox/<object>/<verb>; each response is published on <source topic>/response.
The template was checked against the Dropbox Stone API spec (host, request style, argument fields, required fields, deprecation and latest version of every function) and against a local mock of all three hosts. Without a token, Dropbox answered every packaged function with
400 Error in call to API function "<function>": Invalid authorization value, which names the function, while the same path with a suffix answered 404. With a dummy token every Bearer event answered 401 invalid_access_token. files/list_folder/longpoll and /oauth2/token were also called live and rejected the dummy cursor and app credentials. Nothing has run with a real token yet, so the status stays blocked until an authenticated read and an upload pass.Setup
- In the App Console, create a Scoped access app. Pick App folder to keep the broker inside
/Apps/<app name>/, or Full Dropbox if it must reach existing team folders. Paths in payloads are relative to that root. - Under Permissions, enable the scopes the events need:
account_info.read,files.metadata.read,files.metadata.write,files.content.read,files.content.write,sharing.read,sharing.write,file_requests.read,file_requests.write. Leave out the ones you do not use. - Authorise the app once with
token_access_type=offline(for examplehttps://www.dropbox.com/oauth2/authorize?client_id=<APP_KEY>&token_access_type=offline&response_type=code) and exchange the code at/oauth2/token. Keep the refresh token, app key and app secret in broker secrets (for exampleDROPBOX_REFRESH_TOKEN,DROPBOX_APP_KEY,DROPBOX_APP_SECRET). For a quick test, Generate access token on the app’s settings page gives a short-lived token. - Keep the current access token in a broker secret (for example
DROPBOX_ACCESS_TOKEN) and inject it in a LoT action withGET SECRET. Never retain topics that carry it.
Authentication
Every event onDropboxRestApi and DropboxContentRestApi sends Authorization: Bearer <token> built from the access_token field of the payload:
/oauth2/token returns expires_in 14400 (4 hours). Refresh the token before it expires with OAuthTokenRefresh (storage/dropbox/oauth/token/refresh). That event sends no Authorization header; the app key and secret travel in the form:
FolderLongpoll takes no token at all. Dropbox answers 400 if a longpoll request includes an Authorization header, so DropboxNotifyRestApi sends none.
Payloads
Paths are relative to the app folder or the Dropbox root. The root is
""; every other path starts with / and never ends with /. File ids (id:...) work wherever the reference accepts a path or id. The Dropbox-API-Arg header must be HTTP-header-safe: escape non-ASCII characters and 0x7F as \uXXXX (a standard JSON encoder with ASCII output does this).
Examples
Write a shift report as a JSON file (storage/dropbox/files/upload):
id, rev, size, content_hash). Use "mode": "overwrite" to replace a file, or {".tag": "update", "update": "<rev>"} to replace it only if nobody changed it since that revision.
Read a recipe back on changeover (storage/dropbox/files/download):
Dropbox-API-Result response header. Keep downloads to text and JSON files that fit an MQTT message.
Watch an inbox folder for new files without polling:
-
Get a cursor for future changes (
storage/dropbox/folders/latest-cursor/get): -
Wait for a change (
storage/dropbox/folders/longpoll, no token). The call blocks for up totimeoutseconds plus up to 90 seconds of jitter, then returns{"changes": true}or{"changes": false}, sometimes withbackoff(seconds to wait before the next longpoll): -
When
changesis true, list them (storage/dropbox/folders/list/continue) and store the new cursor from the response:
409 with reset means the cursor expired. Start again with FolderList or FolderLatestCursorGet.
Archive a processed file instead of deleting it (storage/dropbox/files/move):
storage/dropbox/files/temporary-link/get):
storage/dropbox/file-requests/create):
Events
Limits
- Dropbox rate-limits per linked user (per team for team-linked apps) and does not publish the numbers. Above the limit it answers
429with aRetry-Afterheader. Wait that long, and batch work (FolderCreateBatch,CopyBatch,MoveBatch) instead of sending many single calls. FileUploadaccepts up to 150 MiB per file, but keep MQTT payloads small. Larger files need upload sessions, which are not packaged.- On Dropbox Business plans with a data transport limit, upload and download calls count against the team’s monthly allowance. Over the limit Dropbox answers
403invalid_account_type/feature. FolderListreturns at most 2000 entries per page; followhas_morewithFolderListContinue.FolderLongpollaccepts atimeoutfrom 30 to 480 seconds, and the notify connector allows 600 seconds per request.- Temporary links expire after four hours. Temporary upload links last 60 to 14400 seconds.
SaveUrltransfers must finish within 15 minutes.
Not packaged
- Delete-style functions on purpose:
files/delete_v2,delete_batch,permanently_delete,files/tags/remove, shared link revoke and file request delete. Archive files withFileMoveinstead. - Upload sessions (
upload_session/start,append_v2,finish, batch variants) for files over 150 MiB, and binary downloads such as thumbnails, previews,download_zipandexport. - Team (Business) endpoints and the
Dropbox-API-Select-User,Dropbox-API-Select-AdminandDropbox-API-Path-Rootheaders for team spaces. Shared folder membership, Paper, file properties templates, file locking, contacts and account administration. - Webhooks. Dropbox registers webhook URIs in the App Console, not through the API. A receiver would be a separate
ENABLE_SERVERREST_API connector that answers theGETverification by echoingchallengewithin ten seconds and checksX-Dropbox-Signature(HMAC-SHA256 of the body with the app secret). Notifications only carry account ids, so the connector would then callFolderListContinue.FolderLongpollcovers the same need without a public endpoint.
Suggested branches
feat/rest-api-route-dropbox for the broker template and feat/docs-rest-api-dropbox for this page.
