HTTPS Outcall unwantedly sends multiple POST requests to another server

My canister have one function to call POST API to transfer USDT on a server.

But each time this canister function is being called, it sends multiple requests to that USDT server, which can lead to multiple transfer.

I understand that HTTPs outcall will need to sync response data from all the replicas, but it will be a problem if the response data is supposed to be different each time the API is being called.

how should I approach it?

I am thinking to create a specific ledger to mark the request status on that other server.
so each request will have an ID, and I will trace it’s status so that the server can send the same response per request, even though it comes from multiple replica

but kindly let me know if there is better way to approach this

This happens because every replica that runs your canister will also perform the call. Otherwise there wouldn’t be any decentralisation.

That’s the right way to approach it. This pattern is commonly called idempotency key

3 Likes