Disclaimer: This is a complicated combination of multiple RPC calls that results in a custom operation. Use it wisely and at your own risk.
So what do you need to do in order to perform the operation through Tezos RPC? First of all, you need to understand how to send 1 single transaction using RPC and then you will see how to do multiple transactions in one batch. Basically, it takes a few steps: get dependencies, forge operation, sign bytes, preapply operation, decode the signature, and inject operation.
Let’s go through these steps in detail.