create_variant
POST https://api.bootic.net/v1/products/{product_id}/variants
Create a product variant.
This relation is only available for products owned by your current access token (admin
scope).
HTTP POST
$ curl -XPOST -H'Accept:application/json' -H'Content-Type:application/json' -H "Authorization: Bearer xxxx" -i https://api.bootic.net/v1/products/:product_id/variants -d[REQUEST_BODY]
Request body
{
"title": "Some variant",
"sku": "sv-123",
"stock": 100,
"available_if_no_stock": true,
"weight_in_grams": 230
}
- title
- Variant title. Required,
- 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. Defaulttrue
. - weight_in_grams
- Variant weight, in grams, no punctuation. Optional.
Successful response
Status: 201 Created
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"
]
}
]
}
}