Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Return 202 Accepted when a Salesforce REST request has been accepted but its asynchronous work is still running. Use 200 OK when the request has completed successfully and the response represents that completed operation. A 202 response is not a promise that the work will succeed; give the client a way to check status and obtain the final result.

What 202 and 200 mean for an async request

HTTP status codes should describe what has happened at the point the server responds. Salesforce’s Connect REST status-code table defines 202 as: “A request was accepted for processing, but processing isn’t complete.” Its 200 code indicates a successful request, with the returned information depending on the method. Salesforce Connect REST API status codes

If your endpoint has only queued work, returning 200 can lead a client to treat the operation as finished when it is not. Return 202 to acknowledge acceptance, then expose a job or operation resource that the client can check for progress and eventual results. Acceptance is not completion, and it does not establish that processing will ultimately succeed.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the response code for the event that occurred

Salesforce documents several success-related codes for different outcomes. The correct choice depends on the endpoint’s contract and what it actually did, not simply on whether the request was syntactically valid. Salesforce REST API status codes

Status Use it when
200 OK The request completed successfully and the response represents the result. Salesforce documents it for GET, HEAD, and some PATCH requests.
201 Created The request successfully created a resource.
202 Accepted The request was accepted for processing, but the work is not complete.
204 No Content The operation succeeded and there is no response content, as with some DELETE requests.

How to handle asynchronous Salesforce work

Custom asynchronous REST endpoints

On acceptance, return 202 and enough information for the caller to identify or locate the operation. Define how clients can check its status and retrieve its final outcome. The response should not make a queued operation look like a completed one.

Bulk API 2.0 jobs

Bulk API 2.0 is an asynchronous workflow: submit work, then check the job and retrieve results later. A job can move through states such as Open, UploadComplete, JobComplete, and Failed. Treat job creation as the start of the workflow, not its final success; poll or otherwise check the job state and fetch the results when they are available. Salesforce Bulk API 2.0 introduction Salesforce Bulk API 2.0 job creation

Bulk API batch workflows

An add-batch response acknowledges receipt of a batch; it does not confirm that every record succeeded. Check the batch status and retrieve its results. Even a completed batch can contain record-level failures, so inspect the outcomes rather than inferring success from receipt or completion alone. Salesforce Bulk API batch workflow

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When Salesforce recommends Bulk API 2.0

Salesforce describes jobs above 2,000 records as a good candidate for Bulk API 2.0. For jobs below 2,000 records, its guidance is to use bulkified synchronous REST—such as Composite—or SOAP. This is Salesforce’s recommendation, not a universal threshold; select the API based on the workload and the behavior your application needs. Salesforce Bulk API 2.0 introduction

Implementation checklist

  • Return 202 only when the request has been accepted and processing remains incomplete.
  • Provide a documented way to check operation or job status and retrieve final results.
  • Keep acceptance, completion, and record-level success distinct in both the API response and client logic.
  • For bulk workflows, inspect job or batch status and individual outcomes before reporting success to users.
  • Confirm the status-code behavior for the specific Salesforce operation and target org against the current API reference; documentation and API versions can change.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.