Confusion With Salesforce Composite API

I will apologize in advance as this is a very lengthy post, but hopefully can help others if they are using the Composite SF API also!

I am using the SF Composite API option to insert/update records and am confused on the difference between using the "How can we find existing records" on the "Edit Import" screen vs that on the field mapping (more on that at the bottom of the post).

In my case, I will always have an account Id to match to an existing account, however, each contact may or may not have a contact Id. The contact Id is being retrieved from a previous lookup step. If there is a contact Id, then the import should update the existing contact with the fields outlined in the import mapping, but if there is not a contact Id, then the import should treat that as a new contact and import accordingly.

Can someone assist with helping me outline how my Insert/Update should work?

Current setup on the Import:


Input Sample Payload (this is just the Account and Contact portion):

{
  "FormInformation": {
    "FormName": "CELIGOTESTCSNewDependentLayout",
    "SubmitDate": "2025-02-17T19:43:22.749Z",
    "CognitoFormId": "564-3",
    "FormURL": "https://www.cognitoforms.com/ClearwaterBenefits1/564/entries/3",
    "Status": "Submitted",
    "StatusReason": "Submitted",
    "EnrolledFrom": "Cognito"
  },
  "AccountInformation": {
    "AccountName": "PrimaryFirst PrimaryLast",
    "HealthCloudAccountId": "001Pn00000PGx76IAD",
    "PrimarySSN": "423-22-4223",
    "PrimaryDOB": "1986-10-31",
    "MobilePhoneNumber": "(241) 231-2322",
    "StreetAddress": "12345 Sesame Lane",
    "City": "Omaha",
    "State": "Nebraska",
    "ZipCode": "68116"
  },
  "ContactInformation": [
    {
      "FirstName": "PrimaryFirst",
      "LastName": "PrimaryLast",
      "MiddleInitial": "H",
      "Relationship": "Self",
      "DateOfBirth": "1986-10-31",
      "Gender": "Male",
      "SocialSecurityNumber": "111-22-3333",
      "TobaccoUser": "Yes",
      "Email": "test@test.com",
      "MobilePhoneNumber": "(241) 231-2322",
      "ContactId": "003Pn00000RH7UiIAL"
    },
    {
      "FirstName": "SpouseFirst",
      "LastName": "SpouseLast",
      "MiddleInitial": null,
      "Relationship": "Spouse",
      "DateOfBirth": "1979-12-20",
      "Gender": "Female",
      "SocialSecurityNumber": "444-55-6666",
      "TobaccoUser": "Yes",
      "Email": "test1@test.com",
      "MobilePhoneNumber": "(312) 312-3212",
      "ContactId": "003Pn00000RH7UiIBL"
    },
    {
      "FirstName": "Child1First",
      "LastName": "Child1Last",
      "MiddleInitial": null,
      "Relationship": "Child",
      "DateOfBirth": "2003-06-20",
      "Gender": "Female",
      "SocialSecurityNumber": "312-31-2321",
      "TobaccoUser": "No",
      "Email": null,
      "MobilePhoneNumber": null
    },
    {
      "FirstName": "Child2First",
      "LastName": "Child2Last",
      "MiddleInitial": null,
      "Relationship": "Child",
      "DateOfBirth": "2006-05-20",
      "Gender": "Male",
      "SocialSecurityNumber": "412-32-1321",
      "TobaccoUser": "No",
      "Email": null,
      "MobilePhoneNumber": null
    },
    {
      "FirstName": "Child3First",
      "LastName": "Child3Last",
      "MiddleInitial": null,
      "Relationship": "Child",
      "DateOfBirth": "2020-04-01",
      "Gender": "Male",
      "SocialSecurityNumber": "324-24-2432",
      "TobaccoUser": "No",
      "Email": null,
      "MobilePhoneNumber": null
    },
    {
      "FirstName": "Child4First",
      "LastName": "Child4Last",
      "MiddleInitial": null,
      "Relationship": "Child",
      "DateOfBirth": "2022-09-01",
      "Gender": "Female",
      "SocialSecurityNumber": "241-23-4123",
      "TobaccoUser": "No",
      "Email": null,
      "MobilePhoneNumber": null
    }
  ]
}

Sample Field Mappings:

Some of my confusion stems from this section of the help pages:

If you navigate down to the Import Mapping section, it has some documentation around the Composite API and always performing a line ID lookup. Does this mean that I need to have a lookup for each field?

@daveguderian before I look at this, fyi that code blocks are under settings icon and can be used like this:

{
  "FormInformation": {
    "FormName": "CELIGOTESTCSNewDependentLayout",
    "SubmitDate": "2025-02-17T19:43:22.749Z",
    "CognitoFormId": "564-3",
    "FormURL": "[Cognito Forms: Free Online Form Builder](https://www.cognitoforms.com/ClearwaterBenefits1/564/entries/3)",
    "Status": "Submitted",
    "StatusReason": "Submitted",
    "EnrolledFrom": "Cognito"
  }
}

@tylerlamparter - Thanks for that! I wasn't sure where that went, and I didn't want to screw up my long post accidentally by hitting something I didn't intend to. I'll be sure to use the preformatted text in the future!

1 Like

I am using the SF Composite API option to insert/update records and am confused on the difference between using the "How can we find existing records" on the "Edit Import" screen vs that on the field mapping (more on that at the bottom of the post).

The how to find existing records would be related only to the sObject you specified above. So you are telling us "how can we find an existing account to update and if no account is found with this criteria then we will make a new one".

If you navigate down to the Import Mapping section, it has some documentation around the Composite API and always performing a line ID lookup. Does this mean that I need to have a lookup for each field?

This means you do a dynamic lookup for the related objects id (I think, I have not tried this :slight_smile: ):