A Node.js tool to bulk archive emails in Pipedrive via their API, since the UI doesn't provide a batch archive feature.

- Fetches all email threads from your Pipedrive inbox or sent folder
- Bulk archives unarchived emails
- Support for archiving both inbox and sent emails
- Dry-run mode to preview what will be archived
- Interactive confirmation before archiving
- Progress tracking and statistics
- Colorful CLI output with clear status indicators
- Node.js 18+ installed
- Pipedrive account with API access
- API token from Pipedrive
-
Clone or download this repository
-
Install dependencies:
npm install
-
Copy
.env.example
to.env
:cp .env.example .env
-
Edit
.env
and add your Pipedrive API token:PIPEDRIVE_API_TOKEN=your_api_token_here PIPEDRIVE_DOMAIN=yourcompany.pipedrive.com
To get your API token:
- Log in to Pipedrive
- Go to Settings → Personal preferences → API
- Copy your personal API token
npm start
This will:
- Fetch all email threads from your inbox
- Show you a summary of archived/unarchived emails
- Ask for confirmation before archiving
- Archive all unarchived emails
npm start -- --sent
Archives sent emails instead of inbox emails.
Preview what will be archived without making changes:
npm run dry-run
# or
npm start -- --dry-run
Archive without the confirmation prompt:
npm start -- --yes
# or
npm start -- -y
You can combine different options:
# Dry run for sent emails
npm start -- --sent --dry-run
# Archive sent emails without confirmation
npm start -- --sent --yes
npm start -- --help
The tool uses Pipedrive's Mail Threads API to:
- Fetch all email threads from your inbox using pagination
- Filter out already archived threads
- Archive each unarchived thread individually
- Provide real-time progress updates
GET /mailbox/mailThreads
- Fetch email threadsPUT /mailbox/mailThreads/{id}
- Archive individual threads
The tool includes a 100ms delay between archive operations to avoid hitting API rate limits.
Make sure you've created a .env
file with your API token.
- Verify your API token is correct
- Check if your Pipedrive domain is set correctly in
.env
- Ensure you have the necessary permissions in Pipedrive