Back up your account data with the API
Use this guide to keep your own copy of everything in your Drum account, for example a nightly backup to your own storage. The script asks Drum for a full export, waits until it is ready, downloads the zip and checks it.
The export is the same one an admin takes from Settings, Data Export in Drum. For every field and code, see the Data exports reference.
Before you begin
You need:
- An API token created by an account admin. Only an admin can take an export, because it holds every record in the account, including pay rates and costs. A token of any other user gets
403 not_authorized. curlandjq, or the HTTP tools of your language.
Keep this token especially safe. It can download all of the account’s data. Store it in your secrets manager, never in the script.
1. Ask for the export
curl -s -X POST "https://app.getdrum.com/api/v1/data_exports" \
-H "Authorization: Bearer $DRUM_API_TOKEN"
Drum answers 202 with the new export:
{"id": 412, "status": "queued", "quota_date": "2026-11-28", "...": "..."}
Keep the id. Two answers need care:
409 data_export_in_progress: an export is already queued or running, perhaps one an admin started from Settings, or one whose response your script lost. The body’sdata_export_idnames it. Use that id and carry on with step 2.429 data_export_limit_reached: the account has already made its export today. An account gets one successful export per day, in the account’s time zone, shared with the web. TheRetry-Afterheader andnext_available_atsay when the next one can start. A backup job can instead download today’s export: list the exports withGET /api/v1/data_exportsand take the newestcompletedone.
2. Wait until it is ready
Read the export about once a minute until status is completed or failed:
curl -s "https://app.getdrum.com/api/v1/data_exports/412" \
-H "Authorization: Bearer $DRUM_API_TOKEN" | jq '{status, total_rows, byte_size, sha256, error_code}'
A small account finishes in under a minute; a large one can take several minutes. Don’t poll faster than once a minute.
If the status is failed, error_code and error_message say why. A failed run does not use up the day’s export, so you can ask again (up to three failed runs a day).
3. Download the zip
curl -s -L -o "drum-export-$(date +%F).zip" \
-H "Authorization: Bearer $DRUM_API_TOKEN" \
"https://app.getdrum.com/api/v1/data_exports/412/download"
The download endpoint answers with a redirect to a signed link that lasts at most 5 minutes, and -L follows it. If the link runs out before the download starts, call the endpoint again for a new one. The signed link works without a token, so do not log it.
4. Check the file
Compare the file with byte_size and sha256 from step 2:
echo "<sha256 from step 2> drum-export-2026-11-28.zip" | sha256sum --check
Then store the zip somewhere safe. Drum deletes its own copy 7 days after the export completes.
The whole job
#!/usr/bin/env bash
set -euo pipefail
API="https://app.getdrum.com/api/v1"
AUTH="Authorization: Bearer $DRUM_API_TOKEN"
# Ask for an export, or take over the one that is already running.
response=$(curl -s -w '\n%{http_code}' -X POST "$API/data_exports" -H "$AUTH")
status=$(tail -n1 <<<"$response")
body=$(sed '$d' <<<"$response")
case "$status" in
202) id=$(jq -r '.id' <<<"$body") ;;
409) id=$(jq -r '.data_export_id // empty' <<<"$body")
[ -n "$id" ] || { echo "$body" >&2; exit 1; } ;;
429) # Today's export exists: download the newest completed one.
id=$(curl -s "$API/data_exports?limit=10" -H "$AUTH" \
| jq -r '[.data_exports[] | select(.downloadable)][0].id // empty')
[ -n "$id" ] || { echo "$body" >&2; exit 1; } ;;
*) echo "Drum answered $status: $body" >&2; exit 1 ;;
esac
# Wait for it.
while :; do
export_json=$(curl -s "$API/data_exports/$id" -H "$AUTH")
case $(jq -r '.status' <<<"$export_json") in
completed) break ;;
failed) jq -r '"Export failed: \(.error_code): \(.error_message)"' <<<"$export_json" >&2; exit 1 ;;
*) sleep 60 ;;
esac
done
# Download and check it.
file="drum-export-$(jq -r '.quota_date' <<<"$export_json").zip"
curl -s -L -o "$file" -H "$AUTH" "$API/data_exports/$id/download"
echo "$(jq -r '.sha256' <<<"$export_json") $file" | sha256sum --check
Run it once a day from a scheduler such as cron. If it runs more often, the second run of the day gets 429 and downloads the export already made.
Read the files
The zip has one CSV file per table, README.txt and manifest.json. A few rules matter when you load the files into another system:
- Money is integer cents, tax exclusive. Times are UTC.
- Files join on Drum ids: a column ending in
_idis theidof a row in another file.manifest.jsonlists every foreign key. - Text that starts with
=,+,-or@(and a few other characters) has one extra apostrophe in front, so a spreadsheet does not run it as a formula. Remove exactly one leading apostrophe to get the stored value. - Attached files are listed in
files.csv, but are not in the zip. - Read columns by their header name. New columns can appear without notice.
See The archive for the full format.