Create a price
How to create a price via API
To create a new price, send a POST
request to the /api/prices
endpoint, passing the resource arguments in the request body.
Request
POST https://yourdomain.commercelayer.io/api/prices
Arguments
Body Parameter
Type
Required
type
string
Required
attributes.sku_code
string
Optional
attributes.amount_cents
integer
Required
attributes.compare_at_amount_cents
integer
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.rules
object
Optional
attributes.metadata
object
Optional
relationships.price_list
object
Required
relationships.sku
object
Required
relationships.price_tiers
array
Optional
Example
The following request creates a new price:
curl -g -X POST \
'https://yourdomain.commercelayer.io/api/prices' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "prices",
"attributes": {
"amount_cents": 10000
},
"relationships": {
"price_list": {
"data": {
"type": "price_lists",
"id": "ABCRtyUpBa"
}
},
"sku": {
"data": {
"type": "skus",
"id": "BCDRtyUpBa"
}
}
}
}
}'
Last updated