REST API

Upload files, list contents, and manage your Drive connections programmatically.

Base URL

https://drivewidget.com/api/drive

Authentication

All API requests require your API key passed as a header:

X-API-Key: dw_live_xxxxxxxxxxxxxxxx

Get your key from Dashboard → Settings → API Keys.


Endpoints

Upload a file

POST /api/drive/{connection_id}/upload

Upload a file to your connected Google Drive folder.

Headers

X-API-Key: dw_live_xxx
Content-Type: multipart/form-data

Body (multipart/form-data)

FieldTypeRequiredDescription
fileFileYesThe file to upload
subfolderstringNoUpload into a subfolder (created automatically)
rename_tostringNoOverride the filename

Example

curl -X POST https://drivewidget.com/api/drive/CONN_ID/upload \
  -H "X-API-Key: dw_live_xxx" \
  -F "file=@report.pdf" \
  -F "subfolder=clients/acme"

Response

{
  "file_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms",
  "name": "report.pdf",
  "size": 204800,
  "mime_type": "application/pdf",
  "web_view_link": "https://drive.google.com/file/d/1Bxi.../view",
  "created_at": "2026-02-27T14:32:05Z"
}

List files

GET /api/drive/{connection_id}/files

List all files in the connected folder.

Query parameters

ParamDefaultDescription
limit50Max files to return (max 200)
offset0Pagination offset
qSearch by filename

Example

curl https://drivewidget.com/api/drive/CONN_ID/files?limit=20 \
  -H "X-API-Key: dw_live_xxx"

Response

{
  "files": [
    {
      "file_id": "1Bxi...",
      "name": "report.pdf",
      "size": 204800,
      "mime_type": "application/pdf",
      "web_view_link": "https://drive.google.com/...",
      "created_at": "2026-02-27T14:32:05Z"
    }
  ],
  "total": 42,
  "limit": 20,
  "offset": 0
}

Download a file

GET /api/drive/{connection_id}/files/{file_id}/download

Returns the file as a binary stream with appropriate Content-Type headers.

Example

curl -o report.pdf \
  https://drivewidget.com/api/drive/CONN_ID/files/FILE_ID/download \
  -H "X-API-Key: dw_live_xxx"

Delete a file

DELETE /api/drive/{connection_id}/files/{file_id}

Permanently deletes the file from Google Drive.

Example

curl -X DELETE \
  https://drivewidget.com/api/drive/CONN_ID/files/FILE_ID \
  -H "X-API-Key: dw_live_xxx"

Response

{ "deleted": true }

Error codes

StatusCodeMeaning
401invalid_api_keyMissing or invalid API key
403forbiddenConnection does not belong to your account
404not_foundConnection or file not found
413file_too_largeFile exceeds your plan's max upload size
429rate_limitedToo many requests. Check Retry-After header
500drive_errorGoogle Drive returned an error

Rate limits

PlanRequests/minute
Free10
Starter60
Growth120
Pro300
Business1,000

When exceeded, the API returns 429 with a Retry-After header indicating seconds to wait.


SDKs & examples

No official SDK yet — the API is standard REST, easy to call from any language.

Need no-code file collection instead? See Embed Widget → or Client Portals →.

Node.js

const FormData = require("form-data");
const fs = require("fs");
const axios = require("axios");

const form = new FormData();
form.append("file", fs.createReadStream("./report.pdf"));

const res = await axios.post(
  `https://drivewidget.com/api/drive/${CONN_ID}/upload`,
  form,
  { headers: { "X-API-Key": "dw_live_xxx", ...form.getHeaders() } }
);
console.log(res.data.file_id);

Python

import requests

with open("report.pdf", "rb") as f:
    res = requests.post(
        f"https://drivewidget.com/api/drive/{CONN_ID}/upload",
        headers={"X-API-Key": "dw_live_xxx"},
        files={"file": f},
    )
print(res.json()["file_id"])

PHP

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://drivewidget.com/api/drive/{$connId}/upload",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["X-API-Key: dw_live_xxx"],
  CURLOPT_POSTFIELDS => ["file" => new CURLFile("report.pdf")],
]);
$response = json_decode(curl_exec($curl), true);
echo $response["file_id"];

Next steps