data upsert bulk

Bulk upsert records to an org from a CSV file. Uses Bulk API 2.0.

An upsert refers to inserting a record into a Salesforce object if the record doesn’t already exist, or updating it if it does exist.

When you execute this command, it starts a job, displays the ID, and then immediately returns control of the terminal to you by default. If you prefer to wait, set the –wait flag to the number of minutes; if it times out, the command outputs the IDs. Use the job and batch IDs to check the status of the job with the “sf data upsert resume” command.

See “Prepare CSV Files” in the Bulk API Developer Guide for details on formatting your CSV file. (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_prepare_csv.htm)

Flag Name (Long)Flag Name (Short)Description
‑‑api‑versionN/AType: Value

Override the api version used for api requests made by this command
‑‑column‑delimiterN/AType: Value
Valid Values: BACKQUOTE, CARET, COMMA, PIPE, SEMICOLON, TAB

Column delimiter used in the CSV file.
‑‑external‑id‑iType: Value
Required

Name of the external ID field, or the Id field.
‑‑file‑fType: Value
Required

CSV file that contains the IDs of the records to update or delete.
‑‑flags‑dirN/AType: Value

Import flag values from a directory.
‑‑jsonN/AType: Boolean

Format output as json.
‑‑line‑endingN/AType: Value
Valid Values: CRLF, LF

Line ending used in the CSV file. Default value on Windows is CRLF; on macOS and Linux it’s LF.
‑‑sobject‑sType: Value
Required

API name of the Salesforce object, either standard or custom, that you want to update or delete records from.
‑‑target‑org‑oType: Value
Required

Username or alias of the target org. Not required if the target-org configuration variable is already set.
‑‑wait‑wType: Value

Number of minutes to wait for the command to complete before displaying the results.

Bulk upsert records to the Contact object in your default org:

Bulk upsert records to a custom object in an org with alias my-scratch and wait 5 minutes for the command to complete: