Automating recurring file collection with Dropbox
Collecting the same set of documents on a regular schedule — contractor invoices, student assignments, employee headshots — usually means sending reminders and then chasing down attachments buried in email threads. Dropbox file requests let you structure that work: you create a request tied to a target folder in your account, share a link with anyone (Dropbox account or not), and files land in that folder automatically.
Doing this manually through the file requests page works for one-off requests, but when the same collection cycle repeats monthly or weekly, the API version makes more sense. With the Dropbox API you can create the request, capture the submission URL and request ID programmatically, and integrate it into your existing automation.
Creating a request with the Python SDK
The Dropbox Python SDK makes this a short script. Install dropbox from PyPI, then instantiate a client with your access token and call the file requests API:
import dropbox
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
req = dbx.file_requests_create(title="August invoices", destination="/File requests/August")
print req.url
print req.id
Replace the placeholder access token, then set the title and destination path appropriate for your use case. The destination is relative to your Dropbox root and must start with a slash. The service will create intermediate folders if they don't already exist, provided your token has full account access. If you plan to create many requests over time, it's worth designating a single parent folder to hold them all.
The response includes a request URL you can pass along to any recipient — embed it in automated emails, Slack messages, or wherever your workflow already communicates. Keep the request ID returned in the response; you'll need it to query request status later. For other available properties on the returned FileRequest object, check the SDK documentation.
Once the script does what you need, schedule it with a cron job or a similar scheduler so each cycle runs without manual intervention.
Checking upload status
Submitted files are stored in the folder you designated, just as they would be with a manually created request. To see how many files have arrived for a given request without digging through the folder, call the API again:
import dropbox
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
req = dbx.file_requests_get("YOUR_REQUEST_ID")
print req.file_count
This takes your access token and the request ID from the creation step. Among the returned metadata is the current file_count field, which the sample prints.
Since each file request maps to a normal Dropbox folder, you can also list its contents through the standard files API, not just the file requests endpoint. This example prints the filenames currently in a folder:
import dropbox
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
req = dbx.files_list_folder("/File requests/August")
for f in req.entries:
print f.path_display
The listing approach works for up to 2,000 files, which covers the vast majority of file request use cases. Bear in mind two caveats: multiple file requests may point at the same folder, in which case that folder will contain files from several requests, and anyone with access to the folder can place files there outside the file request system.
If Dropbox already anchors your file workflow, the file requests API replaces a repetitive manual chore with a few lines of reusable code.



