Skip to Content

Send Bulk SMS with CSV Streaming & Batch Progress

Ingest high-volume CSV contact lists without memory leaks, dispatch chunked batch jobs, and poll asynchronous campaign completion.

View Markdown (.md)

Sending marketing or broadcast announcements to tens of thousands of subscribers requires an asynchronous architecture. Loading an entire 100,000-row CSV file into memory can crash standard Node.js processes. This recipe demonstrates how to stream CSV rows, sanitize phone numbers, submit chunked batch jobs, and poll progress.

Streaming Bulk SMS Dispatch & Progress Tracking

Navigate through each step to inspect the TypeScript implementation on the right.

1

1. Configure Dependencies & Environment

Install csv-parser to handle Node.js streaming ingestion with minimal memory overhead.

Step 1 (typescript)
2

2. Build the Streaming CSV Recipient Parser

Read the CSV file as an asynchronous stream. Clean and normalize each phone number to standard format, discarding duplicates and malformed records on the fly.

Step 2 (typescript)
3

3. Dispatch Chunked Asynchronous Batch Jobs

Accumulate recipients into chunks of 1,000 recipients and submit each chunk to POST /api/v1/public/sms/batch. Attach a unique Idempotency-Key to each batch chunk.

Step 3 (typescript)
4

4. Poll Campaign Progress & Completion

Periodically query GET /api/v1/public/sms/batch/{jobId}/progress until the job reaches a terminal state (COMPLETED or FAILED).

Step 4 (typescript)