Update Variant By SKU

🔒

Requires write_product access scope. More access scope

The Update Variant by SKU API allows users to update the details of a specific product variant using its SKU. This endpoint is useful for managing inventory, pricing, and other variant-specific attributes by targeting the unique SKU of a variant. It provides flexibility in updating multiple fields of the variant in a single API call.This API is especially useful for:

  1. Update inventory and pricing details for a specific SKU.
  2. Modify metadata such as barcode, weight, or custom notes for better variant management.

Note: The operation is scoped to a specific shop, identified by its unique domain prefix (shopdomain), ensuring all updates are applied to the correct store.

Public Request Parameters

Parameter NameTypeRequiredParameter LocationParameter ValueDescription
Access-TokenStringYesHeaderBx-_5aV
eXNwl-4AB98s5xLV
yg0fNzGf

MuTpqtlBA
Used to authenticate API requests. Obtain an access token from the Access Token Guide.
Pass it in the Authorization header for every request.
Content-TypeStringYesHeaderapplication
/json
Indicates the media type of the request body. It tells the server how to parse the request and
the client how to interpret the response. For more details, visit Content-Type.

Public Response Parameters

Parameter NameTypeMandatoryParameter LocationExample ValueDescription
errorStringNoResponse Body{ "error": "store is not active" }Indicates an error encountered during the process. This field typically appears when the Access Token is missing or invalid. Example: { "error": "store is not active" }.
errorsArrayNoResponse Body{ "errors"["No Context"] }A list of errors that occurred during the request processing. Example: { "errors": [ "No Context" ] }.
Request-IdStringYesHeaderBx-_5aV
eXNwl-4AB98s5xLV
yg0fNzGf

MuTpqtlBA
A unique identifier for each request. It helps in identifying and debugging specific requests.

Error and Errors Clarification:

Added explanation that the error and errors fields are currently dependent on the API implementation, with plans for future unification.

Request Parameters

Path Parameters

ParameterTypeRequiredExampleDescription
skustringYes"ABC123"SKU of the product to retrieve variants.

Body Parameters

FieldTypeRequiredExampleDescription
compare_at_pricestringNo"99.99"The original price of the variant before discount.
pricestringNo"79.99"The current price of the variant.
barcodestringNo"123456789"The barcode for the variant for inventory or sales tracking.
notestringNoSeasonal saleCustom notes or remarks for the variant.
inventory_quantityintNo100The current inventory level for the variant.
weightstringNo"1.5"The weight of the variant.
weight_unitstringNokgThe unit of measurement for the weight. (e.g., kg, g, lb, oz)
cost_pricestringNo"50.00"The cost price of the variant.
retail_pricestringNo"120.00"The recommended retail price for the variant.
refuse_multi_resultboolNotruefalse: If sku matches multiple sub-items, update the matched sub-items normally.
true: Rejects the update if the sku matches more than one subitem

Response Explanation

Successful Response

