Skip to main content

Real-World Example

ABC Collections can import consumers in two ways: an employee manually uploads a CSV in the portal, or the company drops a CSV into its SFTP folder. Once the file is accepted, both paths use the same background processing pipeline. That shared pipeline stores the file, creates import history, splits the work into chunks, processes rows safely, records failed rows, finalizes counts, and triggers the correct consumer communications.

Visual Flow

Shared Processing Rules

Manual Import Path

Manual import starts from Import File. The creditor selects a mapped Header Profile, chooses Add, Add + CFPB, Update, or Delete, uploads a CSV, and the app validates the file headers before storing the file. Manual imports calculate total records before the coordinator creates chunks.

SFTP Import Path

SFTP import starts from SFTP Connections. The scheduled command scans active mapped SFTP header profiles twice daily. When it finds CSV files in the expected folders, it copies each file into import_consumers, creates SFTP import history, and dispatches the same coordinator job used by manual uploads. After dispatching the import, the SFTP follow-up job moves the remote source file into proceed. If a failed-records CSV is available, it is copied back into the remote failed folder.

Four Import Types

Communication Behavior

The import pipeline does not blindly send messages while rows are still processing. It stores communication work and lets follow-up jobs send or schedule messages after the import work is safe.
  • New accounts can trigger new-account or existing-PII-account communication.
  • Pay-term updates can trigger updated-offer communication.
  • Deleted accounts can trigger creditor-removed-account communication.
  • Secure CFPB EcoLetters trigger CFPB delivery communication when the creditor sends those letters.
  • Email/SMS still depends on feature flags, opt-out state, contact permissions, valid email/phone, and available communication templates.
For provider delivery, open tracking, SMS opt-out replies, and webhook callbacks, see Communication Delivery & Webhooks.

How It Should Work

  • It should process manual and SFTP files through the same safe queue pipeline.
  • It should make import progress visible through import history.
  • It should keep failed row details attached to the import.
  • It should make SFTP imports auditable by marking the history as SFTP.
  • It should finalize only after all chunks finish.

How It Should Not Work

  • It should not process all rows in a single browser request.
  • It should not mix files or failed rows between creditors.
  • It should not mark an import completed while chunks are still pending or processing.
  • It should not send communications for rows that failed validation.

Developer Notes

  • ImportConsumersCoordinatorJob owns chunk creation and dispatch.
  • ProcessConsumerChunkJob owns row-level validation and create/update/delete work.
  • FinalizeConsumerImportJob owns aggregate status, duration, large-upload mail, over-limit billing, and subscription sync after deletion.
  • ProcessConsumerImportNotificationsJob dispatches deferred consumer communication work in 500-notification batches.
  • SFTP imports use ImportConsumersViaSFTPCommand and then reuse the same coordinator/chunk/finalize jobs.
  • app/Livewire/Creditor/ImportConsumers/IndexPage.php
  • app/Console/Commands/ImportConsumersViaSFTPCommand.php
  • app/Console/Kernel.php
  • app/Enums/FileUploadHistoryType.php
  • app/Enums/ConsumerUpdateFields.php
  • app/Jobs/ImportConsumersCoordinatorJob.php
  • app/Jobs/ProcessConsumerChunkJob.php
  • app/Jobs/FinalizeConsumerImportJob.php
  • app/Jobs/ProcessConsumerImportNotificationsJob.php
  • app/Jobs/GenerateErrorFileOfImportedConsumersViaSFTPJob.php
Last modified on May 27, 2026