Skip to content

Update a product ​

Endpoint: https://api.youcan.shop/products/update/{id}

Method: POST

Required Scopes ​

  • edit-products

Parameters ​

Send only the fields you want to change. An omitted field keeps its current value.

  • A list you send (images, variants, variant_options, categories, vendors) replaces the current list. An omitted list is not changed.
  • variant_options must come with variants.
  • variants must come with has_variants. To add variants to a product that has none, send has_variants: true with variants and variant_options.
  • compare_at_price must be greater than price. When you send only one of them, the other is checked at its current value.
Param NameParam TypeDescriptionRequired
namestringProduct nameno
descriptionstringProduct descriptionno
visibilityboolIs product visible for customersno
track_inventoryboolShould the inventory be tracked?no
inventoryintProduct stockno
skustringProduct SKU in case it has no variantsno
has_variantsboolProduct contain variants?no
pricefloatProduct priceno
compare_at_pricefloatProduct compare priceno
cost_pricefloatProduct cost priceno
variant_optionsarrayList of product variant options.no
categoriesstring[]List of categories IDs to attach to productno
variantsarrayList of product variants.no
vendorsarray OR string[]List of tags/vendors to assign to product.no
imagesarrayList of product images.no

Variant Options ​

Ex: [{"name": "Size", "type": 4, "values": ["M", "L"]}]

Variants ​

Param NameParam TypeDescriptionRequired
variationsobjectKey, value pair of select variation. Ex: {"Color": "Red", "Size": "M"}yes
pricefloatVariant price. Default to product price.no
weightfloatVariant weight.no
skustringVariant SKU.no
barcodestringVariant barcode.no
inventoryintVariant inventory.no
imagestringVariant image path if any.no

Images ​

Param NameParam TypeDescriptionRequired
namestringImage path or full URLyes
orderintCan be used to specify the images order in listingno
typeint1=image OR 2=external video link (ex: YouTube, Vimeo, etc)yes

Response ​

[201] Created

json
{
    "id": "469fd6f9-8f55-4fc4-86a7-baeaa5250eae",
    "name": "Amazing watch for me",
    "slug": "amazing-smart-watch",
    "public_url": "https://maroc.youcan.shop/products/amazing-smartwatch",
    "thumbnail": "https://cdn.ycan.shop/stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD_md.jpeg",
    "description": "very long description",
    "price": 101,
    "compare_at_price": 203,
    "cost_price": null,
    "visibility": true,
    "has_variants": true,
    "variants_count": 1,
    "variant_options": [
        {
            "name": "Design",
            "type": 6,
            "values": ["upload-zone"]
        }
    ],
    "inventory": 0,
    "track_inventory": true,
    "you_save_amount": 103,
    "meta": {
        "title": "Amazing smartwatch",
        "description": "Smart Watch, Fitness Tracker with Heart Rate Monitor, Activity Tracker with 1.3\" Touch Screen, IP68 Waterproof Pedometer Smartwatch with Sleep Monitor",
        "images": []
    },
    "created_at": "2020-02-10T11:38:29+00:00",
    "updated_at": "2020-06-02T12:31:35+00:00",
    "deleted_at": false,
    "images": [
        {
            "id": "ca6ee0a7-eb6e-4d75-8f44-bf08cd64258c",
            "name": "stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD.jpeg",
            "type": 1,
            "url": "https://cdn.ycan.shop/stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD.jpeg",
            "order": 1,
            "variations": {
                "original": "https://cdn.ycan.shop/stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD.jpeg",
                "sm": "https://cdn.ycan.shop/stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD_sm.jpeg",
                "md": "https://cdn.ycan.shop/stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD_md.jpeg",
                "lg": "https://cdn.ycan.shop/stores/maroc/products/FyRohvIKye2sbq6MzOf1KAnGiYB1Xt5vRZ7m4xzD_lg.jpeg"
            }
        },
        {
            "id": "e154633a-2784-4366-97ac-7ff561326b4a",
            "name": "stores/maroc/products/M7jAkVcg4QhWD0htcvIT7mWm0Mpo7OqxWSRFaJpv.jpeg",
            "type": 1,
            "url": "https://cdn.ycan.shop/stores/maroc/products/M7jAkVcg4QhWD0htcvIT7mWm0Mpo7OqxWSRFaJpv.jpeg",
            "order": 2,
            "variations": {
                "original": "https://cdn.ycan.shop/stores/maroc/products/M7jAkVcg4QhWD0htcvIT7mWm0Mpo7OqxWSRFaJpv.jpeg",
                "sm": "https://cdn.ycan.shop/stores/maroc/products/M7jAkVcg4QhWD0htcvIT7mWm0Mpo7OqxWSRFaJpv_sm.jpeg",
                "md": "https://cdn.ycan.shop/stores/maroc/products/M7jAkVcg4QhWD0htcvIT7mWm0Mpo7OqxWSRFaJpv_md.jpeg",
                "lg": "https://cdn.ycan.shop/stores/maroc/products/M7jAkVcg4QhWD0htcvIT7mWm0Mpo7OqxWSRFaJpv_lg.jpeg"
            }
        },
        {
            "id": "814eacc7-72ec-4744-8736-ca38337e31bf",
            "name": "stores/maroc/products/azcMFaHxrsc9rWqPVhNH1bzK06evi0JimoA2Qh51.jpeg",
            "type": 1,
            "url": "https://cdn.ycan.shop/stores/maroc/products/azcMFaHxrsc9rWqPVhNH1bzK06evi0JimoA2Qh51.jpeg",
            "order": 3,
            "variations": {
                "original": "https://cdn.ycan.shop/stores/maroc/products/azcMFaHxrsc9rWqPVhNH1bzK06evi0JimoA2Qh51.jpeg",
                "sm": "https://cdn.ycan.shop/stores/maroc/products/azcMFaHxrsc9rWqPVhNH1bzK06evi0JimoA2Qh51_sm.jpeg",
                "md": "https://cdn.ycan.shop/stores/maroc/products/azcMFaHxrsc9rWqPVhNH1bzK06evi0JimoA2Qh51_md.jpeg",
                "lg": "https://cdn.ycan.shop/stores/maroc/products/azcMFaHxrsc9rWqPVhNH1bzK06evi0JimoA2Qh51_lg.jpeg"
            }
        }
    ]
}