# Bulk Update Products

POST https://services.leadconnectorhq.com/products/bulk-update

API to bulk update products (price, availability, collections, delete)

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `products.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/products/bulk-update": {
      "post": {
        "summary": "Bulk Update Products",
        "operationId": "bulkUpdateProducts",
        "description": "API to bulk update products (price, availability, collections, delete)",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkUpdateDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Products updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "products.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "BulkUpdateDto": {
        "type": "object",
        "properties": {
          "altId": {
            "type": "string",
            "description": "Location Id or Agency Id",
            "example": "6578278e879ad2646715ba9c"
          },
          "altType": {
            "type": "string",
            "enum": [
              "location"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "bulk-update-price",
              "bulk-update-availability",
              "bulk-update-product-collection",
              "bulk-delete-products",
              "bulk-update-currency"
            ],
            "description": "Type of bulk update operation",
            "example": "bulk-update-price"
          },
          "productIds": {
            "example": [
              "5f8d0d55b54764421b7156c1"
            ],
            "description": "Array of product IDs",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "filters": {
            "description": "Filters to apply when selectAll is true",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "collectionIds": {
                    "description": "Filter by collection IDs",
                    "example": [
                      "5f8d0d55b54764421b7156c1",
                      "5f8d0d55b54764421b7156c2"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "productType": {
                    "type": "string",
                    "description": "Filter by product type",
                    "example": "one-time"
                  },
                  "availableInStore": {
                    "type": "boolean",
                    "description": "Filter by availability status",
                    "example": true
                  },
                  "search": {
                    "type": "string",
                    "description": "Filter by search term",
                    "example": "blue t-shirt"
                  }
                },
                "title": "BulkUpdateFilters"
              }
            ]
          },
          "price": {
            "description": "Price update configuration",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "INCREASE_BY_AMOUNT",
                      "REDUCE_BY_AMOUNT",
                      "SET_NEW_PRICE",
                      "INCREASE_BY_PERCENTAGE",
                      "REDUCE_BY_PERCENTAGE"
                    ],
                    "description": "Type of price update",
                    "example": "INCREASE_BY_AMOUNT"
                  },
                  "value": {
                    "type": "number",
                    "example": 100,
                    "description": "Value to update (amount or percentage based on type)"
                  },
                  "roundToWhole": {
                    "type": "boolean",
                    "description": "Round to nearest whole number",
                    "example": true
                  }
                },
                "required": [
                  "type",
                  "value"
                ],
                "title": "PriceUpdateField"
              }
            ]
          },
          "compareAtPrice": {
            "description": "Compare at price update configuration",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "INCREASE_BY_AMOUNT",
                      "REDUCE_BY_AMOUNT",
                      "SET_NEW_PRICE",
                      "INCREASE_BY_PERCENTAGE",
                      "REDUCE_BY_PERCENTAGE"
                    ],
                    "description": "Type of price update",
                    "example": "INCREASE_BY_AMOUNT"
                  },
                  "value": {
                    "type": "number",
                    "example": 100,
                    "description": "Value to update (amount or percentage based on type)"
                  },
                  "roundToWhole": {
                    "type": "boolean",
                    "description": "Round to nearest whole number",
                    "example": true
                  }
                },
                "required": [
                  "type",
                  "value"
                ],
                "title": "PriceUpdateField"
              }
            ]
          },
          "availability": {
            "type": "boolean",
            "description": "New availability status"
          },
          "collectionIds": {
            "description": "Array of collection IDs",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "currency": {
            "type": "string",
            "description": "Currency code",
            "example": "USD"
          }
        },
        "required": [
          "altId",
          "altType",
          "type",
          "productIds"
        ],
        "title": "BulkUpdateDto"
      },
      "BulkUpdateResponseDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "boolean",
            "description": "Status of api action",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Success message",
            "example": "Successfully created"
          }
        },
        "required": [
          "status"
        ],
        "title": "BulkUpdateResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/products/bulk-update' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "altId": "6578278e879ad2646715ba9c",
  "type": "bulk-update-price",
  "productIds": [
    "5f8d0d55b54764421b7156c1"
  ],
  "filters": {
    "collectionIds": [
      "5f8d0d55b54764421b7156c1",
      "5f8d0d55b54764421b7156c2"
    ],
    "productType": "one-time",
    "availableInStore": true,
    "search": "blue t-shirt"
  },
  "price": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "compareAtPrice": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "collectionIds": [],
  "currency": "USD"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "altId": "6578278e879ad2646715ba9c",
      "type": "bulk-update-price",
      "productIds": [
        "5f8d0d55b54764421b7156c1"
      ],
      "filters": {
        "collectionIds": [
          "5f8d0d55b54764421b7156c1",
          "5f8d0d55b54764421b7156c2"
        ],
        "productType": "one-time",
        "availableInStore": true,
        "search": "blue t-shirt"
      },
      "price": {
        "type": "INCREASE_BY_AMOUNT",
        "value": 100,
        "roundToWhole": true
      },
      "compareAtPrice": {
        "type": "INCREASE_BY_AMOUNT",
        "value": 100,
        "roundToWhole": true
      },
      "collectionIds": [],
      "currency": "USD"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/products/bulk-update', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/products/bulk-update"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "altId": "6578278e879ad2646715ba9c",
    "type": "bulk-update-price",
    "productIds": [
        "5f8d0d55b54764421b7156c1"
    ],
    "filters": {
        "collectionIds": [
            "5f8d0d55b54764421b7156c1",
            "5f8d0d55b54764421b7156c2"
        ],
        "productType": "one-time",
        "availableInStore": true,
        "search": "blue t-shirt"
    },
    "price": {
        "type": "INCREASE_BY_AMOUNT",
        "value": 100,
        "roundToWhole": true
    },
    "compareAtPrice": {
        "type": "INCREASE_BY_AMOUNT",
        "value": 100,
        "roundToWhole": true
    },
    "collectionIds": [],
    "currency": "USD"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/products/bulk-update',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "altId": "6578278e879ad2646715ba9c",
  "type": "bulk-update-price",
  "productIds": [
    "5f8d0d55b54764421b7156c1"
  ],
  "filters": {
    "collectionIds": [
      "5f8d0d55b54764421b7156c1",
      "5f8d0d55b54764421b7156c2"
    ],
    "productType": "one-time",
    "availableInStore": true,
    "search": "blue t-shirt"
  },
  "price": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "compareAtPrice": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "collectionIds": [],
  "currency": "USD"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/products/bulk-update")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"altId\":\"6578278e879ad2646715ba9c\",\"type\":\"bulk-update-price\",\"productIds\":[\"5f8d0d55b54764421b7156c1\"],\"filters\":{\"collectionIds\":[\"5f8d0d55b54764421b7156c1\",\"5f8d0d55b54764421b7156c2\"],\"productType\":\"one-time\",\"availableInStore\":true,\"search\":\"blue t-shirt\"},\"price\":{\"type\":\"INCREASE_BY_AMOUNT\",\"value\":100,\"roundToWhole\":true},\"compareAtPrice\":{\"type\":\"INCREASE_BY_AMOUNT\",\"value\":100,\"roundToWhole\":true},\"collectionIds\":[],\"currency\":\"USD\"}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/products/bulk-update"
  payload := strings.NewReader(`{
  "altId": "6578278e879ad2646715ba9c",
  "type": "bulk-update-price",
  "productIds": [
    "5f8d0d55b54764421b7156c1"
  ],
  "filters": {
    "collectionIds": [
      "5f8d0d55b54764421b7156c1",
      "5f8d0d55b54764421b7156c2"
    ],
    "productType": "one-time",
    "availableInStore": true,
    "search": "blue t-shirt"
  },
  "price": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "compareAtPrice": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "collectionIds": [],
  "currency": "USD"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/products/bulk-update")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "altId": "6578278e879ad2646715ba9c",
  "type": "bulk-update-price",
  "productIds": [
    "5f8d0d55b54764421b7156c1"
  ],
  "filters": {
    "collectionIds": [
      "5f8d0d55b54764421b7156c1",
      "5f8d0d55b54764421b7156c2"
    ],
    "productType": "one-time",
    "availableInStore": true,
    "search": "blue t-shirt"
  },
  "price": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "compareAtPrice": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "collectionIds": [],
  "currency": "USD"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "altId": "6578278e879ad2646715ba9c",
  "type": "bulk-update-price",
  "productIds": [
    "5f8d0d55b54764421b7156c1"
  ],
  "filters": {
    "collectionIds": [
      "5f8d0d55b54764421b7156c1",
      "5f8d0d55b54764421b7156c2"
    ],
    "productType": "one-time",
    "availableInStore": true,
    "search": "blue t-shirt"
  },
  "price": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "compareAtPrice": {
    "type": "INCREASE_BY_AMOUNT",
    "value": 100,
    "roundToWhole": true
  },
  "collectionIds": [],
  "currency": "USD"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/products/bulk-update' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
