VariantMovement

Changes to stock are saved as a Variant Movement, allowing you to track the stock changes of a shop. Historical data of a Variant Movement is kept for a month, older data is automatically deleted.

If you’re looking to create a real time synchronisation, take a look at Webhooks. This allows you to be notified when the stock of variants change, instead of polling for changes.

Example object

{
    "variantMovement": {
        "id": 114586434,
        "createdAt": "2019-08-07T19:20:22+00:00",
        "channel": "auto",
        "stockLevelChange": -10,
        "product": {
            "resource": {
                "id": 20967270,
                "url": "products/20967270",
                "link": "https://api.shoplightspeed.com/us/products/20967270.json"
            }
        },
        "variant": {
            "resource": {
                "id": 34771897,
                "url": "variants/34771897",
                "link": "https://api.shoplightspeed.com/us/variants/34771897.json"
            }
        }
    }
}

Properties

id The unique numeric identifier for the variant movement. {“id”: {id}}
createdAt The date and time when the variant movement was created. (format: ISO-8601){“createdAt”: “2019-08-07T19:20:22+00:00”}
channel The channel that created the movement. {“channel”: “manual, auto, api”}
stockLevelChange The quantity that the stock has changed by. {“stockLevelChange”:-1}
product Link to the Product resource. {“product”: “products/20967270”}
variant Link to the Variant resource. {“variant”: “variants/34771897”}

GET All movements

Retrieve the total number of variantMovement objects for this shop.

Definition

GET /variants/movements.json

Example request

curl https://api.shoplightspeed.com/en/variants/movements.json \
  -u {key}:{secret}
<?php $api->variantsMovements->get();

Example response

{
    "variantsMovements": [
        {
            "id": 114586434,
            "createdAt": "2019-08-07T19:20:22+00:00",
            "channel": "auto",
            "stockLevelChange": -10,
            "product": {
                "resource": {
                    "id": 20967270,
                    "url": "products/20967270",
                    "link": "https://api.shoplightspeed.com/us/products/20967270.json"
                }
            },
            "variant": {
                "resource": {
                    "id": 34771897,
                    "url": "variants/34771897",
                    "link": "https://api.shoplightspeed.com/us/variants/34771897.json"
                }
            }
        }
    ]
}

Arguments

  No arguments available.

Filters

product Retrieve all variant movements based on the product.
variant Retrieve all variant movements based on the variant.
channel Retrieve all variant movements created by a specific channel.
limit Number of results. {(default: 50) (maximum: 250)}
page Page to show. {(default: 1)}
since_id Restrict results to after the specified ID. {(default: 0)}
created_at_min Show variant movements created after date. {(format: YYYY-MM-DD HH:MM:SS)}
created_at_max Show variant movements created before date. {(format: YYYY-MM-DD HH:MM:SS)}

GET Number of movements

Retrieve the total number of stock mutations of this shop.

Definition

GET /variants/movements/count.json

Example request

curl https://api.shoplightspeed.com/en/variants/movements/count.json \
  -u {key}:{secret}
<?php $api->variantsMovements->count();

Example response

{
  "count": 1
}

Arguments

  No arguments available

Filters

limit Number of results. {(default: 50) (maximum: 250)}
page Page to show. {(default: 1)}
since_id Restrict results to after the specified ID. {(default: 0)}
created_at_min Show variant movements created after date. {(format: YYYY-MM-DD HH:MM:SS)}
created_at_max Show variant movements created before date. {(format: YYYY-MM-DD HH:MM:SS)}

GET Retrieve a movement

Retrieve a single variantMovement. This is a stock mutation related to a variant.

Definition

GET /variants/movements/{variantMovement_id}.json

Example request

curl https://api.shoplightspeed.com/en/variants/movements/{variantMovement_id}.json \
  -u {key}:{secret}
<?php $api->variantsMovements->get($variantMovement_id);

Example response

{
    "variantMovement": {
        "id": 114586434,
        "createdAt": "2019-08-07T19:20:22+00:00",
        "channel": "auto",
        "stockLevelChange": -10,
        "product": {
            "resource": {
                "id": 20967270,
                "url": "products/20967270",
                "link": "https://api.shoplightspeed.com/us/products/20967270.json"
            }
        },
        "variant": {
            "resource": {
                "id": 34771897,
                "url": "variants/34771897",
                "link": "https://api.shoplightspeed.com/us/variants/34771897.json"
            }
        }
    }
}

Arguments

id The unique numeric identifier for the variant movement. {“id”: {id}}