Below are the available data related commands in CLI. If I want to insert records using SFDX CLI, how to do that?

force:data:bulk:delete    -- bulk delete records from a csv file
force:data:bulk:status    -- view the status of a bulk data load job or batch
force:data:bulk:upsert    -- bulk upsert records from a CSV file
force:data:record:create  -- create a record
force:data:record:delete  -- delete a record
force:data:record:get     -- view a record
force:data:record:update  -- update a record
force:data:soql:query     -- execute a SOQL query
force:data:tree:export    -- export data from an org into sObject tree format for force:data:tree:import consumption
force:data:tree:import    -- import data into an org using SObject Tree Save API

How can I use force:data:bulk:upsert command to insert records for a object which doesn't have External Id defined?

NOTE: I agree there are several options possible but I am more interested in using SFDX CLI to insert records.

1 Answer 1


You can use Id as the field to upsert against. There's even an example in the docs:

$ sfdx force:data:bulk:upsert -s MyObject__c -f ./path/to/file.csv -i Id -w 2

For new records, leave the Id column empty. Here's an example file I used that worked in my developer org (YMMV):


This created a new account called Acme. Make sure you modify the -w parameter to give yourself enough polling time (this example is just 2 minutes), or you'll have to use force:data:bulk:status to check for completion and/or view the Bulk Job Monitoring screen in Setup.

  • I thought it was an example for updating records. Never thought I could leave Id column empty. This is great.
    – javanoob
    Sep 28, 2019 at 17:57
  • @javanoob Glad to help, as always.
    – sfdcfox
    Sep 28, 2019 at 18:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .