Deletion from Couchbase Server

Hello everyone,
I try to explain my scenario,
I have a mobile device that uses CouchBase Lite, in this device I create a document with the Java SDK with null ID. Once the document is created, it passes on the sync gateway and then ends up on couchbase server. When it arrives on couchbase server we intercept it we delete it and create a new one with the correct id (which is a progressive).
It happens that when we do the deletion and create a new one everything seems to be fine but instead after a few seconds I find the one with id null.
Why does this happen?
Should I by chance delete from the sync gateway directly ?

thank you in advance for your help.