Filter
What would you like to search for?
Backend API
Fields
Unique identifier for the stock adjustment.
ID of the parent product.
Quantity of the adjustment. A positive number means stock was increased, and a negative number means stock was decreased.
Date and time the stock adjustment was created.
Date and time the stock adjustment was last updated.
New stock level after the adjustment is applied.
Auto-incremented stock adjustment number.
ID of an order when the stock adjustment was either reduced by the sale of a product, or increased by cancelling an order. Adjustments from orders are created automatically when stock tracking is enabled.
Expandable link to an order, if applicable to the stock adjustment.
Expandable link to the parent product.
Link to the previous stock adjustment.
ID of the previous stock adjustment.
Enumerated reason for the stock adjustment. Can be received, returned, canceled, sold, missing, or damaged.
A brief description of the reason for the stock adjustment.
ID of the parent variant, if applicable.
Expandable link to the parent variant, if applicable.
The stock model
{
"id": "60f199509111e7000000005f",
"parent_id": "60f199509111e70000000062",
"date_created": "2021-07-16T14:36:00.321Z",
"date_updated": "2021-07-16T14:36:00.321Z",
"level": 20,
"number": 1029376,
"reason": "received",
"reason_message": "Restock - PO #47362",
"variant_id": "60f199509111e70000000061"
}
Create a new stock adjustment. Normally, stock adjustments are automatically created when stock tracking is enabled and orders are placed or canceled.
Arguments
The id of the parent product.
Quantity of the adjustment. A positive number means the stock was increased, and a negative number means the stock was decreased.
Enumerated reason for the stock adjustment. Can be received, returned, canceled, sold, missing, or damaged.
A brief description of the reason for the stock adjustment.
The id of an order when the stock adjustment was either reduced by the sale of a product or increased by canceling an order. Adjustments from orders are created automatically when stock tracking is enabled.
The id of the parent variant, if applicable.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/products:stock', {
parent_id: '5ca24abb9c077817e5fe2b3b',
quantity: 10,
reason: 'received',
reason_message: 'Restock - PO #47362',
});
Response
{
"id": "5ca24abb9c077817e5fe2b3b",
"parent_id": "5ca7d6c68f749692da37c985",
"quantity": 10,
"level": 10,
"number": "100184",
"reason": "received"
"reason_message": "Restock - PO #47362",
"date_created": "2019-04-01T00:00:00.000Z"
}
Retrieve an existing stock adjustment using the id that was returned when created.
Arguments
The id of the stock adjustment to retrieve.
Expanding link fields and child collections is performed using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Return only the specified fields in the result.
- For example, fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The stock adjustment id is always returned.
Include one or more arbitrary queries in the response, possibly related to the main query.
See including for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/products:stock/{id}', {
id: '5ca24abb9c077817e5fe2b3b',
});
Response
{
"id": "5ca24abb9c077817e5fe2b3b",
"parent_id": "5ca7d6c68f749692da37c985",
"quantity": 10,
"level": 10,
"number": "100184",
"reason": "received"
"reason_message": "Restock - PO #47362",
"date_created": "2019-04-01T00:00:00.000Z"
"date_updated": "2019-04-01T00:00:00.000Z",
}
Return a list of product stock adjustments.
Arguments
Expand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
Returns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
Include one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.
The page number of results to return given the specified or default limit.
A text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
Expression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
An object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/products:stock', {
limit: 25,
page: 1
});
Response
{
"count": 51,
"results": [
{
"id": "60f199509111e7000000005f",
"parent_id": "60f199509111e70000000066",
"date_created": "2021-07-16T14:36:00.321Z",
"date_updated": "2021-07-16T14:36:00.321Z",
"level": 20,
"number": 1029376,
"reason": "received",
"reason_message": "Restock - PO #47362",
"variant_id": "60f199509111e70000000061"
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}