QuickBooks Integration With Salesforce Rest API

by Himanshu Goyal

Hello friends, today we are going to discuss QuickBooks Integration With Salesforce Rest API Using Named Credentials From Flow. Here we will create the Apex class and use Rest API to integrate with QuickBooks. QuickBooks and Salesforce Integration using Apex are very simple. We invoke Apex class from the Lightning flow.

What is QuickBooks

Quickbooks is accounting software for your small business which allows you to create and send invoices, track sales and inform you about how business is doing at a point in time, with accounting data reading in the cloud. 

Why We Need to Integrate with Salesforce to Quickbook

  1. Increase productivity by sharing the data between these.
  2. Achieve better forecasting.
  3. Give better approch for how we complete our goal.

To Integrate the Quickbooks with Salesforce lets layout some Key details First

  1. Requirement : We need some automation in Salesforce so that whenever an Account is created in salesforce that Account should also be created in Quickbooks as well.
  2. Process in QuickBooks : First Sign Up for a developer account with Quickbooks then create an App there then we will create an auth provider and named credential for QuickBooks in sales force.
  3. Process in Salesforce : After setting up Auth provider and named credentials. We will create a flow that will invoke an Apex class and that class will make a call out to the Quickbooks API with a POST request to create a new account in Quickbooks with details sent from salesforce.

Named credentials blog link here.

So in Salesforce After setting up the named credential we will write an Apex class with the Invokable method which we will invoke via the flow.

Code :


public class QuickbooksIntegration{
    public static void CreateAccount(List<Id> accountIds){
       //get account        
       List<Account> accountList = [SELECT id, name from account where id =:accountIds[0]];
      //Data map Preparation
       map<String,Object> mainMap = new map<String,Object>();
       mainMap.put('Name', accountList[0].name);
       mainMap.put('AccountType', 'Accounts Receivable');
       if(mainMap!= null && !mainMap.isEmpty()){
           //Calling Async method for callout 
    @future(callout =true)
    public static void insertOnQuickBook(String jsonData){
		//new request
		HttpRequest req = new HttpRequest();
		string  endPointURL = 'callout:quickbook_named_credentials/v3/company/4620816365165921730/account?minorversion=59';
        req.setHeader('Content-Length', '512');
        Http http = new Http();
        HTTPResponse response = http.send(req);
        //Response Handle
		if(response.getStatusCode() == 200 ){
            Map<String, Object> serializeResponseBody = new Map<String, Object>();
            serializeResponseBody = (Map<String, Object>)JSON.deserializeUntyped(response.getBody());

Create Flow:

After creating the class we are going to create a flow that will run on the creation of Accounts in salesforce. That flow will have an Action type element which will refer to the QuickbooksIntegration class and we also will set the input parameter for the invokable method which will be the current record Id.

QuickBooks Integration With Salesforce Rest API Flow Techdicer
QuickBooks Integration With Salesforce Rest API Flow Techdicer
QuickBooks Integration With Salesforce Rest API
QuickBooks Integration With Salesforce Rest API Flow Techdicer


Reference :

  1. Salesforce
  2. QuickBook
What’s your Reaction?

You may also like


Laxman rao October 15, 2022 - 8:26 pm

Great article thanks, have you done the integration of invoice and invoice lines to quick book invoice? Please let me know

Rijwan Mohmmed October 17, 2022 - 3:41 pm

Hi Laxman Rao, you can try other API as well in this class

Muhammad November 16, 2022 - 8:40 pm

Hi, Thanks for the article. I’ve setup the named credentials for the quickbooks but When I am trying to sync the customer I am gettting 401 unauthorized error. Can you please help me in fixing that?

Abhijeet Kumar February 1, 2023 - 7:50 am

HI I am not able to fetch the customer, Item from quickbook end to salesforce using apex


Leave a Comment