Dropbox API v2 bindings for document workflows and agents: list and search files, read any file as text (Paper docs export to Markdown), binary-safe downloads with Range chunking, uploads with chunked upload sessions and content-hash checks, folders, moves, copies, deletes, revisions, batch jobs, shared links, cursor-based change sync with longpoll, and signed webhooks.
Credentials come from context by default, or per call from opts:
dropbox.access.token- a short-lived (about 4 hours) access tokendropbox.refresh.token+dropbox.app.key(+dropbox.app.secret)- an offline refresh token; access tokens are minted and cached for the run
Team apps add dropbox.select.user / dropbox.select.admin (a team
member id) and dropbox.path.root (team space or a namespace).
Namespaces
::dropbox::auth- credential resolution and the per-run token cache::dropbox::oauth-authorize-url(PKCE, offline),exchange-code, refresh, revoke::dropbox::api- RPC and content requests,Dropbox-API-Arg,HttpError,is-retryable::dropbox::files- list, search, metadata, folders, move, copy, delete, restore, revisions, batches::dropbox::content-read-document, download (Range, chunked), export, temporary links,content-hash::dropbox::upload- single uploads and upload sessions::dropbox::sharing- shared links::dropbox::sync- cursors,sync-changes, longpoll::dropbox::webhooks- challenge echo, signature verification, payload parsing::dropbox::users- current account, space usage, team-space path root
Every function has an options arity taking an opts Map. API
arguments use Dropbox's own snake_case names (recursive, limit,
include_deleted, autorename, ...); the package's own keys
(token, refresh-token, app-key, app-secret, select-user,
select-admin, path-root, retry) are handled by ::dropbox::api.
Quick start
::files ::dropbox::files
::content ::dropbox::content
entries ::files/list-all("/Reports", {recursive: true}, 500)
doc ::content/read-document("/Reports/Q3 plan.paper", "markdown")
doc.text
Values
API_URL
API_URL: Str "https://api.dropboxapi.com/2"
AUTHORIZE_URL
AUTHORIZE_URL: Str "https://www.dropbox.com/oauth2/authorize"
CONTENT_URL
CONTENT_URL: Str "https://content.dropboxapi.com/2"
FOLDER_MIME
FOLDER_MIME: Str "inode/directory"
NOTIFY_URL
NOTIFY_URL: Str "https://notify.dropboxapi.com/2"
PAPER_MIME
PAPER_MIME: Str "application/vnd.dropbox.paper"
TOKEN_URL
TOKEN_URL: Str "https://api.dropboxapi.com/oauth2/token"
Functions
base-mime
fn (content-type: Str?): Str?
A Content-Type without parameters, lowercased: "text/plain; charset=utf-8" becomes "text/plain".
Example
::dropbox/base-mime("text/plain; charset=utf-8") // "text/plain"
compact
fn (arg: Map): Map
Drop null values from an argument Map (Dropbox arguments never carry JSON null for unset fields).
Example
::dropbox/compact({path: "/a.txt", rev: null}) // {path: "/a.txt"}
content-text
fn (content: Map): Str
The text of a FileContent: its text, or the UTF-8 decoding of
bytes (invalid sequences become U+FFFD).
Example
::dropbox/content-text({text: "hello", bytes: Bytes("hello")}) // "hello"
::dropbox/content-text({text: null, bytes: Bytes("hi")}) // "hi"
create-folder of ::dropbox::files/create-folder
fn (path: Str): Map
fn (path: Str, opts: Map): Map
POST files/create_folder_v2 - create a folder (and any missing parents).
Returns its metadata. Options: autorename (pick a free name instead of
failing on a conflict). A 409 path/conflict/folder means it already
exists.
Example
folder ::dropbox::files/create-folder("/Reports/2026")
folder.id
// Pick a free name instead of failing on a conflict
copy ::dropbox::files/create-folder("/Reports/2026", {autorename: true})
copy.name
delete-path of ::dropbox::files/delete-path
fn (path: Str): Map
fn (path: Str, opts: Map): Map
POST files/delete_v2 - delete a file or folder (with its contents).
Deleted files can be restored with restore-file within the account's
version-history window. Returns the deleted entry's metadata. Options:
parent_rev (only delete if the file is still at that rev; files only).
Example
deleted ::dropbox::files/delete-path("/tmp/a.txt")
deleted.name
// Only if the file has not changed
::dropbox::files/delete-path("/tmp/b.txt", {parent_rev: "a1c10ce0dd78"})
download of ::dropbox::content/download
fn (path: Str): ::dropbox/FileContent
fn (path: Str, opts: Map): ::dropbox/FileContent
POST files/download (content host) - a file's exact bytes as a
FileContent, with its metadata from Dropbox-API-Result. Files
larger than http.max-response-bytes are fetched again in Range
chunks (download-chunked). Export-only files (Paper docs) fail with
409 unsupported_file: use read-document or export.
Options: rev (a specific revision), range: {start, end}
(inclusive; end null for the rest) for a partial download,
chunk-size for the chunked fallback, plus credentials.
pdf ::dropbox::content/download("/Reports/Q3.pdf")
pdf.mime-type // "application/pdf"
pdf.bytes // exact bytes
pdf.file.rev
entry-tag
fn (entry: Map): Str?
The .tag of a metadata entry: "file", "folder" or "deleted"
(null when absent).
Example
::dropbox/entry-tag({".tag": "file", name: "a.txt"}) // "file"
file-extension
fn (name: Str?): Str?
The lowercased extension of a file name without the dot ("Q3.Plan.PDF"
gives "pdf"), or null.
Example
::dropbox/file-extension("Q3.Plan.PDF") // "pdf"
::dropbox/file-extension(".bashrc") // null
get-metadata of ::dropbox::files/get-metadata
fn (path: Str): Map
fn (path: Str, opts: Map): Map
POST files/get_metadata - metadata for a file or folder by path, id or
rev:. Options: include_deleted (return metadata for a deleted
entry instead of a 409 path/not_found), include_media_info,
include_has_explicit_shared_members. The root folder has no metadata.
meta-data ::dropbox::files/get-metadata("/Reports/Q3.pdf")
meta-data.rev
is-blank
fn (value: Any): Bool
True for null, "", and whitespace-only strings (context placeholders
wire "" for unset env vars).
Example
::dropbox/is-blank(" ") // true
::dropbox/is-blank("report") // false
is-deleted
fn (entry: Map): Bool
True for a deleted metadata entry (from list_folder with
include_deleted, or a sync delta).
Example
::dropbox/is-deleted({".tag": "deleted", name: "a.txt"}) // true
is-exportable
fn (entry: Map): Bool
True for a file Dropbox cannot download directly but can export
(is_downloadable: false with export_info.export_as set): Paper docs
and cloud docs such as Google Docs stored in Dropbox.
Example
::dropbox/is-exportable({is_downloadable: false, export_info: {export_as: "markdown"}}) // true
::dropbox/is-exportable({is_downloadable: true}) // false
is-file
fn (entry: Map): Bool
True for a file metadata entry.
Example
::dropbox/is-file({".tag": "file", name: "a.txt"}) // true
is-folder
fn (entry: Map): Bool
True for a folder metadata entry.
Example
::dropbox/is-folder({".tag": "folder", name: "Reports"}) // true
is-textual-mime
fn (mime-type: Str?): Bool
True when content of this MIME type is text: text/*, JSON, XML, SVG,
JavaScript, YAML, SQL, and +json/+xml types.
Example
::dropbox/is-textual-mime("application/json") // true
::dropbox/is-textual-mime("application/pdf") // false
list-all of ::dropbox::files/list-all
fn (path: Str?): Vec
fn (path: Str?, opts: Map): Vec
fn (path: Str?, opts: Map, limit: Int?): Vec
Every entry under path (all pages), or at most limit (null for
no limit). Options as for list-folder.
files filter(::dropbox::files/list-all("/Contracts", {recursive: true}, 5000), ::dropbox/is-file)
list-folder of ::dropbox::files/list-folder
fn (path: Str?): Map
fn (path: Str?, opts: Map): Map
POST files/list_folder - one page of a folder's entries:
{entries, cursor, has_more}. Pass {recursive: true} for the whole
tree. Follow cursor with list-folder-continue, or use list-all.
page ::dropbox::files/list-folder("/Reports", {limit: 500})
page.entries
mime-type-of
fn (entry: Map): Str
The MIME type for a metadata entry (pure): FOLDER_MIME for folders,
PAPER_MIME for .paper docs, else from the file extension
(application/octet-stream when unknown). Dropbox does not store MIME
types.
Example
::dropbox/mime-type-of({".tag": "file", name: "Q3.pdf"}) // "application/pdf"
::dropbox/mime-type-of({".tag": "folder", name: "Reports"}) // "inode/directory"
normalize-path
fn (path: Str?): Str
Normalise a Dropbox path for an argument (pure). The root is ""
(null, "" and "/" all mean root); ids (id:...), revisions
(rev:...) and namespace paths (ns:...) pass through; other paths
get a leading / and lose a trailing one. Dropbox paths are
case-insensitive and always use /.
::dropbox/normalize-path("Reports/Q3/") // "/Reports/Q3"
::dropbox/normalize-path("/") // ""
::dropbox/normalize-path("id:a4ayc_80_OEAAAAAAAAAYa")
parent-path
fn (path: Str?): Str?
The parent folder of a display path (pure): "/a/b/c.txt" gives
"/a/b", "/c.txt" gives "" (root). Null for ids and the root.
Example
::dropbox/parent-path("/a/b/c.txt") // "/a/b"
::dropbox/parent-path("/c.txt") // ""
::dropbox/parent-path("id:a4ayc_80") // null
read-document of ::dropbox::content/read-document
fn (path: Str): ::dropbox/FileContent
fn (path: Str, format: Str?): ::dropbox/FileContent
fn (path: Str, format: Str?, opts: Map): ::dropbox/FileContent
Read any file as a FileContent with its DocFile attached.
- Paper docs and other export-only files are exported in
format("auto"by default: Markdown when offered, else the file's default export); seeexport-formatfor the names. - Other files are downloaded as stored (
formatis ignored):textis set for textual types (.txt,.md,.csv,.json, ...) andbytesalways holds the exact content. - Folders and deleted entries return an Err.
doc ::dropbox::content/read-document("/Notes/Roadmap.paper", "markdown")
doc.text // Markdown, ready for chunking and embedding
doc.file.version // the rev, for incremental re-indexing
search of ::dropbox::files/search
fn (query: Str): Map
fn (query: Str, opts: Map): Map
POST files/search_v2 - one page of search results: {matches, has_more, cursor?}. Each match has metadata.metadata (the entry)
and match_type; use match-metadata or search-all. Dropbox
returns at most 10,000 matches in total. Results lag recent changes
by a few minutes (the index is eventually consistent).
page ::dropbox::files/search("quarterly plan", {path: "/Reports", file_extensions: ["pdf", "docx"]})
sync-changes of ::dropbox::sync/sync-changes
fn (cursor: Str): ChangeSet
fn (cursor: Str, opts: Map): ChangeSet
Read every page of changes since cursor and return a ChangeSet
with the cursor to use next time. On a 409 reset, relists
opts.path (with the other list-folder options in opts) and
returns reset: true; without opts.path the Err is returned.
::sync ::dropbox::sync
saved-cursor ::sync/get-latest-cursor("/Docs", {recursive: true})
set ::sync/sync-changes(saved-cursor, {path: "/Docs", recursive: true})
upserts ::sync/changed-files(set) // DocFiles to (re)index
deletes ::sync/deleted-paths(set) // lowercased paths to drop
next-cursor set.cursor // store this for the next run
to-doc-file
fn (entry: Map): DocFile
Normalise a Dropbox metadata entry (from get_metadata,
list_folder, search, sync deltas, or the metadata of a write
result) into a DocFile. A {metadata: {...}} wrapper is unwrapped.
Missing fields become null/false.
Example
entry {".tag": "file", id: "id:a4ayc_80", name: "Q3.pdf", path_display: "/Reports/Q3.pdf", size: 1024, rev: "a1c10ce0dd78"}
file ::dropbox/to-doc-file(entry)
file.mime-type // "application/pdf"
file.parents // ["/Reports"]
file.version // "a1c10ce0dd78"
to-doc-files
fn (entries: Vec): Vec
to-doc-file over a Vec of metadata entries.
Example
files ::dropbox/to-doc-files([{".tag": "file", name: "a.txt"}, {".tag": "folder", name: "Reports"}])
map(files, %.name) // ["a.txt", "Reports"]
upload of ::dropbox::upload/upload
fn (path: Str, content: Any): Map
fn (path: Str, content: Any, opts: Map): Map
Upload a file to path and return its metadata. Content up to
opts.session-threshold (default 32 MiB) goes in one request; larger
content (or session: true) uses an upload session.
Options: mode ("add" default, "overwrite", "update" with
rev), rev, autorename, client_modified, mute,
strict_conflict, session, session-threshold, chunk-size,
verify (default true: send content_hash), plus credentials.
meta-data ::dropbox::upload/upload("/Reports/q3.csv", "region,total\nwest,42\n", {mode: "overwrite"})
meta-data.content_hash
Types
DocFile
DocFile type {
provider: Str,
id: Str,
name: Str,
mime-type: Str,
path: Str?,
size: Int?,
modified: Str?,
created: Str?,
parents: Vec,
drive-id: Str?,
web-url: Str?,
version: Str?,
revision-id: Str?,
md5: Str?,
sha256: Str?,
content-hash: Str?,
is-folder: Bool,
is-google-native: Bool,
is-shortcut: Bool,
shortcut-target-id: Str?,
trashed: Bool,
export-formats: Vec,
raw: Map
}
Provider-neutral file metadata, the same field names as
::google::drive/DocFile plus path and content-hash, so a
documents pipeline can treat Drive and Dropbox alike.
Fields
provider-"dropbox"id- Dropbox's stable id (id:...); for deleted entries (which have no id) the lowercased pathname,mime-type(from the extension;inode/directoryfor folders)path-path_display, the display path (/Reports/Q3.pdf)size- bytes (Int); null for foldersmodified-server_modified(when the content last changed on Dropbox)created- always null (Dropbox does not record it)parents- the parent folder's display path, as a one-element Vecdrive-id- the shared folder (namespace) id the item lives in, if anyweb-url-preview_urlwhen Dropbox returned one, else nullversion,revision-id- the file'srev(use as an etag)md5,sha256- always null (Dropbox has neither)content-hash- Dropbox'scontent_hash(see::dropbox::content/content-hash)is-folder,is-google-native(true for export-only files such as Paper docs),is-shortcut(a symlink),shortcut-target-id(its target)trashed- true for deleted entriesexport-formats-export_info.export_optionsraw- the Dropbox metadata as returned
FileContent
FileContent type {
file-id: Str,
name: Str?,
mime-type: Str?,
size: Int,
bytes: Bytes,
text: Str?,
source: Str,
format: Str?,
file: DocFile?
}
Downloaded or exported file content, the same shape as
::google::drive/FileContent. bytes is always the exact response
body (binary safe); text is the UTF-8 decoding when mime-type is
textual, else null.
Fields
file-id- the path or id asked fornamemime-type- the MIME type ofbytes(from the name or export name)size-length(bytes)bytes,textsource-"download","export","range"or"chunked"format- the export format used, else nullfile- theDocFile(from theDropbox-API-Resultheader)