Automated Bash script for normalizing and bulk-importing contacts from Excel files into API.
The import_contacts.sh script does the following:
- Normalizes and sanitizes phone numbers (removes
+, spaces, hyphens, and brackets, leaving digits only). - Validates required fields (Full Name and Phone Number).
- Splits large lists into batches (chunks) for safe API transmission.
- Handles network errors (timeouts) and server HTTP errors (4xx/5xx).
- Generates a detailed report and results log.
The script relies on the following CLI utilities: curl, jq, miller (mlr), and gnumeric (ssconvert for Excel conversion).
brew install gnumeric miller jq curlsudo apt update
sudo apt install -y gnumeric miller jq curlCopy the configuration template .env.example to .env:
cp .env.example .envOpen the .env file and set the URL and API access token:
COMPANY_URL=your_url_here
TOKEN=your_access_token_here
TYPE_ID=200
BATCH_SIZE=1000
The input file can be in .xls or .xlsx format. The first row must contain column headers.
Make the script executable (run once before the first execution):
chmod +x import_contacts.shStandard import run:
./import_contacts.sh --file contacts.xlsx --queue-id 123Upon completion, the script generates a detailed summary log.