• PXM Products/
    PXM Products Inventory API/
    Update Inventory

    Update Inventory

    Action types

    TypeDescription
    incrementUse this when you receive stock from a supplier, making products available for purchase.
    decrementUse this when you want to remove stock from product inventory.
    allocateUse this when you want to allocate stock, normally to a reseller who sells on the stock.
    deallocateUse this when you want to deallocate any previously allocated stock.

    POST Create a Stock Transaction for a Product

    https://api.moltin.com/v2/inventories/:productId/transactions
    

    Parameters

    Path parameters

    NameRequiredTypeDescription
    productIdRequiredstringThe ID for the product you’re performing this action on.

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    quantityRequiredintegerThe amount of stock affected by this transaction.
    actionRequiredstringincrement, decrement, allocate, deallocate.
    typeRequiredstringAlways stock-transaction.

    Request Examples

    Curl

    curl -X POST https://api.moltin.com/v2/inventories/:productId/transactions \
         -H "Authorization: Bearer XXXX" \
         -H "Content-Type: application/json" \
         -d $'{
           "data": {
             "type": "stock-transaction",
             "action": "increment",
             "quantity": 10
           }
         }'
    

    JavaScript SDK

    const MoltinGateway = require("@moltin/sdk").gateway;
    const Moltin = MoltinGateway({
        client_id: "X",
        client_secret: "X",
    });
    const productId = "XXXX";
    const quantity = 10;
    Moltin.Inventories.IncrementStock(productId, quantity).then((transaction) => {
        // Do something
    });
    Moltin.Inventories.DecrementStock(productId, quantity).then((transaction) => {
        // Do something
    });
    Moltin.Inventories.AllocateStock(productId, quantity).then((transaction) => {
        // Do something
    });
    Moltin.Inventories.DeallocateStock(productId, quantity).then((transaction) => {
        // Do something
    });
    

    Response Example

    200 OK

    You get the following response for any of the action types.

    {
        "data": {
            "id": "da9a0008-d2c4-4a17-bbc6-5e0b2f9430aa",
            "type": "stock-transaction",
            "action": "increment",
            "product_id": "9eda5ba0-4f4a-4074-8547-ccb05d1b5981",
            "quantity": 10,
            "timestamps": {
                "created_at": "2018-05-01 10:10:57 +0000 UTC"
            }
        }
    }
    

    422: Unprocessable Entity

    You get the following error if you try to perform an action with incorrect amounts.

    {
        "errors": [
            {
                "status": 422,
                "title": "Cannot complete request",
                "detail": "Your request could not be completed due to insufficient stock levels"
            }
        ]
    }
    

    Was this helpful?

    Previous
    Create Inventory