# API for inventory changes

**URL:** <https://community.shiphero.com/t/api-for-inventory-changes/2738>\
**Category:** GraphQL API\
**Created:** [December 12, 2023, 6:55am UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738 "2023-12-12T06:55:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![teamzorali](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/teamzorali/32/821_2.png) [@teamzorali](https://community.shiphero.com/u/teamzorali)\
**Post date:** [December 12, 2023, 6:55am UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738/1 "2023-12-12T06:55:07Z")

</div>

Hey guys,

We’re looking to fetch inventory changes / stock adjustments made in ShipHero and push them into Cin7.

We are looking to fetch these changes two ways possibly, maybe using a Webhook or the GraphSQL API to access the Inventory Change schema if there was a way to tell if this change was due to a stock adjustment rather than a bin transfer or move. Can you confirm if the Schema which I think we think we would use? See screenshot below:

 ![Screenshot 2023-10-25 at 9.11.15 pm (1)](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/1X/8472f121192bfa4c18d9e60cd6fbeb5c0f21e691.png)

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [December 12, 2023, 2:04pm UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738/2 "2023-12-12T14:04:17Z")

</div>

Hey @teamzorali,

Thanks for reaching out!

Yes, if you wanted to query for inventory changes that query would be the one to use. An example query could look something like this:

```auto
{
  inventory_changes(date_from: " _____", date_to: "_____") {
    request_id
    complexity
    data(first: 20) {
      edges {
        node {
          id
          legacy_id
          account_id
          sku
          previous_on_hand
          change_in_on_hand
          reason
        }
      }
    }
  }
}

```

If you want us to push updates to an endpoint, I recommend looking at our [Inventory Update Webhook](https://developer.shiphero.com/webhooks#inventory-update-webhook). The Inventory Update Webhook will fire anytime a products on hand quantity changes.

Please let me know if you have any questions or concerns.

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![lloyd](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@lloyd](https://community.shiphero.com/u/lloyd)\
**Post date:** [December 13, 2023, 12:39am UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738/3 "2023-12-13T00:39:44Z")

</div>

When looking at webhook Inventory Update, or via the query function above, what is the best way to tell if this is a item adjustment rather than shipping a good, transferring between bins, or other movement which is not a write on or write off?

Regards,  
Lloyd

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [December 13, 2023, 12:45pm UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738/4 "2023-12-13T12:45:23Z")

</div>

Hey @lloyd,

Thanks for reaching out!

The webhook body doesn’t include the reason for the webhook fire. However, with the above query, the `reason` field will return the cause of the change.

Please let me know if you have any questions or concerns.

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![lloyd](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@lloyd](https://community.shiphero.com/u/lloyd)\
**Post date:** [December 13, 2023, 1:08pm UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738/5 "2023-12-13T13:08:35Z")

</div>

Can you point me to the documentation about the different reason codes I can expect to find? I need to figure out how to filter for actual inventory write off/on changes (for example nil pick adjustments, stock damage, found stock) to pass these through to an ERP/Inventory system.

Regards,  
Lloyd

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [December 13, 2023, 2:08pm UTC](https://community.shiphero.com/t/api-for-inventory-changes/2738/6 "2023-12-13T14:08:13Z")

</div>

Hey again @lloyd,

Thanks for the quick replies!

There is no documentation about the different `reason` values. The value is specific in how it will return which PO was received or which Order Number was shipped etc.

For example, I ran the query in my test account, and this was my response:

```auto
{
  "data": {
    "inventory_changes": {
      "request_id": "6579b9b3d614f729658031f9",
      "complexity": 21,
      "data": {
        "edges": [
          {
            "node": {
              "id": "TG9jYXRpb25DaGFuZ2VMb2c6NDk1MjIwNjA5",
              "legacy_id": 495220609,
              "account_id": "QWNjb3VudDo2MDUzNA==",
              "sku": "testsku0305",
              "previous_on_hand": 1,
              "change_in_on_hand": -1,
              "reason": "Change from the product page via the ShipHero Web Dashboard."
            }
          },
          {
            "node": {
              "id": "TG9jYXRpb25DaGFuZ2VMb2c6NTAyMjU5NTkw",
              "legacy_id": 502259590,
              "account_id": "QWNjb3VudDo2MDUzNA==",
              "sku": "CHALLENGER",
              "previous_on_hand": 3,
              "change_in_on_hand": -1,
              "reason": "Order <a href=\"/dashboard/orders/details/420737789\">#M79</a> shipped"
            }
          },
          {
            "node": {
              "id": "TG9jYXRpb25DaGFuZ2VMb2c6NTAyODcyNzA2",
              "legacy_id": 502872706,
              "account_id": "QWNjb3VudDo2MDUzNA==",
              "sku": "CHARGER",
              "previous_on_hand": 50,
              "change_in_on_hand": -1,
              "reason": "Order <a href=\"/dashboard/orders/details/419660330\">#M78</a> shipped"
            }
          },
          {
            "node": {
              "id": "TG9jYXRpb25DaGFuZ2VMb2c6NTAyOTMwNDU2",
              "legacy_id": 502930456,
              "account_id": "QWNjb3VudDo2MDUzNA==",
              "sku": "CHALLENGER",
              "previous_on_hand": 51,
              "change_in_on_hand": 9,
              "reason": "Received from Purchase Order <a href=\"/dashboard/purchase-orders/details/1844626\">PO 27</a>"
            }
          },
          {
            "node": {
              "id": "TG9jYXRpb25DaGFuZ2VMb2c6NTAyOTMwNDY4",
              "legacy_id": 502930468,
              "account_id": "QWNjb3VudDo2MDUzNA==",
              "sku": "CHARGER",
              "previous_on_hand": 0,
              "change_in_on_hand": 9,
              "reason": "Received from Purchase Order <a href=\"/dashboard/purchase-orders/details/1844626\">PO 27</a>"
            }
          },
          {
            "node": {
              "id": "TG9jYXRpb25DaGFuZ2VMb2c6NTAyOTMxMTM4",
              "legacy_id": 502931138,
              "account_id": "QWNjb3VudDo2MDUzNA==",
              "sku": "5278-43976#14",
              "previous_on_hand": 3299,
              "change_in_on_hand": -1,
              "reason": "Change from the product page via the ShipHero Web Dashboard."
            }
          }
        ]
      }
    }
  }

```

Please let me know if you have any questions or concerns.

Best,  
RayanP
