SAP Integration Application Guide

This guide outlines the integration process for incorporating SAP records into NextBillion's Route Optimization API using the Retool development suite.

Step 1: SAP Records Retrieval

To retrieve customer records and their address details from SAP, execute the following cURL command:

1# Fetch customer data from SAP
2curl --location '' \
3--header 'APIKey: <SAP_API_Key>' \
4--header 'Accept: application/json' \
5--header 'DataServiceVersio: 2.0'

The response will contain an array of customer records with address details in JSON format.

2 "@odata.context": "$metadata#FrtOrdStopLocAddrDfltRprstn",
3 "@odata.metadataEtag": "W/"20231014225153"",
4 "value": "[...]"

The subsequent cell visualizes the above API response.

SAP Records Retrieval

Step 2: Vehicle Records

In this integration, we employed randomly generated vehicles. The CSV-formatted details of these vehicles were uploaded to the Database and leveraged for optimization. Users have the flexibility to integrate their own fleet/vehicle records into the optimization process. If vehicle records are available in SAP, they can be seamlessly pulled and incorporated into the optimization workflow.

The following image visualizes the vehicles dashboard.

Vehicle Records

Step 3: Integration with Route Optimization API

Following the successful retrieval of essential data from SAP, seamlessly integrate the fetched information with Route Optimization using the specified API endpoint. Effectively map the SAP data to the relevant API parameters and configure optimization settings, including shift start and end times, as well as service times.

This code snippet manages the integration process, ensuring a smooth connection between SAP data and Route Optimization API.

2let vehicles = [];
3let shifts = [];
4let starts = [];
5let ends = [];
6let veh_attr = [];

Step 4: Create Optimization Jobs

Initiate the creation of optimization jobs by sending a POST request to's Route Optimization API with specified parameters. Confirm the successful job creation through the received API response.

Here's an example of the POST query using cURL:

1curl --request POST \
2 --url{{localStorage.values.apiKey}}

Upon successful execution, the API response will confirm the creation of the optimization job:

2 "id": "daa1725f45c6c1e9aa184dca568d596c",
3 "message": "Optimization job created",
4 "status": "Ok"

This response provides essential information, including the job ID, a confirmation message, and the status 'Ok,' indicating the successful creation of the optimization job.

Step 5: Optimized Route Result Retrieval

Retrieve the optimized route result by making a GET request to the Route Optimization API with the job ID and API key.

Below is an example of the GET query:


Upon successful retrieval, the API responds with a JSON structure, providing crucial details about the optimized route. Here's an example of the JSON response:

2 "result": "{...}",
3 "status": "Ok",
4 "message": ""

This response includes detailed information such as total cost, the number of routes, service and duration metrics, and individual steps for each route, offering a comprehensive overview of the optimized route result.

Step 6: Visualize Optimized Routes

After successfully fetching the data and setting up the Route Optimization API, initiate the API to generate optimized routes. To visualize the generated routes, you can view them on NextBillion's Optimizer using the following link:


This link directs you to the Optimizer interface, providing a convenient way to inspect and analyze the optimized routes generated by the Route Optimization API. Simply replace the placeholders with your API key and the request ID obtained from the API response for seamless integration and route assessment.

Below is a snippet showcasing the visual representation of the generated routes within the tester interface.

Visualize Optimized Routes

Step 7: Retrieve Optimization Results in SAP

To access the outcome of the optimization process within the SAP system, employ a GET request. In your SAP instance, craft a GET request with the specified details:

1curl -X GET "<Optimization Result ID>&key=< API Key>" -H "accept: application/json"
2-H "Authorization: User <User Secret of SAP>=, Organization 359ad019a15fd3e02f4353c53a489827, Element w8SQ6cP+l4qBgFpbcHd/mMIoorCZUYiiEu0KxrYY/QM="

This request will retrieve the optimization results from and integrate them seamlessly into your SAP environment. Ensure that you replace <Optimization Result ID> and < API Key> with the corresponding values for your specific optimization run.

Upon successful execution, the JSON response within SAP will contain the detailed optimization results, providing valuable insights into the routes and associated data generated by the optimization process.

Retrieve Optimization Results in SAP

SAP, with its extensive capabilities, offers a multitude of integration possibilities. This guide outlines one approach to seamlessly integrate SAP with NextBillion's Route Optimization API. While the SAP Integration Suite provides a robust toolkit for integrating diverse applications and systems, it's essential to note that it's not the sole method for integration. There are alternative methods and technologies available, and the choice depends on your specific SAP system.

Selecting the appropriate integration method hinges on your unique requirements and existing infrastructure. SAP offers a range of options to cater to various integration scenarios, allowing you to choose the approach that aligns best with your needs.