The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Loading large Data sets with Bulk API 2.0 and avoiding common failures (opens in a new tab)

You will learn how Bulk API 2.0 jobs work, the limits that govern them, and practices such as external-ID upserts, load ordering and failure reconciliation that keep large loads repeatable.

  1. Create job
  2. Upload CSV
  3. Close job
  4. Check job status
  5. Download failed records
The job flow Bulk API 2.0 follows from creation to completion

Bulk API 2.0 is Salesforce’s asynchronous data-loading API. Rather than sending records one request at a time, you create a job, upload a CSV file, close the job, and check its status while Salesforce processes the records in the background. Success and failure files are available for download, so the outcome of every record can be accounted for.

The article recommends it for thousands of records or more, such as migrations, nightly syncs and bulk cleanups, and suggests the standard Data Loader or Import Wizard for smaller volumes. It stresses that a bulk load multiplies the quality of its source file, so data should be cleaned first by standardizing picklist values, deduplicating and validating required fields.

Five practices are offered. Upsert against a stable External ID so re-runs do not create duplicates. Keep files within the limits of 150 MB per CSV and 150 million records per job, splitting very large loads into logical chunks. Watch the job through its states of Open, UploadComplete, InProgress and JobComplete, and download the failed-records file, which gives an error per row. Respect the daily limits of 10,000 Bulk API batches per rolling 24 hours and 15,000 Bulk API 2.0 jobs per day in most editions. Load parent records before children.

The piece also notes gotchas. Validation Rules still fire, so blocked rows fail while the rest succeed. Triggers and Flows run on every record and can slow the job or hit governor limits, so non-essential automation may be deactivated during a migration window. The hardDelete operation is permanent and skips the Recycle Bin, so it should be tested on a small batch first.

Read the original at dev.to (opens in a new tab)

Worth reading?

Recommended

Salesforce integrations fail on quota and data model, not protocol (opens in a new tab)

You will learn how the org-wide daily API allocation is calculated and why batching is a design decision rather than a tuning step.

Why read this

You will also see the Apex governor limit trap that breaks batch writes, and the external ID and upsert pattern that makes retries safe.

  • 5000: Contacts written one record per call
  • 25: Calls needed via sObject Collections at 200 per request
  • 100: SOQL query ceiling per synchronous transaction
Batching cuts the calls needed to write 5,000 Contacts by a factor of 200

The article argues that Salesforce integrations rarely fail on authentication or protocol. They fail on the daily API request allocation, which is shared across every consumer in an org, and on the data model choices that are costly to reverse once records exist. It walks through the main APIs, noting that REST and SOAP are both current, that Bulk API 2.0 is a different asynchronous programming model, and that Composite and sObject Collections cut call volume sharply because each counts as one call against the allocation.

The piece then covers the constraints that shape the architecture. The allocation is set by edition and license count, and requests fail with REQUEST_LIMIT_EXCEEDED once it is exhausted, with no grace on trial and Developer Edition orgs. Batching is presented as a design decision: a 5,000 record job costs 5,000 calls one at a time but 25 through sObject Collections. Caching reference data is also suggested. Governor limits are explained as applying to customer Apex that runs when an inbound write fires triggers, and an unbulkified trigger can exceed the 100 query ceiling on a 200 record batch.

Finally, the article addresses authentication, the Lead, Contact, Account and Person Account decisions, external IDs for idempotent upserts, partial-success handling, dead letter stores and reconciliation, and sandbox and API version pinning. It also discusses when middleware is justified and the UK GDPR obligations around controllers, processors and transfers. The cost ranges and vendor-agnostic claims are the author’s own estimates and are not independently verified.

Read the original at dev.to (opens in a new tab)

Worth reading?