Skip to main content

Withdraw Price Order

The root URL of the Recurring API's withdraw from price order endpoint is as such.

https://api.jup.ag/recurring/v1/priceWithdraw
info

This will not close the order. To close the order, you need to use the /cancelOrder endpoint.

Withdraw Order

If you want to withdraw funds from a price-based order, you need to do these steps:

  1. Get a list of the order accounts you want to withdraw via /getRecurringOrders endpoint.
  2. Choose the order account to deposit by making a post request to the /priceDeposit endpoint to get the transaction to deposit into the order.
  3. Sign then send the transaction to the network either via /execute endpoint or by yourself.
Get Recurring Orders

Refer to the /getRecurringOrders section to prepare order account you want to withdraw from.

warning

If you do not pass in amount, the transaction will be built to withdraw the full amount of the order.

const priceWithdrawResponse = await (
await fetch('https://api.jup.ag/recurring/v1/priceWithdraw', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
order: "EpTsCUnKComCd8FDNZn3kVrQBQo2uEn5rRzYk9ocqFPH",
user: wallet.publicKey.toBase58(),
inputOrOutput: "In", // either "In" or "Out" mint, note that price-based orders auto withdraws the output tokens to the user's wallet every time the order is executed
amount: 1000000
}),
})
).json();

Withdraw Order Response

Success Example Response

{
"requestId": "cb1c0e03-8e4a-4f85-ac36-e353c7981f5b",
"transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAcNRL7cu4ZNuxh1wI9W7GVURyr3A06dH348HDpIQzcAJ4oHNtIX+MwRgQakd3fYovqoEXuKqaHTmdCmjuWoQiMiby7TSszpu+tgf+jdiEM5n3uMiCD/N3AS0uVWTp10QrcFd1R4MYi595YUO8ViNwpWb17+Q9DxkVcz5fWpSqjtDyjKhKdx27tkl2VPxhBBJcKx9gSuUqMJnrF2JWtuKPpRPM1Qmt8G5sH80c9QL+SQJRbRoHSG7z7KaEAztDAAXRb0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADBkZv5SEXMv/srbpyw5vnvIzlu8X3EmssQ5s6QAAAAAabiFf+q4GE+2h/Y0YYwDXaxDncGus7VZig8AAAAAABBt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKmMlyWPTiSJ8bs9ECkUjg2DC1oTmdr/EIQEjnvY2+n4Wcb6evO+2606PWXzaqvJdDGxu+TC0vbg5HymAgNFL11h22bCn6+jaw4yO0OzNgqgKrh+NYPQDG7Wi2D35hzKmzcjGx2VRtfxzpYauPv7ArfDDH2VHlwLKs45O0rZTboL4wMHAAUCnqwAAAcACQNADQMAAAAAAAEOAAAFCwgCAwEEBgkKDAEStxJGnJRtoSIBQEIPAAAAAAAA"
}

Failed Example Response

{
"code": 400,
"message": "Failed to deserialize account data: failed to fill whole buffer",
"status": "Bad Request"
}

Execute Withdraw Order

To sign then send the transaction to the network to execute the withdrawal, you can use the /execute endpoint or by yourself.

Refer to the Execute Order section for more details.