COMPOSITE API Bunch Multiple Calls within a Single API Request

Composite API is a design approach to bundle API requests consecutively into a single API call. 

Now a client doesn’t need multiple round trips to a server but can make one API request with a series of calls and gain one response.

 

It provides a choice to make numerous combined Callouts to the Salesforce and facility to refer the values between all nodes in the body request.

 

For example, if you have created an account using the REST API call and now you want to create 10 Contacts, you need to write a trigger in the Account. But by leveraging the composite API feature, you can create Contacts together with the Account in one single API call.

 

How to Design a Composite API:

 A composite API doesn’t require creating a brand new API but augmenting the existing REST API design will do. Regardless of these criteria, you have several considerations for composite API design:

 

  • Request representation: At the lowest, an array of objects which includes the method, endpoint, and a way to pass data/ parameters with each request is required.

 

  • Authentications: You need to find if the credentials will be passed from the composite call to single requests or require granular authentication for every underlying call?

 

  • Response rendering: It is required to include the response from the closing request. Seemingly, some subset of response data from preceding steps should be too included. 

 

  • Field references: Sequential calls will be most effective when included data from previous steps, meaning you need to determine how to shape those references.

 

  • Error handling: If single or multiple calls in your sequence return an error, you need to put forward details to aid consumers in debugging the response.

 

  • Partial successes: Besides reporting errors, you need to choose whether to carry on with the steps after the error or not.

 

  • All or none: Some use cases perhaps expect transactional features, where an error “rolls back” any alteration in earlier steps.

 

Your decisions based on these considerations will affect the design of your composite API. 

 

Summing Up: 

Salesforce set forth the Composite API with the vision to make the callouts parallelly. It helps in reducing time because there’s only one need to construct the payload. 

A composite API extends a design solution that is more capable with only one request needed instead of five or more. 

It also facilitates non-developers in easy execution of the complex DML operations.

 

CEPTES is a global Salesforce service provider with dedicated professional CRM services for accelerating the business value of your Salesforce investment. 

 

Connect with us today