Mass Updating Dropship Providers

Git RepositoryEdit on Github
Last update: 2 years ago by luigi mangaReading time: 2 min

While managing a large database of dropship providers, it may be necessary to mass update some properties (e.g. commission rates).

This can be done programmatically by using Onport's API.

The below script shows how to set a commissionRate of 20.00 to all the Dropship Providers having a tag named test

import Bottleneck from 'bottleneck';
import pino from 'pino';
import request from 'request-promise-native';
const logger = pino({
prettyPrint: true,
const limiter = new Bottleneck({
maxConcurrent: 1,
minTime: 2000,
// Throttle the requests
const throttle = async (...params) => limiter.schedule(() => request(...params));
const headers = {
Authorization: `Bearer ${process.env.TOKEN}`,
const tags = ["test"];
const payload = {
commissionRate: "20.00"
const go = async () => {'Fetching List of Dropship Providers');
const dropshipProviders = await throttle({
method: 'GET',
uri: `${process.env.API_HOST}/api/dropship-providers.json`,
json: true,
qs: {
where: {
internalTags: {
$contains: tags
});'Making PUT request with following payload:');;,'dropshipments to be updated');
for(const dropshipProvider of dropshipProviders) {"Updating Dropship Provider ID",;
const putDropshipProvider = await throttle({
method: 'PUT',
uri: `${process.env.API_HOST}/api/dropship-providers/${}.json`,
json: true,
body: payload
if(putDropshipProvider && {"Dropship Provider",,"updated");
}else{"Unable to update Dropship Provider",;

The script expects the following environment variables

โŒจ๏ธ Dropship Providers โ€” Previous
Creating Dropship Provider Addresses
Next โ€” ๐Ÿ’ป Vendor Integration
Real Time Inventory Update