Stock Transactions

Last updated last month

Each product has its own Inventory and stock history. This is useful when auditing product movements across your project. Below is the Stock Transaction object, request and response examples for getting all stock transactions by Product ID.

The Stock Transaction Object

Attribute

Type

Description

id

string

The unique identifier for the stock transaction

type

string

The type represents the object being returned

action

string

The type of action performed by this transaction

product_id

string

The product identifier that this stock transaction is for

quantity

integer

The amount of stock affected by the stock transaction

get
Get All Product Stock Transactions

https://api.moltin.com
/v2/inventories/:productId/transactions
Request
Response
Path Parameters
productId
required
string
The ID for the product you're performing this action on
Headers
Authorization
required
string
The Bearer token to grant access to the API
200: OK
You will see inside the response below you get all stock transactions, including the initial stock amount on product create.
{
"data": [
{
"id": "0b0e5be3-b88b-4574-8316-f2871a803a8a",
"type": "stock-transaction",
"action": "create",
"product_id": "9eda5ba0-4f4a-4074-8547-ccb05d1b5981",
"quantity": 1,
"timestamps": {
"created_at": "2018-02-05 14:00:11 +0000 UTC"
}
},
{
"id": "4638fc99-faec-416c-94e0-c3e0d11af436",
"type": "stock-transaction",
"action": "increment",
"product_id": "9eda5ba0-4f4a-4074-8547-ccb05d1b5981",
"quantity": 1,
"timestamps": {
"created_at": "2018-03-07 14:34:32 +0000 UTC"
}
},
{
"id": "2edaa5f6-45fe-4272-96d4-3c745f80c26d",
"type": "stock-transaction",
"action": "decrement",
"product_id": "9eda5ba0-4f4a-4074-8547-ccb05d1b5981",
"quantity": 1,
"timestamps": {
"created_at": "2018-03-07 14:44:21 +0000 UTC"
}
}
]
}
cURL
JavaScript SDK
Moltin Request
curl -X GET https://api.moltin.com/v2/inventories/:productId/transactions \
-H "Authorization: Bearer XXXX"
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const productId = 'XXXX'
Moltin.Inventories.GetTransactions(productId).then(transactions => {
// Do something
})
const { createClient } = require('@moltin/request')
const client = new createClient({
client_id: 'X'
})
const productId = 'XXXX'
client
.get(`inventories/${productId}/transactions`)
.then(inventory => {
// Do something...
})
.catch(console.error)