function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mahesh KGMahesh KG 

How to Create an Account in Salesforce using REST API

Can you please let me know how to create an Account in Salesforce using the REST API.
i also need to know where i can find my clientId and Client Secret to get the access token
Sankaranarayanan VenkatachalamSankaranarayanan Venkatachalam

Hi Mahesh,

Please find the steps below to create an Account using REST API:

* Login to Workbench (
* Navigate to 'Utilities -> REST Explorer'
* Select the 'Method' as 'POST'
* Paste the below line in the text box:


* Click on 'Headers' and paste the below:

Accept: application/xml

* In the Request Body, paste the below content:

  "Name" : "Account from REST API",
  "ShippingCity" : "Chennai"
* Click 'Execute'. The Account will be created.

Refer Trailhead ( module for more information about REST API.
Refer this link  ( for the steps to know your Client ID and Client Secret.

Please mark this answer as 'Best Answer' if this answers your question.

Best Regards.
Mahesh KGMahesh KG
Can you tell me how to Authentication is working? are you using Ouath?  i need to implemen the same with my java code? can u tell me the flow for the account creation?
Sankaranarayanan VenkatachalamSankaranarayanan Venkatachalam
If you want to hit Salesforce using REST API and want to create an Account, then you have to follow the below steps:

* Create a Connected App (for Authentication). Reference. (
* Create a REST service Apex Class in Salesforce, which gets the necessary parameters (like Name, Country etc.) for Account creation, as shown in the 'Create a Record with a POST Method' section here (
* Perform the callout using the Client ID and Client Secret you will get from the Connected App.
* Once the connection is established, call the REST Service class, which will create the record in Salesforce.

Please mark this answer as 'Best Answer' if this answers your question.

Best Regards.
Mahesh KGMahesh KG
Should we create a new Apex class for the Account? i think there is already a controller mapping for Account can i use the same? 
Sankaranarayanan VenkatachalamSankaranarayanan Venkatachalam
Yes, a new class should be created for Account creation in Salesforce. Something like below:
global with sharing class MyRestResource {
    global static Id createAccount(String name, String county) {
        Account restAcc = new Account(Name=name, ShippingCountry=country);
        insert restAcc;
        return restAcc.Id;
Mahesh KGMahesh KG
Thank you for the Help. 

i have below fields that we are using today on the salesforce for creating the order. Can you please let me know the corresponding objects that i need to pass them to my controller. i would like to know what is the object that i need to send to create the account in salesforce.

Please find the below list of fields highlighted. User-added imageUser-added image
i have below fields like AccountName,ParentAccount etc,. i need to know how i need to send them as the object to create the account and how the values should be sent to the dropdown?

Deepali KulshresthaDeepali Kulshrestha
Hi Mahesh,

Supply the required field values in the request data, and then use the POST method of the resource. The response body will contain the ID of the created record if the call is successful.

Example of creating a new Account

Method :- Post
URL:- /services/data/v36.0/sobjects/Account/

Example Request Body for creating an account:- 

{ "Name" : "Express Logistics and Transport" }

Example response body after successfully creating a new Account

{ "id" : "0019000001hE8apAAC", "success" : true, "errors" : [ ] }

I suggest to visit these links, it will help you in understand how to create a record using API

There is a specific Trailhead for this:-

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Sankaranarayanan VenkatachalamSankaranarayanan Venkatachalam

Hi Mahesh,

Based on your screenshots, you want to create 'Account' object in Salesforce. The Object API name is 'Account' itself. You can pass the values to your REST Service method (refer my last comment). For dropdown values, you can pass as 'String' and assign them directly. If they are constants, then you can assign them in the REST Service class directly.

Please mark this answer as 'Best Answer' if this answers your question.

Best Regards.

Mahesh KGMahesh KG
I need to integrate the REST service Apex class created with java for creating the account object? can u insist with the right APIS?