"All contacts" API endpoint not returning all contacts

We are using a sync job to migrate data from our production database to hubspot by extracting all contacts and updating them back into Hubspot.
We are however not seeing all the contacts returned via the API (https://legacydocs.hubspot.com/docs/methods/contacts/get_contacts),,) only half are returned to us. We are using a simple loop going over each returned page (of 100 items) until the “has-more” flag turns false. We are not seeing any errors from the API (only 200 OKs).
The issue is quite critical to us as the client status is not propagated to Hubspot for customer handling and care.

I would like help in resolving this issue.

Best regards, Thomas.
Developer at Mouseflow.

Did you tried to change to V3 API

https://api.hubapi.com/crm/v3/objects/contacts?limit=100&archived=false

It retursn 100 records and for Loop you’ll need to use after parameter from previous response.

No we did not.
We prefer to leave the code as is for now (risk and time), if we can get the endpoint to work as promised in the docs.
But thanks for the suggestion.