Skip to main content

Documentation

Create SKU

Create an SKU and attach it to a product.

Relevant to products where type is goods. You can attach several SKUs to a single product.

This method triggers the SKU Created webhook. This webhook contains the same information as the response.

Note

If the product defined an array of attributes, then you must include an attributes object that assigns values to those attributes, as in the example below.

    • active

    • Indicates whether the product is currently available for purchase.

      false

    • currency

    • Three-letter ISO 4217 code for the currency used in the price parameter.

    • id

    • ID of the sku object. Alphanumeric characters and underscores (_). If the client does not provide this value, Rapyd creates a string starting with sku_.

    • image

    • URL of image associated with the product.

    • inventory

    • Describes the items packaged together as a SKU item.

    • price

    • The amount of the price. Decimal.

    • product

    • ID of the product that this SKU relates to. The type field of the product must be set to goods.

Code Samples
    • .NET

      • using System;
        using System.Text.Json;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        var attributes = new 
                        {
                                  color = "green"
                        };
        
                        var inventory = new 
                        {
                            quantity = 1,
                            type = "finite",
                            value = 600,
                        };
        
                        var metadata = new 
                        {
                            merchant_defined = true
                        };
        
                        var package_dimensions = new 
                        { 
                            length = 2,
                            height = 1,
                            weight = 3,
                            width = 4,
                        
                        };
        
                        var requestObj = new
                        {
                            id = "",
                            active = true,
                            attributes,
                            currency = "USD",
                            image = (string) null,
                            inventory,
                            metadata,
                            package_dimensions,
                            price = 600,
                            product = "product_f383d03c34fb499eb3ada4e3c574002a",
                        };
        
                        string request = JsonSerializer.Serialize(requestObj);
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("POST", "/v1/skus", 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 = {
              id: '',
              active: true,
              attributes: {
                color: 'green'
              },
              currency: 'USD',
              image: null,
              inventory: {
                quantity: 1,
                type: 'finite',
                value: 600
              },
              metadata: {
                merchant_defined: 'true'
              },
              package_dimensions: {
                length: 2,
                height: 1,
                weight: 3,
                width: 4
              },
              price: 600,
              product: 'product_f383d03c34fb499eb3ada4e3c574002a'
            };
            const result = await makeRequest('POST', '/v1/skus', 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);
        // Message body:
        //{
        //    "product": "product_f383d03c34fb499eb3ada4e3c574002a",
        //    "price":600,
        //    "inventory": {
        //    "quantity": 1,
        //        "type": "finite",
        //        "value": 600
        //      }
        //}
        $body = [
            "product" => "product_f383d03c34fb499eb3ada4e3c574002a",
            "price" => 600,
            "inventory" => array(
                "quantity" => 1,
                "type" => "finite",
                "value" => 600
            )
        ];
        
        try {
            $object = make_request('post', '/v1/skus', $body);
            var_dump($object);
        } catch(Exception $e) {
            echo "Error: $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        sku = {
            "active": True,
            "attributes": {
                "color": "green"
            },
            "currency": "USD",
            "inventory": {
                "quantity": 1,
                "type": "finite",
                "value": 600
            },
            "metadata": {
                "merchant_defined": True
            },
            "package_dimensions": {
                "length": 2,
                "height": 1,
                "weight": 3,
                "width": 4
            },
            "price": 600,
            "product": "product_f383d03c34fb499eb3ada4e3c574002a"
        }
        result = make_request(method='post', path='/v1/skus', body=sku)
        pprint(result)
        
  • /v1/skus

  • Create SKU

  • curl -X post
    https://sandboxapi.rapyd.net/v1/skus
    -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 '{
        "id": "",
        "active": true,
        "attributes": {
            "color": "green",
            "arm_rest": true
        },
        "currency": "USD",
        "image": null,
        "inventory": {
            "quantity": 1,
            "type": "finite",
            "value": 600
        },
        "metadata": {
            "merchant_defined": true
        },
        "package_dimensions": {
            "length": 2,
            "height": 1,
            "weight": 3,
            "width": 4
        },
        "price": 600,
        "product": "product_1228f5334ea6cee9052137b85db1699b"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "9371db29-4304-4b36-9004-cb98539bb941"
        },
        "data": {
            "id": "sku_de7d491598e013008959aa8484438fc8",
            "active": true,
            "attributes": {
                "color": "green",
                "arm_rest": true
            },
            "created_at": 1675845778,
            "currency": "USD",
            "image": "",
            "inventory": {
                "type": "finite",
                "quantity": 1,
                "value": ""
            },
            "metadata": {
                "merchant_defined": true
            },
            "price": 600,
            "product": "product_1228f5334ea6cee9052137b85db1699b",
            "package_dimensions": {
                "length": 2,
                "height": 1,
                "weight": 3,
                "width": 4
            },
            "updated_at": 1675845778
        }
    }