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‑version | N/A | Type: Value Override the api version used for api requests made by this command |
‑‑column‑delimiter | N/A | Type: Value Valid Values: BACKQUOTE, CARET, COMMA, PIPE, SEMICOLON, TABColumn delimiter used in the CSV file. |
‑‑external‑id | ‑i | Type: Value Required Name of the external ID field, or the Id field. |
‑‑file | ‑f | Type: Value Required CSV file that contains the IDs of the records to update or delete. |
‑‑flags‑dir | N/A | Type: Value Import flag values from a directory. |
‑‑json | N/A | Type: Boolean Format output as json. |
‑‑line‑ending | N/A | Type: Value Valid Values: CRLF, LFLine ending used in the CSV file. Default value on Windows is CRLF; on macOS and Linux it’s LF. |
‑‑sobject | ‑s | Type: Value Required API name of the Salesforce object, either standard or custom, that you want to update or delete records from. |
‑‑target‑org | ‑o | Type: Value Required Username or alias of the target org. Not required if the target-org configuration variable is already set. |
‑‑wait | ‑w | Type: 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: