# Getting duplicate after tokens

**URL:** <https://community.hubspot.com/t/getting-duplicate-after-tokens/105674>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [April 24, 2024, 2:32pm UTC](https://community.hubspot.com/t/getting-duplicate-after-tokens/105674 "2024-04-24T14:32:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MHenderson42](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mhenderson42/32/7035_2.png) [@MHenderson42](https://community.hubspot.com/u/MHenderson42)\
**Post date:** [April 24, 2024, 2:32pm UTC](https://community.hubspot.com/t/getting-duplicate-after-tokens/105674/1 "2024-04-24T14:32:55Z")

</div>

I am getting duplicate after tokens when doing GET request to conversation messages.

Example:

…/conversations/v3/conversations/threads/{threadId}/messages?limit=500&sort=createdAt&after={afterToken}

The first request returns a paging similar to above. The first and second requests return new data. Then the paging link is not updated after that and I am getting duplicates returned.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 24, 2024, 7:53pm UTC](https://community.hubspot.com/t/getting-duplicate-after-tokens/105674/2 "2024-04-24T19:53:46Z")

</div>

Hey, @MHenderson42 👋 Welcome to our community! Thanks for your question.

Have you tried:

- Try limiting records to a smaller number, 5 or 10, and see if the issue persists. /conversations/v3/conversations/threads/{threadId}/messages?limit=10&sort=createdAt&after={afterToken}
- If no duplicates are returned, gradually increase the limit (to 50, 100, etc.) until you start seeing duplicates again.
- Another test to try is not passing the after token and see if duplicates start from first request itself or after a few batches.

This will give you a better idea of whether the issue is related to the ‘limit’ parameter, the ‘after’ token or is a different issue.

Thanks for the additional information! — Jaycee

---

<div class="post-metadata">

**Author:** ![MHenderson42](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mhenderson42/32/7035_2.png) [@MHenderson42](https://community.hubspot.com/u/MHenderson42)\
**Post date:** [April 24, 2024, 8:15pm UTC](https://community.hubspot.com/t/getting-duplicate-after-tokens/105674/3 "2024-04-24T20:15:51Z")

</div>

I’ve tried a few things:

- Adding and removing sort
- Ascending and descending sort
- Setting the limit or removing to use default

The pattern goes like this:

1. First GET request returns a handful of messages (with or without setting the limit)
2. First GET request has **after** and **link** values
3. Second GET request with **after** token returns a new token
4. Third GET returns the same result as the second, including the token

I just noticed seomthing else testing with a new thread id. The second GET results returned an empty array, yet there’s a paging link. And the paging link duplicates the second GET request. It’s as if there’s no results left yet it’s setting a paging link anyway.
