A simple script to sync person data to Pipedrive CRM.
- Install dependencies:
pnpm install- Create a
.envfile in the root folder:
PIPEDRIVE_API_KEY=your_api_key_here
PIPEDRIVE_COMPANY_DOMAIN=your_company_domain
- Run the script:
pnpm build
pnpm start- Reads person data from
src/mappings/inputData.json - Uses field mappings from
src/mappings/mappings.jsonto map input fields to Pipedrive fields - For each person:
- Searches if person already exists (by name)
- If found → updates the person
- If not found → creates new person
The input data can be a single object or an array of objects. The script handles both cases - if you pass an array, it processes each person one by one.
Pipedrive doesn't have a bulk create API, so we loop through and add a small delay between requests to avoid hitting rate limits.
If Pipedrive returns a 429 (too many requests), the script waits for the time specified in the Retry-After header and then retries the same request.
If a person in the array has an empty name or no valid data to sync, the script skips that person and continues with the rest. It doesn't fail the entire batch because of one bad entry.
Pipedrive search returns partial matches (searching "John" might return "John Smith", "Johnny", etc.). The script does an exact name comparison after search to make sure we're updating the right person.
If API key or company domain is missing/empty in the .env file, the script throws a clear error message instead of failing with a confusing API error later.
src/
index.ts - Main sync logic
mappings/
inputData.json - Person data to sync
mappings.json - Field mappings (pipedrive field → input field)
types/
pipedrive.ts - TypeScript types
- The script uses the v1 Pipedrive API
- Name field is required for person lookup
- Empty values in input data are skipped (not sent to Pipedrive)