Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Step 5: Check Batch Status

You can check the status of an individual batch by running this cURL command.

curl https://instance.salesforce.com/services/async/67.0/job/jobId/batch/batchId -H "X-SFDC-Session: sessionId"

instance is the portion of the <serverUrl> element and sessionId is the <sessionId> element that you noted in the login response. jobId is the job ID that was returned when you created the job. batchId is the batch ID that was returned when you added a batch to the job.

Salesforce returns an XML response with data such as this:

1<?xml version="1.0" encoding="UTF-8"?>
2<batchInfo
3   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
4  <id>751x00000000079AAA</id>
5  <jobId>750x0000000005LAAQ</jobId>
6  <state>Completed</state>
7  <createdDate>2009-09-01T17:44:45.000Z</createdDate>
8  <systemModstamp>2009-09-01T17:44:45.000Z</systemModstamp>
9  <numberRecordsProcessed>2</numberRecordsProcessed>
10  <numberRecordsFailed>0</numberRecordsFailed>
11  <totalProcessingTime>5820</totalProcessingTime>
12  <apiActiveProcessingTime>2166</apiActiveProcessingTime>
13  <apexProcessingTime>0</apexProcessingTime>
14</batchInfo>

If Salesforce can’t read the batch content or if the batch contains errors, such as invalid field names in the CSV header row, the batch state is Failed. When the batch state is Completed, all records in the batch have been processed. However, individual records could have failed. To see the status of individual records, retrieve the batch result.

Checking the status of each individual batch isn't necessary. You can check the status for all batches that are part of the job by running this cURL command:

curl https://instance.salesforce.com/services/async/67.0/job/jobId/batch -H "X-SFDC-Session: sessionId"