---
title: "Prepare an Aave withdrawal"
method: POST
path: "/positions/{address}/unwind"
tags: ["Utilities"]
---

# Prepare an Aave withdrawal

`POST /positions/{address}/unwind`

## Request

- Base URL: `https://v1.orchestrator.rhinestone.dev/deposit-processor`
- URL: `https://v1.orchestrator.rhinestone.dev/deposit-processor/positions/{address}/unwind`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/rhinestonewtf/apis/deposit-service-api/docs/positions/:address/unwind/post.ts> (a function with typed inputs; its response is checked against the schema)

Prepares an unsigned transaction to withdraw an Aave position to a deposit address.

## Path parameters

- `address` string, required: The EOA holding the position. It signs and sends the returned transaction.

## Headers

- `x-api-key` string: API key for authentication
- `x-api-version` string: API version identifier (e.g. "2026-04.amazon"). Optional today, will become required in a future release.

## Request body

- PrepareUnwindRequestBody
  - `account` string, required: The registered deposit account the proceeds go to. The recipient is resolved from this server-side; it is never taken from the request directly.
  - `market` string, required: The Aave market's Pool address, as returned in a position's `market.address`. Required rather than inferred, because a chain can host several markets.
  - `chainId` integer, required
  - `asset` string, required: The supplied underlying token to withdraw
  - `amount` string: Base units to withdraw. Omit for the largest amount currently permitted. An amount above that maximum is rejected rather than silently reduced.

## Response `200`

Unsigned withdraw transaction

- PrepareUnwindResponse
  - `transaction` object, required: Unsigned transaction for the holding EOA to sign and send. The backend never executes it — the EOA holds the aTokens, so only it can authorise the withdraw.
    - `to` string, required
    - `data` string, required
    - `value` string, required
    - `chainId` number, required
  - `amount` string, required: Base units the transaction will withdraw
  - `isFullExit` boolean, required: True when the whole position is being withdrawn, in which case the calldata uses the max-uint sentinel so interest accrued before the transaction lands is swept too.
  - `recipient` string, required: The deposit address the proceeds are sent to, resolved from the registered account. Echoed so it is auditable.
  - `constraints` string[], required: Why the amount is below the supplied balance, if it is. Empty for an unconstrained full exit.

## Other responses

- `400`: Invalid request, unauthorized, no such position, an amount above the withdrawable maximum, or proceeds the deposit policy would reject
- `401`: Authentication required or the presented credential is invalid.
- `403`: API key lacks the required deposits scope, or the account belongs to another project
- `503`: Tenant billing verification is temporarily unavailable; retry after 5 seconds.

## Changes

- **2026-11-06** `aa1767d704fa`: 5 info
  - the endpoint scheme security `internalProjectBearer` was added to the API
  - the endpoint scheme security `tenantApiKey` was added to the API
  - the `header` request parameter `x-api-key` became optional
  - added the non-success response with the status `401`
  - …1 more
- **2026-09-17** `676300ac19ff`: 2 info
  - added the optional property `code` to the response with the `400` status
  - added the optional property `code` to the response with the `403` status
- **2026-07-29** `7f6aae39bb48`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/rhinestonewtf/apis/deposit-service-api/changes/positions/:address/unwind/post.md)

---

[API](https://skmtc.dev/rhinestonewtf/apis/deposit-service-api.md) - [All operations](https://skmtc.dev/rhinestonewtf/apis/deposit-service-api/llms.txt) - [OpenAPI document](https://skmtc.dev/rhinestonewtf/apis/deposit-service-api/revisions/aa1767d704fa?raw)