FieldTypeExampleDescription
variantsarrayarray of variant object
variants[ ].idstring1b735278-62c7-41ad-9976-b1b63a90590dUnique identifier for the variant.
variants[ ].product_idstring636a07da-39eb-4829-bde9-b65fae1c28b0Unique identifier for the associated product.
variants[ ].image_idstring91d032e7-bbc8-47e4-8668-9ba6fe714de6Unique identifier for the associated image.
variants[ ].created_atstring (date)2024-04-15T02:00:57ZTimestamp indicating when the variant was created.
variants[ ].updated_atstring (date)2024-04-15T02:00:57ZTimestamp indicating when the variant was last updated.
variants[ ].titlestringS-redTitle of the variant.
variants[ ].option1stringSFirst option value for the variant (e.g., size).
variants[ ].option2stringredSecond option value for the variant (e.g., color).
variants[ ].option3string""Third option value for the variant, if applicable.
variants[ ].imageobjectImage Object
variants[ ].image.srcstring//cdn.shoplazza.com/efd33b921cacd5311a32dd03a9bc8740.pngURL of the image associated with the variant.
variants[ ].image.widthinteger1588Width of the variant image in pixels.
variants[ ].image.heightinteger2246Height of the variant image in pixels.
variants[ ].image.pathstringefd33b921cacd5311a32dd03a9bc8740.pngFile path of the variant image.
variants[ ].image.altstring""Alternative text for the variant image.
variants[ ].positioninteger1Position of the variant in the product's variant list.
variants[ ].compare_at_pricestring100.00Original price of the variant before discounts.
variants[ ].pricestring100.00Current price of the variant.
variants[ ].skustringS-REDStock Keeping Unit (SKU) for the variant.
variants[ ].barcodestring123Barcode associated with the variant.
variants[ ].notestrings-redNotes or additional information about the variant.
variants[ ].inventory_quantityinteger10Number of items available in inventory for the variant.
variants[ ].weightstring0.10Weight of the variant.
variants[ ].weight_unitstringkgUnit of measurement for the weight (e.g., kg, lb).
variants[ ].cost_pricestring11.00Cost price of the variant.
variants[ ].wholesale_priceobjectwholesale price object
variants[].wholesale_price.pricestring100.00Wholesale price for the variant.
variants[].wholesale_price.min_quantityinteger1Minimum quantity required to avail the wholesale price.
variants[ ].retail_pricestring1

Error Response

Error responses in the API can be represented using two different fields: errors and error. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.

FieldTypeExampleDescription
errorsArray["Record not found"]A list of errors encountered during the request processing.
FieldTypeExampleDescription
errorArray "store is not active"Indicates an error encountered during the process.

Request Examples

curl --request PUT \
     --url https://{shopdomain}.myshoplazza.com/openapi/2022-01/variants/sku/{sku} \
     --header 'accept: application/json' \
     --header 'access-token: {your-access-token}' \
     --header 'content-type: application/json' \
     --data '{
       "compare_at_price": 99.99,
       "price": 79.99,
       "barcode": "123456789",
       "note": "Seasonal sale",
       "inventory_quantity": 100,
       "weight": 1.5,
       "weight_unit": "kg",
       "cost_price": 50.00,
       "retail_price": 120.00,
       "refuse_multi_result": true
     }'

Success Response Example

{
  "variants": [
    {
      "id": "88e68830-4ef5-4125-bf7d-aef8047176b2",
      "product_id": "a1a88be0-a1d4-47e4-a2f2-ba6e131cf447",
      "image_id": "8ef098c5-5a08-44b4-b5fb-89214bb507dc",
      "created_at": "2024-04-17T02:15:18Z",
      "updated_at": "2024-04-17T02:15:18Z",
      "title": "S-blue-T",
      "option1": "S",
      "option2": "blue",
      "option3": "T",
      "image": {
        "src": "//cdn.shoplazza.com/ccf0794c594bad32a320eea0d6bfe40c.jpeg",
        "width": 174,
        "height": 180,
        "path": "ccf0794c594bad32a320eea0d6bfe40c.jpeg",
        "alt": ""
      },
      "position": 1,
      "compare_at_price": "12.10",
      "price": "10.10",
      "sku": "T-M-S-blue-T-A001004",
      "barcode": "6929000212340",
      "note": "node",
      "inventory_quantity": 16,
      "weight": "1.10",
      "weight_unit": "kg",
      "cost_price": "1.10",
      "wholesale_price": [
        {
          "price": "10.10",
          "min_quantity": 1
        }
      ],
      "retail_price": "0.00"
    }
  ]
}

Error Response Example

{
  "errors": [
   "Record not found"
  ]
}
{
  "error": "store is not active"
}

Error Details

Status CodeMessagePossible ReasonExample Response
400Bad RequestInvalid input format or request structure (e.g., missing required fields or incorrect data types).Bad Request
UnauthorizedThe request is missing valid authentication credentials or the credentials provided are invalid.Unauthorized
4221.sku Not Found,2.Invalid or empty sku1.The variant SKU provided in the request does not exist.
2. Missing or invalid SKU
{ "errors": ["Record not found"] }
Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!