Rest API: Create Account
This article details the Create Account section of the Rest API documentation
Overview
This call basically creates account with related contact information like account name, account number, Account address, phone number etc.
This method can be used to create:
- Only Account
- Only Contact
- Account with single or multiple Contacts
- Account with single or multiple payment methods
- Account with one contact and one or multiple payment methods
HTTP Method
POST
Request URL
https://domain/services/apexrest/Invoice_API/invoiceit/accounts
The Domain Name Example – “eposnow.my.salesforce.com”
Request Body
The request body object field details needed to create Account or contact or payment method.
Note: Apart from the below fields any other standard or custom fields of Account or Contact or payment method could be used to create a record.
Field Description
- Name (Required) The name of account up to 255 characters
- invoiceit_s__Advance_Requested_Amount__c (Optional) Amount of 16 digit with 2 decimal place
- invoiceit_s__Advance_Request_Status__c (Optional) Status of type ‘Requested’ or ‘Paid’
- invoiceit_s__Customer_Class__c (Optional) Customer class of type ‘Default’ or ‘*’
- invoiceit_s__VAT_No_c (Optional) Vat/Tax No of type number up to 15 characters
- invoiceit_s__Invoice_Delivery_Type__c or ‘Email&Print’ (Optional) Invoice Delivery type of Print’, ‘Email’
- invoiceit_s__Payment_Terms__c (Optional) Payment Term of type ‘Net 30’, ‘Net 45’, ‘Net 60’ or ‘Due On Receipt’
- invoiceit_s__Preferred_Billing_Day__c (Optional) Preferred billing day value from 1 to 31
For Contact:
Field Description
- Name The last name of contact of text up to 255 character
- Phone Give phone number
- Email Give email id for the contact
For Payment Method:
Field Description
- Name Give the name of the payment method
- invoiceit_s__Account__c (Required) Give the account number
- invoiceit_s__Bank_Account_Name__c Give the bank account name
- invoiceit_s__Billing_Address__c Give the billing address
- invoiceit_s__Card_Number__c Give the card number
- invoiceit_s__CVV__c Give the cvv number
Response Body
Success Returns true if successful, else false
AccountName Account Name
AccountId Auto-generated account ID
ContactName Contact Name
ContactIds Auto-generated Contact ID(s)
Payment MethodIds Auto-generated Payment Method IDs
ErrorMessage Description of the error
Argument/Return Type
JSON/ JSON
REST Request: Create Only Account
Request:
{
"Name":"Account Test",
"Phone": "8055555",
"NumberOfEmployees":2
}
Response:
{
"success": true,
"accountName": "Account Test",
"accountId": "001b000000ZpdONAAZ"
}
REST Request: Create Only Contacts
Request:
{
"Contacts":
[{
"FirstName": "001",
"LastName": "Contact",
"Phone": "8055555",
"Birthdate": "2013-01-09"
},
{
"FirstName": "002",
"LastName": "Contact",
"Phone": "8055555"
}]
}
Response:
{
"Contacts": [
{
"contactName": "001 Contact",
"contactId": "003b000000YQ44pAAD"
},
{
"contactName": "002 Contact",
"contactId": "003b000000YQ44qAAD"
}
]
}
REST Request: One Account With One Contact
Request:
{
"Name":"Test Account Sagarika13",
"Phone": "8055555",
"NumberOfEmployees":2,
"Contacts":
[{
"FirstName": "001",
"LastName": "Contact",
"Phone": "8055555"
}]
}
Response:
{
"success": true,
"accountName": "Test Account Sagarika13",
"accountId": "001b000000budU5AAI",
"Contacts": [
{
"contactName": "001 Contact",
"contactId": "003b000000aC7tsAAC"
}
]
}
REST Request: One Account With Two Contacts
Request:
{
"Name":"Account Test",
"Phone": "8055555",
"NumberOfEmployees":2,
"Contacts":
[{
"FirstName": "001",
"LastName": "Contact",
"Phone": "8055555",
"Birthdate": "2013-01-09"
},
{
"FirstName": "002",
"LastName": "Contact",
"Phone": "8055555"
}]
}
Response:
{
"success": true,
"accountName": "Account Test",
"accountId": "0012000001Bs7KXAAZ",
"Contacts": [
{
"contactName": "001 Contact",
"contactId": "0032000001HJetKAAT"
},
{
"contactName": "002 Contact",
"contactId": "0032000001HJetLAAT"
}
]
}
REST Request: One Account With One Payment Method
- Request :
{
"Name":"Test Account Sagarika12",
"Phone": "8055555",
"NumberOfEmployees":2,
"PaymentMethods":
[{
"invoiceit_s__Billing_Company__c": "Invoice IT",
"invoiceit_s__Billing_Email__c": "ss@invoiceit.com"
}]
}
- Response :
{
"success": true,
"accountName": "Test Account Sagarika12",
"accountId": "001b000000budW1AAI",
"PaymentMethods": [
{
"PaymentMethodName": "PM-0142",
"PaymentMethodId": "a0Mb0000003zTjoEAE"
}
]
}
REST Request: One Account With One Contact And One Payment Method
Request:
{
"Name":"Test Account Sagarika11",
"Phone": "8055555",
"NumberOfEmployees":2,
"Contacts":
[{
"FirstName": "001",
"LastName": "Contact",
"Phone": "8055555"
}],
"PaymentMethods":
[{
"invoiceit_s__Billing_Company__c": "Invoice IT",
"invoiceit_s__Billing_Email__c": "ss@invoiceit.com"
}]
}
Response:
{
"success": true,
"accountName": "Test Account Sagarika11",
"accountId": "001b000000budXsAAI",
"Contacts": [
{
"contactName": "001 Contact",
"contactId": "003b000000aC7z1AAC"
}
],
"PaymentMethods": [
{
"PaymentMethodName": "PM-0143",
"PaymentMethodId": "a0Mb0000003zTjyEAE"
}
]
}
REST Request: One Account With One Contact And Two Payment Methods
Request:
{
"Name":"Test Account Sagarika11",
"Phone": "8055555",
"NumberOfEmployees":2,
"Contacts":
[{
"FirstName": "001",
"LastName": "Contact",
"Phone": "8055555"
}],
"PaymentMethods":
[{
"invoiceit_s__Billing_Company__c": "Invoice IT",
"invoiceit_s__Billing_Email__c": "ss@invoiceit.com"
},
{
"invoiceit_s__Billing_Company__c": "Invoice IT1",
"invoiceit_s__Billing_Email__c": "sag@invoiceit.com"
}]
}
Response:
{
"success": true,
"accountName": "Test Account Sagarika11",
"accountId": "001b000000budpIAAQ",
"Contacts": [
{
"contactName": "001 Contact",
"contactId": "003b000000aC8M5AAK"
}
],
"PaymentMethods": [
{
"PaymentMethodName": "PM-0146",
"PaymentMethodId": "a0Mb0000003zTmREAU"
},
{
"PaymentMethodName": "PM-0147",
"PaymentMethodId": "a0Mb0000003zTmSEAU"
}
]
}