Creating new custom object records

If you want to create new custom object records using the Bulk API, you can set the identifierFieldName to the custom object record Id or external Id then set this field to blank upon uploading data.

This tutorial will provide an example of creating the definition and uploading data to create only new custom object records. If you are not yet familiar with importing data via the Bulk API, see the tutorial.

In this tutorial:

  • Creating custom object definition with identifierFieldName set to custom object record Id
  • Uploading data to definition with blank values for custom object record Id

Creating the custom object definition:

Let's start by creating a custom object import definition with identifierFieldName set to the custom object record Id:

POST /bulk/2.0/customObjects/9/imports

{
    "name": "Create new custom object records",
    "fields": {
        "Email": "{{CustomObject[9].Field[103]}}",
        "FirstName": "{{CustomObject[9].Field[104]}}",
        "Id": "{{CustomObject[9].Id}}"
    },
    "identifierFieldName": "Id",
    "isSyncTriggeredOnImport": true
}

Note: Custom object IDs can be retrieved using the Retrieve a list of custom objects endpoint. All custom object field statements, including ID and external ID, can be retrieved using the Retrieve a list of the fields for a custom object endpoint. Either of the following custom object record fields can be used to create new custom object records:

  • {{CustomObject[customObjectId].Id}}
  • {{CustomObject[customObjectId].ExternalId}}

Here's the response:

{
    "id": 874,
    "parentId": 9,
    "mapDataCardsCaseSensitiveMatch": false,
    "name": "Create new custom object records",
    "fields": {
        "Email": "{{CustomObject[9].Field[103]}}",
        "FirstName": "{{CustomObject[9].Field[104]}}",
        "Id": "{{CustomObject[9].Id}}"
    },
    "identifierFieldName": "Id",
    "isSyncTriggeredOnImport": true,
    "dataRetentionDuration": "P7D",
    "isUpdatingMultipleMatchedRecords": false,
    "uri": "/customObjects/9/imports/874",
    "createdBy": "API.User",
    "createdAt": "2024-09-11T17:10:04.9900000Z",
    "updatedBy": "API.User",
    "updatedAt": "2024-09-11T17:10:04.9900000Z"
}

Uploading data to the custom object definition:

Now that we have the uri for the import definition with the identifierFieldName set to the custom object record ID, let's upload data with the custom object record ID set to blank to create all new records:

POST /bulk/2.0/customObjects/9/imports/874/data

[
    {
        "Email": "john.doe@example.com",
        "FirstName": "John",
        "Id": ""
    },
    {
        "Email": "jane.doe@example.com",
        "FirstName": "Jane",
        "Id": ""
    }
]

Here's the response:

{
    "syncedInstanceUri": "/customObjects/9/imports/874",
    "status": "pending",
    "createdAt": "2024-09-11T17:56:45.1900000Z",
    "createdBy": "API.User",
    "uri": "/syncs/2933"
}

Note: If Unique Code Field is set on the custom object, and the value for the unique code field already exists in the custom object the record will be rejected with a "Duplicate identifier" warning.

Learn more

Import data into Eloqua