Update a Product

Last updated 4 months ago

put
Update by ID

https://api.moltin.com
/v2/products/:id
Updating an existing product.
Request
Response
Path Parameters
id
required
string
The ID of the product you wish to update
Headers
X-Moltin-Language
optional
string
If set, the system will store a record of the translation in the specific language
Authorization
required
string
The Bearer token to grant the API access
Body Parameters
type
required
string
Represents the type of object being created. (should be product)
name
optional
string
A human readable name for this product
slug
optional
string
A unique slug for this product
sku
optional
string
A unique SKU for this product
mange_stock
optional
boolean
True if moltin should manage stock, false if not
description
optional
string
A human readable description of the product
price
optional
array
An array of prices, one for each currency
price.amount
optional
string
Value of the price
price.currency
optional
string
Currency of this price. (3 letter ISO)
price.includes_tax
optional
boolean
true if relevant taxes have been included in the price. false if not
status
optional
string
draft, live
commodity_type
optional
string
physical/digital
200: OK
{
"data": {
"type": "product",
"id": "b47372eb-6f13-4bcb-ad06-329f4ffee69d",
"name": "A Product",
"slug": "a-product-1",
"sku": "SP01-{COLOUR}-new-2",
"manage_stock": false,
"description": "Some description",
"price": [
{
"amount": 6999,
"currency": "GBP",
"includes_tax": true
},
{
"amount": 7499,
"currency": "USD",
"includes_tax": true
}
],
"status": "live",
"commodity_type": "physical",
"meta": {
"timestamps": {
"created_at": "2018-05-11T20:07:56+00:00",
"updated_at": "2018-05-12T00:50:11+00:00"
},
"display_price": {
"with_tax": {
"amount": 7499,
"currency": "USD",
"formatted": "$74.99"
},
"without_tax": {
"amount": 7499,
"currency": "USD",
"formatted": "$74.99"
}
},
"stock": {
"level": 0,
"availability": "out-stock"
}
},
"relationships": {
"categories": {
"data": [
{
"type": "category",
"id": "3acf1815-ef09-44df-a6d3-e3e702663524"
}
]
},
"collections": {
"data": [
{
"type": "collection",
"id": "10229491-7dbb-424d-be08-80c5735795cc"
}
]
}
}
}
}
cURL
JavaScript SDK
Moltin Request
curl -X "PUT" https://api.moltin.com/v2/products/:id \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-H "X-Moltin-Language: en" \ # Optional language header
-d $'{
"data": {
"type": "product",
"id": "XXXX",
"name": "Updated product name"
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const id = 'XXXX'
const data = {
'name': 'Updated product name',
'type': 'product',
'id': id
}
Moltin.Products.Update(id, data).then(product => {
// Do something
})
const { createClient } = require('@moltin/request')
const client = new createClient({
client_id: 'X',
client_secret: 'X'
})
const id = 'XXXX'
const data = {
name: 'Updated product name',
type: 'product',
id
}
client
.put(`products/${id}`, data)
.then(product => {
// Do something...
})
.catch(console.error)