Good afternoon,
I’m new to the VTEX world and I have a question. When importing orders from VTEX, how do I avoid importing ones that have already been imported?
I appreciate any help.
Hey @bauermanndev, how’s it going?
When using the VTEX Orders Feed V3 and filtering orders by the “payment-approved” status, you’ll need to commit the already-processed handles so they are removed from the queue.
In other words, after making a GET request to retrieve the latest orders, you’ll need to make a POST request to commit the handles so they don’t return to the queue after they’ve already been read.
Example:
curl --request post \
--url https://apiexamples.vtexcommercestable.com.br/api/orders/feed \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-VTEX-API-AppKey: ' \
--header 'X-VTEX-API-AppToken: ' \
--data '{"handles":["AQEBSM/bSqonHYtx+UrHdbuJ0i7M9yMbI2jtYwMIPdEc4BenuneaCTC9VEJ3dgAy1XtfQvHBvgwZTO8LvGObIKNqiKXDZiMKY25vK+pblZEqf1pWdLMugu5XoHA5ZAd4IcBcXrBcrlr1GU8uvPEBoVLOsVBP9IAxIZkkeEedIDg3K6GPyEXVuPlTEYb/0OCunEGxWF+AZ1frFdXh7ulORTcuqO5oDlBGbpD+QYzCmF4mUZtQ0VVWh9icM1QBVh6PlJ0D/lfwnJKWpBn3jf8c+DTm7sD7wb1Lcz9uWMLhDtPwvH9vue4MvKU9sCahEQe7K5jWuwwb54szGbFKdfcACsTSQ9WlyBfMdbV83c27k68G3cnaBFExkC1MLHHE9UzpQ6l4s43BT4k95ocgMXffnj/HMUYXn+OCvlvjytY59x1OCRE="]}'
Just adding to this…
There’s also the VTEX Hook option, but it will require you to have an API service running in your external environment.
Feed v3: you query it whenever you want to receive status changes (or new orders).
VTEX Hook: VTEX sends you the orders whenever there is a status change (or new orders).