Merge.dev Connection Plugin
Connect Flatfile to the Merge.dev unified API platform to sync data from hundreds of third-party integrations including HRIS, ATS, CRM, and Accounting systems.
The Merge.dev Connection Plugin enables users to sync data from hundreds of third-party integrations directly into Flatfile through the Merge.dev unified API platform. When a user establishes a connection to a service via Merge within the Flatfile UI, the plugin automatically creates a new Flatfile Workbook with a schema that matches the data models for that integration. The plugin performs an initial data sync and allows users to manually trigger full data refreshes at any time.
Installation
Install the plugin using npm:
Configuration & Parameters
This plugin is configured through Flatfile Secrets rather than code-based options.
Required Secret
Your API key from your Merge.dev account. This secret must be created in your Flatfile Space and is used to authenticate with the Merge API for token exchange, schema fetching, and data synchronization.
Default Behavior: If the MERGE_ACCESS_KEY
secret is not present or invalid, the plugin will fail during workbook creation or data sync, resulting in a failed Flatfile Job with an error message indicating the missing key.
Function Signature
The plugin exports a single function:
Parameters: None
Returns: A function that registers job handlers with the Flatfile listener for:
space:createConnectedWorkbook
: Creates workbooks based on Merge schemasworkbook:syncConnectedWorkbook
: Syncs data from connected services
Usage Examples
Complete Setup Example
Configuration Setup
-
Create the Secret: In your Flatfile Space settings, create a new Secret with the name
MERGE_ACCESS_KEY
and your Merge.dev API key as the value. -
Use the Plugin: The plugin automatically looks for the
MERGE_ACCESS_KEY
secret in the Space where it’s running.
Troubleshooting
Missing API Key Error
If you encounter errors related to missing Merge API keys, ensure that:
- The
MERGE_ACCESS_KEY
secret is properly set in your Flatfile Space - The API key value is correct and active in your Merge.dev account
Sync Timeout Issues
If sync operations timeout, the plugin polls Merge.dev for up to 5 minutes (30 attempts at 10-second intervals). If Merge doesn’t complete its sync within this window, the job will fail with a timeout error.
Job Failures
Check the Flatfile Job logs in your dashboard for specific error messages. The plugin provides descriptive error messages for common issues like missing credentials or API failures.
Notes
Prerequisites
- The
connections
feature flag must be enabled for your Flatfile account (contact support@flatfile.com) - Active Merge.dev account required
MERGE_ACCESS_KEY
secret must be configured in your Flatfile Space
Alpha Release Warning
This plugin is an alpha release. Functionality and APIs may change in future versions.
Data Sync Behavior
- Each sync performs a full refresh of data
- All existing records are deleted before inserting current data
- Manual changes made in Flatfile will be overwritten on next sync
- This ensures data consistency with the source system
Automatic Secret Management
The plugin automatically creates workbook-specific secrets named <workbookId>:MERGE_X_ACCOUNT_TOKEN
to store account tokens for each connection. These are managed internally by the plugin.
Error Handling Pattern
The plugin uses centralized error handling that:
- Logs original errors to the console for debugging
- Throws user-friendly error messages displayed in the Flatfile UI
- Causes failed jobs to show descriptive error messages in the dashboard
Manual Sync Actions
After initial setup, the plugin automatically adds a “Sync” action to connected workbooks. Users can trigger this action from the Flatfile UI to refresh data without additional code.