I'd like to create an account and then a contact in the same call using bulk api. I've used composite api calls to create an account and contact in the same API request.

I would now like to do the same using the bulk api (as i'm trying to import millions of entries). I know i can create all the accounts first, retrieve the account ids, and then create the contacts with the account ids mapped to the correct contact (which would be two calls).

Is there a way to composite the account and contact creation in the single call with bulk api?

Cheers, Ankur

  • The composite sobject api can create hundreds of records per call. – sfdcfox Apr 2 '20 at 17:11
  • Oh really? According to the documentation it can only handle 25 subrequests in a single call – Ankur22 Apr 2 '20 at 17:26
  • Yes, and each sub-request can include up to 200 records, which you can then refer in subsequent sub-requests using referenceId values. – sfdcfox Apr 2 '20 at 18:23

No, you can't use the Bulk API to create multiple object types at the same time. Every Bulk API job uses exactly one sObject.

Note that the notion of a "call" looks rather different in the Bulk API. Every Bulk API job you run will involve multiple API calls. You'll create a job, push batches into that job, close the job, poll for completion, and download results, each of which is at least one API call.

  • So, just to be clear, relationship fields in records can only be used to update, not to create records? – Brian Kessler Jul 8 '20 at 12:43
  • Sorry @BrianKessler, I'm not quite sure what you mean. You can match relationships on an upsert - is that what you're aiming at? – David Reed Jul 8 '20 at 14:39
  • If I understand correctly, if we use either JSON or XML with the Bulk API, we can include data for parent relationships in calls to the Bulk API. Maybe I don't understand correctly (I find the bulk API a little confusing), but I'm wondering if we could leverage this to insert both the child and the parent concurrently with the Bulk API. – Brian Kessler Jul 9 '20 at 7:33
  • 1
    No, that feature only allows you to map relationship fields through an idLookup or External Id field on the parent object. It doesn't insert or update the parent. – David Reed Jul 9 '20 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.