Create Records Using REST API

Ingest individual records using the sObjects create endpoints in REST API.

A common use case for this API is the integration of applications that collect contact registration information. You can use this API to feed the collected data directly into Salesforce.

Use REST API to create the record types shown in this table.

Record TypeAPI Name
Contact recordsContact
Lead recordsLead
CampaignsCampaign

Before you send a request to REST API, obtain a bearer token. For more information, see Connect to REST-based APIs.

To create a record, send a POST request to the /services/data/v60.0/sobjects/OBJECT_API_NAME endpoint, where OBJECT_API_NAME is the API name of the type of object that you want to create. The body of the request is a JSON object that contains the information that you want to add to the record.

A common use case is to use REST API to create individual contact records. This code example shows how to create a basic contact record.

The field names that you specify in the request body must exactly match the field names in the target object. You can retrieve a list of field names and relationships by issuing a GET call to the /services/data/v60.0/sobjects/OBJECT_API_NAME/describe endpoint. Alternatively, you can view a list of fields and relationships in the Object Explorer in Salesforce Setup.

Fields that are present in the target object but not specified in the request receive their default values. If a field in the request body doesn’t exist in the target object, the request fails with an error.

For more information and code examples, see createContact.

You can create up to 200 records in a single synchronous operation by issuing a POST request to the /services/data/v60.0/composite/tree/OBJECT_API_NAME endpoint. To create more than 200 records, use Bulk API 2.0 instead.

In a request to create multiple records, the body of the request is slightly different. It contains an array called records, and each record is a separate object in the array. Each record includes an additional object, attributes, which must include the type of object that you’re creating. The object must also include a referenceId, which is included in the response so that you can track which items in the request were processed successfully.

This code example shows how to create multiple contact records in a single call to REST API.

The response indicates whether there were errors in processing the request. It also lists the IDs and the reference IDs for each object that was created.

For more information, see Create Multiple Records in the REST API Developer Guide.