# Updating Stock Entry

**URL:** <https://developer-forum.veeqo.com/t/updating-stock-entry/444>\
**Category:** API Queries (How To)\
**Created:** [September 14, 2021, 5:05pm UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444 "2021-09-14T17:05:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmyers0](https://avatars.discourse-cdn.com/v4/letter/d/FF6200/32.png) [@dmyers0](https://developer-forum.veeqo.com/u/dmyers0)\
**Post date:** [September 14, 2021, 5:05pm UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444/1 "2021-09-14T17:05:50Z")

</div>

Hi Guys,  
We are trying to push our stock values from our warehouse system to Veeqo, so the correct values can then be shown on the website.  
The sellable\_id is the parameter show in the API docs, but we need to use the SKU to match the products between the two platforms.  
Any suggestions on how we can do this ?  
Many thanks in advance for any info

---

<div class="post-metadata">

**Author:** ![Kristien](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/kristien/32/157_2.png) [@Kristien](https://developer-forum.veeqo.com/u/Kristien)\
**Post date:** [September 14, 2021, 6:46pm UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444/2 "2021-09-14T18:46:58Z")

</div>

Hi, @dmyers0!  
Welcome to the Veeqo developer forum!

There’s no way to update based on SKU’s because the endpoint required the primary ID (sellable\_id) - I’d assume this is because multiple sellables could potentially have the same SKU code.

The way I would go about doing this is iterating through products and fetching each of the sellable IDs and building an array that would reference the SKU, then iterating through the array that has been built, and making separate requests to the /sellables endpoint

This is possible using the /products endpoint.

1. First, make a request to: [https://api.veeqo.com/products](https://api.veeqo.com/products)

2. This will return a response for each product, you will then need to iterate through the “sellable” portion of the response for the products to get the SKU code and sellable IDs for that product.

3. Then, for each iteration, you can build an array dynamically for each sellable containing the SKU code and Sellable ID.

4. Finally, Iterate through your newly build array containing each of the SKUs and make your request with the new data you have

Here’s some working PHP code that I’ve written up which would build this array:  
_($products is the decoded json response from the /products endpoint)_

```auto
foreach($products as $product){
    foreach($product['sellables'] as $index => $sellable){
        $array[$sellable['sku_code']] = $sellable['id'];
    }
}

```

This would generate an array with the following structure:

```auto
Array (
    [g-dog-2] => 58641795
    [g-dog-1] => 58641794
    [test] => 58519745
    [DG02] => 57991303
    [DG01] => 57991302
    [FLORYEL124] => 57611649
    [FLORYEL123] => 57611648
    [TS001] => 57557816
    [TS002] => 57557817
    [CP003] => 57557780
    [CP3321] => 57557779
    [CP001] => 57557777
    [VQ001] => 57340964
    [IMP01] => 57302068
    [PJ003] => 57301122
)

```

From this point, you would iterate through the array we’ve built, and make your requests to this endpoint: [https://api.veeqo.com/sellables/sellable\_id/warehouses/warehouse\_id/stock\_entry](https://api.veeqo.com/sellables/sellable_id/warehouses/warehouse_id/stock_entry)  
_Make sure you change the relevant fields_

**I should note, that by doing this through the API, you may encounter some issues with the limits [as stated here.](https://developer.veeqo.com/docs#/introduction/limits)**

**If the limits cause issues, you could always update your stock via .csv. Ben has a really good video guide [which you can find here](https://help.veeqo.com/en/articles/5393962-updating-stock-via-csv).**

Hope this help!

---

<div class="post-metadata">

**Author:** ![dmyers0](https://avatars.discourse-cdn.com/v4/letter/d/FF6200/32.png) [@dmyers0](https://developer-forum.veeqo.com/u/dmyers0)\
**Post date:** [September 14, 2021, 7:31pm UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444/3 "2021-09-14T19:31:36Z")

</div>

Thanks so much for the detailed response Kristien.  
I will check this out with team tomorrow and see if we can get this working.

---

<div class="post-metadata">

**Author:** ![dmyers0](https://avatars.discourse-cdn.com/v4/letter/d/FF6200/32.png) [@dmyers0](https://developer-forum.veeqo.com/u/dmyers0)\
**Post date:** [October 22, 2021, 11:02am UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444/4 "2021-10-22T11:02:13Z")

</div>

Just to update this thread, we managed it with the approach above.  
Many Thanks

---

<div class="post-metadata">

**Author:** ![Kristien](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/kristien/32/157_2.png) [@Kristien](https://developer-forum.veeqo.com/u/Kristien)\
**Post date:** [October 24, 2021, 12:28am UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444/5 "2021-10-24T00:28:27Z")

</div>

That’s great news, @dmyers0!  
I’m glad I could help out.

---

<div class="post-metadata">

**Author:** ![Kristien](https://yyz1.discourse-cdn.com/flex033/user_avatar/developer-forum.veeqo.com/kristien/32/157_2.png) [@Kristien](https://developer-forum.veeqo.com/u/Kristien)\
**Post date:** [October 24, 2021, 12:28am UTC](https://developer-forum.veeqo.com/t/updating-stock-entry/444/6 "2021-10-24T00:28:34Z")

</div>


