update_variant

PUT https://api.bootic.net/v1/shops/{shop_id}/variants/{id}

Update a product variant.

This relation is only available for products owned by your current access token (admin scope).

HTTP PUT

$ curl -XPUT -H'Accept:application/json' -H'Content-Type:application/json' -H "Authorization: Bearer xxxx" -i https://api.bootic.net/v1/shops/:shop_id/variants/:id -d[REQUEST_BODY]

Request body

You can use this relation for partial updates, by including only the attributes that you want to update in the payload.

{
  "title": "Some variant",
  "sku": "sv-123",
  "stock": 100,
  "available_if_no_stock": true,
  "weight_in_grams": 230
}
title
Variant title. Optional.
sku
Variant Stock Keeping Unit code. Must be unique in shop. Optional.
stock
Variant stock number. Optional.
available_if_no_stock
Availability policy. true for always available, false for available only if in stock.
weight_in_grams
Variant weight, in grams, no punctuation. Optional.

Successful response

Status: 200 OK
Content-Type: application/json; charset=utf-8
Connection: keep-alive
ETag: "0728e2965bd03e20a7f1c33add2f8775"
Last-Modified: Fri, 20 Jun 2014 22:34:14 GMT
Cache-Control: must-revalidate, private, max-age=0
Date: Wed, 31 Jul 2013 21:11:52 GMT
X-OAuth-Scopes: admin
{
  "_class": [
    "variant"
  ],
  "_links": {
    "self": {
      "href": "https://api.bootic.net/v1/shops/453/variants/145812"
    },
    "btc:update_variant": {
      "href": "https://api.bootic.net/v1/shops/453/variants/145812",
      "title": "Update a product variant",
      "method": "put"
    },
    "btc:delete_variant": {
      "href": "https://api.bootic.net/v1/shops/453/variants/145812",
      "title": "Remove a product variant",
      "method": "delete"
    }
  },
  "title": "Some variant",
  "id": 145812,
  "stock": 100,
  "available_if_no_stock": true,
  "sku": "sv-123",
  "weight_in_grams": 230,
  "price": 12333,
  "price_comparison": 122234
}

A succesful response returns a variant entity including links to further actions.
See update_variant and delete_variant for more.

Invalid response

Status: 422 Unprocessable Entity
Content-Type: application/json; charset=utf-8
Connection: keep-alive
ETag: "0728e2965bd03e20a7f1c33add2f8775"
Last-Modified: Fri, 20 Jun 2014 22:34:14 GMT
Cache-Control: must-revalidate, private, max-age=0
Date: Wed, 31 Jul 2013 21:11:52 GMT
X-OAuth-Scopes: admin
{
  "_class": [
    "errors"
  ],
  "_embedded": {
    "errors": [
      {
        "_class": [
          "error"
        ],
        "field": "variant.title",
        "messages": [
          "can't be blank"
        ]
      }
    ]
  }
}

Updating variant by SKU

Optionally, you can identify a variant by its SKU (Stock Keeping Unit), which is unique per shop, instead of its :id. So for a variant with SKU “abc” and shop id “123”, do this:

PUT https://api.bootic.net/v1/shops/123/variants/abc

This can be useful when syncronizing data directly from 3rd party data sources.