# How to return 2 most recent inventory snapshots?

**URL:** <https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753>\
**Category:** GraphQL API\
**Created:** [July 27, 2026, 12:29pm UTC](https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753 "2026-07-27T12:29:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [July 27, 2026, 12:29pm UTC](https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753/1 "2026-07-27T12:29:44Z")

</div>

Hello! I’m trying to query the last 2 most recent inventory snapshots via the API, but no matter what I’ve tried, I always gets results that are years old, either from 2020 or 2021. We’re definitely running one at least every day because I received the emails to download them when they’re complete. The query I’m trying is:

`query {`  
` inventory_snapshots {`  
` request_id`  
` data (sort: "-created_at", first: 2) {`  
` edges {`  
` node {`  
` snapshot_id`  
` status`  
` created_at`  
` snapshot_url`  
` }`  
` }`  
` }`  
` }`  
`}`

This should be sorting created\_at in descending order and returning the first 2 snapshots. I’ve also tried a number of variations of the `sort` and `first` fields, such as sorting created\_at in ascending order and requesting the last 2. I pulled the sort syntax from [this post](https://community.shiphero.com/t/sort-returns-by-date/1162). I also looked through the [developer docs site](https://developer.shiphero.com/), and sort syntax doesn’t seem to really be specified there, either. I did see one reference to sorting in the [examples page](https://developer.shiphero.com/examples/) under “Cycle Count Create”, which shows examples of the sort field as “LOCATION\_NAME\_ASC” and “QUANTITY\_DESC”. Based on those, I tried using “CREATED\_AT\_ASC” and “CREATED\_AT\_DESC” syntax in my query, but those didn’t do anything to change the sort, either.

Here are some of my request\_ids:

`6a674870e13ef742ed5386bd`  
`6a6748e68995d911dea206de`  
`6a6749cfefe9fc2901b93cf7`

Along with receiving help with this, I would also like to suggest to please incorporate documentation and examples for how to use the sort field in queries, especially if the syntax is different between queries and mutations. It would also be _extremely_ helpful if the [GraphQL schema documentation](https://developer.shiphero.com/schema/#group-Operations-Queries) could specify which fields are sortable in each query and mutation.

Thank you,

Jeremy

---

<div class="post-metadata">

**Author:** ![jjconti](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@jjconti](https://community.shiphero.com/u/jjconti)\
**Post date:** [July 28, 2026, 7:35pm UTC](https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753/2 "2026-07-28T19:35:20Z")

</div>

Thanks for the detailed report. Indeed, you found a bug. We’re sending a fix right now. I’ll let you know once it’s deployed.

Juanjo

---

<div class="post-metadata">

**Author:** ![jjconti](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@jjconti](https://community.shiphero.com/u/jjconti)\
**Post date:** [July 30, 2026, 8:42pm UTC](https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753/3 "2026-07-30T20:42:02Z")

</div>

Good news! a fix was released so you query should work now. You can also use `sort: "-_id"` for faster results. In the account I tested 600 ms vs 2.3 s.

---

<div class="post-metadata">

**Author:** ![jeremyw](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jeremyw](https://community.shiphero.com/u/jeremyw)\
**Post date:** [August 3, 2026, 10:00am UTC](https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753/4 "2026-08-03T10:00:07Z")

</div>

Confirming it now works. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/2X/8/83f2a5ec5d7908b156cb6999baa4c753fadfa85d.svg) [@system](https://community.shiphero.com/u/system)\
**Post date:** [August 7, 2026, 10:00am UTC](https://community.shiphero.com/t/how-to-return-2-most-recent-inventory-snapshots/3753/5 "2026-08-07T10:00:44Z")

</div>

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.
