Timed Order in Spot API

Hello, I have a question about Binance Spot Api. I want to create a timed order. I didn’t see anything in Api documentation. I create a buy order and I canceled after 5 seconds. But sometimes I take an error as “Unknown order”[code=-2011]. Because the order filled when I want to cancel it. That’s why, can I create a timed order in spot api ?

I’m not entirely understanding your point of view. It’s normal that there’s risk of the order being immediately filled after placing it, specially when its price is close to the latest price. So by the time you cancel, the order is already filled. So what do you mean exactly by timed order?
If helpful, you can look at “Time in force (timeInForce)” options in the API doc.

I am creating a buy order and I want to keep it open for 5 seconds. If the purchase has not been made within 5 seconds, I want to cancel.