Create a new product variant

post
/products/{id}/variants

Create a new variant for the specified product.

as-store-id
string
required

This value equals to store.id of Store Resource. You can obtain this id by making a GET /stores call to get existing stores or a POST /stores to create a new store.

id
string
required

A unique identifier for the product variant in your system.

<= 32 characters
Example:
5634477687
sku
string
required

The product SKU of the product variant.

<= 1024 characters
Example:
SKU001
price
string
required

The price of the product variant.

<= 100 characters
Example:
10
available_quantity
integer

Available quantity of the product variant.

Example:
1
image_urls
array[string]

The product image URL of the product variant.

<= 100 items
title
string

The title of the product variant.

<= 1024 characters
Example:
Power Mobile Phone
compare_at_price
string

The original price of the item before an adjustment or a sale.

<= 100 characters
weight
Weight

The weight information of the product variant.

Example:
{"unit":"kg","value":10}
unit
string

The weight unit eg: g or kg.

Allowed values:
kglbozg
value
number

The value of the weight.

Example:
10
hs_code
string

Harmonized System (HS) Codes.

<= 256 characters
Example:
6403911600
origin_country_region
string

The origin country of this product variant. The field should be in ISO 3166-1 alpha-3 format.

Example:
AUS
Match pattern:
^[A-Z]{3}$
allow_backorder
boolean

To specify whether customers are permitted to place an order for this out-of-stock product variant.

options
array[object]

The custom product variant properties, such as size, color, and material.

>= 1 items
name
string

The field name of the custom product property.

<= 256 characters
Example:
color
value
string

The value of the custom product property.

<= 256 characters
Example:
white

Variant created successfully

meta
Meta

The Meta model holds the metadata of the API response, including relevant error details for debugging purposes.Show all...

Example:
{"code":20000,"type":"OK","message":"The request was successfully processed by AfterShip."}
code
number
required

Error code in integer format. For detailed information, please refer to the Request Error introduction page.

Default:
20000
Example:
20000
type
string
required

Response type string for the reference. For detailed information, please refer to the Request Error introduction page.

>= 1 characters
Example:
OK
message
string
required

Human-readable response message. For detailed information, please refer to the Request Error introduction page.

>= 1 characters
Example:
The request was successfully processed by AfterShip.
errors
array[Error]

Error detail object. Each error object contains a "path" key and an "info" key. The "path" is the JSON path of the request object to indicate the error location. The "info" is a human-readable description of the error.Show all...

data
object
variant
product_variant.v1
Auth
:
Parameters
:
Body
{ "id": "5634477687", "sku": "SKU001", "price": "10", "available_quantity": 1, "image_urls": [ "https://example.com/product/image.png" ], "title": "Power Mobile Phone", "compare_at_price": "string", "weight": { "unit": "kg", "value": 10 }, "hs_code": "6403911600", "origin_country_region": "AUS", "allow_backorder": true, "options": [ { "name": "color", "value": "white" } ] }
Response Example
{ "meta": { "code": 20000, "type": "OK", "message": "The request was successfully processed by AfterShip." }, "data": { "variant": { "id": "5634477687", "sku": "SKU001", "price": "10", "available_quantity": 1, "image_urls": [ "https://example.com/product/image.png" ], "title": "Power Mobile Phone", "compare_at_price": "string", "weight": { "unit": "kg", "value": 10 }, "hs_code": "6403911600", "origin_country_region": "AUS", "allow_backorder": true, "options": [ { "name": "color", "value": "white" } ] } } }