Update SKU
Change or modify an SKU.
This method triggers the SKU Updated webhook. This webhook contains the same information as the response.
sku
ID of the
sku
object. String starting with sku_.
active
Indicates whether the product is currently being sold. Default is false.
attributes
Up to 5 alphanumeric key-value pairs defined by the merchant. Each key must match a string in the
attributes
list of the correspondingproduct
object.
currency
Three-letter ISO 4217 code for the currency used in the
price
field.
image
URL of image associated with the product.
inventory
Contains the following fields:
package_dimensions
Physical attributes of the SKU item. Contains the following fields:
height
length
weight
width
These fields are represented as numbers, but it is the responsibility of the merchant to define and interpret the relevant units of length and weight.
price
Price of one unit. Decimal.
product
ID of the product that this SKU relates to.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string sku = "sku_a6d86bdc6f3a7ef6cb51de5a5678493f"; var metadata = new { merchant_defined = "updated" }; var requestObj = new { metadata, price = 10.99, }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/skus/{sku}", request); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const body = { active: false }; const result = await makeRequest('POST', '/v1/skus/sku_a6d86bdc6f3a7ef6cb51de5a5678493f', body); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); try { $body = [ "metadata"=> array( "merchant_defined" => "updated" ), "price"=> 10.99 ]; $object = make_request('post', '/v1/skus/sku_a6d86bdc6f3a7ef6cb51de5a5678493f', $body); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request sku = { "metadata": { "merchant_defined": "updated" }, "price": 10.99 } result = make_request( method='post', path='/v1/skus/sku_a6d86bdc6f3a7ef6cb51de5a5678493f', body=sku) pprint(result)
/v1/skus/:sku
Update SKU
curl -X post https://sandboxapi.rapyd.net/v1/skus/sku_a6d86bdc6f3a7ef6cb51de5a5678493f -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here' -d '{ "metadata": { "merchant_defined": "updated" }, "price": 10.99 } '
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "a5f938a8-3086-445a-bf9a-f1c9d97adde2" }, "data": { "id": "sku_a6d86bdc6f3a7ef6cb51de5a5678493f", "active": true, "attributes": { "color": "green" }, "created_at": 1546353713, "currency": "USD", "image": "", "inventory": { "type": "finite", "quantity": 1, "value": "" }, "metadata": { "merchant_defined": "updated" }, "price": 10.99, "product": "product_f383d03c34fb499eb3ada4e3c574002a", "package_dimensions": { "length": 2, "height": 1, "weight": 3, "width": 4 }, "updated_at": 1546354288 } }