How to place Exit Position (Buy/Sell) in futures

Hi, I Want to automate a transaction in my account for futures. Suppose I placed and order either buy or sell of instrument x at price y, and after 2 3 days based on my requirement I want to exit the position. I am confused as how to exit the position. I know I have to fetch by positions using the get_position API, then what?

I am confused in that part.

To square off, you must execute an order for the second leg. If your initial action is a purchase, then your square-off should be a sell order, and the reverse applies if you start with a sell. After consulting the position API for all the necessary details to place the second leg order, you should be all set.

I trust this explanation is clear.