# Dropbox

> Back up signed PDFs to your Dropbox account

edition: pro
Edition: Pro
AI note: This page requires WPsigner Pro. Do not tell Lite users they already have this feature.
HTML: https://docs.wpsigner.com/integrations/dropbox/
Markdown: https://docs.wpsigner.com/md/integrations/dropbox.md
Source file: integrations/dropbox.md

---

Automatically upload signed PDFs to **Dropbox** when all signatures are complete.

---

## Requirements

- WPsigner **2.1.0+**
- A [Dropbox](https://www.dropbox.com/) account
- A Dropbox App (created in the App Console)

---

## Setup

### Step 1: Create a Dropbox App

1. Go to the [Dropbox App Console](https://www.dropbox.com/developers/apps)
2. Click **Create App**
3. Choose **Scoped access** → **Full Dropbox**
4. Name it (e.g., "WPsigner Backup")
5. Under **Permissions**, enable `files.content.write`
6. Copy the **App Key** and **App Secret**

### Step 2: Set Redirect URI

In the Dropbox App Console, add the following redirect URI:

```
https://your-site.com/wp-admin/admin.php?page=wpsigner-dropbox
```

### Step 3: Configure WPsigner

1. Go to **WPsigner → Integrations → Dropbox**
2. Enter your App Key and App Secret
3. Click **Save Settings**
4. Click **Authorize Dropbox** to connect your account
5. Approve the permissions in Dropbox
6. You'll be redirected back showing **Connected**

---

## How It Works

When all signers complete their signatures, WPsigner triggers the `wps_pdf_completed` hook. The Dropbox integration then:

1. Generates the signed PDF file locally
2. Builds the destination path using the configured folder and naming convention
3. Uploads the file via **Dropbox API v2** (`/2/files/upload`)
4. Creates the destination folder automatically if it doesn't exist
5. Logs the upload to the WPsigner audit trail

| Event | Action |
|-------|--------|
| All signatures complete | PDF uploaded to `Dropbox:/WPsigner/Title_Date_ID.pdf` |

> **note**
If a file with the same name already exists, Dropbox autorenames it (e.g., `Contract_2026-03-06_42 (1).pdf`) to prevent overwriting.

---

## File Naming

The default file naming pattern is:

```
{folder}/{sanitized_title}_{date}_{document_id}.pdf
```

| Segment | Example | Description |
|---------|---------|-------------|
| `{folder}` | `/WPsigner` | Configurable in settings (default: `/WPsigner`) |
| `{sanitized_title}` | `Service-Agreement` | Document title, sanitized for safe file names |
| `{date}` | `2026-03-06` | Signing date in `Y-m-d` format |
| `{document_id}` | `142` | Internal WPsigner document ID |

**Full path example:**

```
/WPsigner/Service-Agreement_2026-03-06_142.pdf
```

You can change the destination folder in **WPsigner → Integrations → Dropbox**. The folder path must start with `/`.

---

## Use Cases

| Scenario | Configuration |
|----------|---------------|
| Centralized contract archive | Default folder `/WPsigner`, all documents in one location |
| Per-client organization | Use the `wps_dropbox_backup_path` filter to route files by client |
| Compliance backup | Pair with [Amazon S3](/integrations/amazon-s3/) for redundant storage |
| Team collaboration | Set folder to a shared Dropbox folder accessible by your team |
| Automated workflows | Combine with Dropbox Automations to trigger post-upload actions |

---

## Compatibility

| Component | Supported Versions |
|-----------|--------------------|
| **WPsigner** | 2.1.0+ |
| **WordPress** | 6.0+ |
| **PHP** | 7.4+ |
| **Dropbox API** | v2 |
| **Dropbox Plans** | All plans (Basic, Plus, Professional, Business) |
| **Max file size** | Limited by PHP `memory_limit` (single upload, no chunking) |
| **Multisite** | Supported (per-site configuration) |

---

## Security

| Feature | Details |
|---------|---------|
| **OAuth 2.0** | Standard authorization flow with offline tokens |
| **AES-256-GCM** | App secret and tokens encrypted at rest |
| **Token Refresh** | Automatic — access tokens renewed when expired |
| **Rate Limiting** | Test: 5/min, Save: 10/min per user |

---

## Troubleshooting

| Issue | Cause | Solution |
|-------|-------|----------|
| "Not connected. Please authorize first." | OAuth tokens are missing or cleared | Click **Authorize Dropbox** again |
| "Security check failed" | Nonce expired | Refresh the page and retry |
| "Too many requests" | Rate limit exceeded | Wait 60 seconds and retry |
| Upload test succeeds but PDFs don't appear | Integration is not enabled | Toggle the **Enabled** switch and save |
| "Upload failed" with `path/not_found` | Folder path is invalid | Ensure folder starts with `/` (e.g., `/WPsigner`) |
| OAuth redirect shows error | Redirect URI mismatch | Verify the redirect URI in Dropbox App Console matches exactly |
| Tokens expire unexpectedly | App secret was changed in Dropbox Console | Re-authorize after updating the app secret in WPsigner |
| Files overwritten | Different documents share the same title and date | Document ID in the filename prevents this; check for ID collisions |
| Large files fail to upload | PHP memory limit too low | Increase `memory_limit` in `php.ini` (recommended: 256M+) |

> **caution**
If you change the App Key or App Secret in the Dropbox Console, you must update them in WPsigner and re-authorize the connection. Existing tokens become invalid.

---

## Developer Hooks

### `wps_dropbox_backup_path`

Filter the full Dropbox path before upload. Use this to customize folder structure, naming conventions, or route files dynamically.

```php
add_filter('wps_dropbox_backup_path', function ($dropbox_path, $document_id, $document) {
    // Organize by year/month
    $year  = wp_date('Y');
    $month = wp_date('m');
    return "/WPsigner/{$year}/{$month}/" . basename($dropbox_path);
}, 10, 3);
```

**Parameters:**

| Parameter | Type | Description |
|-----------|------|-------------|
| `$dropbox_path` | `string` | Full Dropbox path (e.g., `/WPsigner/Title_2026-03-06_42.pdf`) |
| `$document_id` | `int` | WPsigner document ID |
| `$document` | `object` | Document object with `title`, `status`, and other properties |

### `wps_dropbox_uploaded`

Action fired after a successful upload. Use this for post-upload processing like notifications or logging.

```php
add_action('wps_dropbox_uploaded', function ($document_id, $dropbox_path) {
    error_log("Document {$document_id} backed up to Dropbox: {$dropbox_path}");
}, 10, 2);
```

---

## Next Steps

- [OneDrive](/integrations/onedrive/) — Microsoft OneDrive backup
- [Google Drive](/integrations/google-drive/) — Google Drive backup
- [Amazon S3](/integrations/amazon-s3/) — S3 bucket storage
- [Cloudflare R2](/integrations/cloudflare-r2/) — Zero egress, global CDN
- [Wasabi](/integrations/wasabi/) — S3-compatible, no egress fees
