---
updatedAt: 2025-09-22T22:40:16.000Z
agentTools:
  projectIndex: https://bluefin-exchange.readme.io/llms.txt
---

# /trade/withdraw

Initiates a withdraw action to remove some amount of funds from a user's account.

## Client Library

```python
#!/usr/bin/env python

import asyncio
import logging
import time

from bluefin_pro_sdk import BluefinProSdk, Environment, RpcUrl
from crypto_helpers.signature import SuiWallet

# Set up logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)


def now():
    """Return the current time in milliseconds since the Epoch."""
    return int(time.time() * 1000)


async def main():
    """
    Example showing how to initiate a withdrawal of funds for an account using the Bluefin Pro API
    using the PRODUCTION environment.
    """
    # Create a wallet with your private key
    sui_wallet = SuiWallet(
        mnemonic="dilemma salmon lake ceiling moral glide cute that ginger float area aunt vague remind cage mother concert inch dizzy present proud program time urge"
    )

    log.info(f"Using wallet address: {sui_wallet.sui_address}")

    # Initialize the Bluefin Pro SDK client with PRODUCTION environment and RPC
    async with BluefinProSdk(
            sui_wallet=sui_wallet,
            contracts=None,  # Not needed for this example
            rpc_url=RpcUrl.PROD,
            env=Environment.PRODUCTION,
            debug=False  # Set to True for more verbose output
    ) as client:
        try:
            # Initialize the client, which will handle authentication
            await client.init()

            # ========= Withdraw ==========
            log.info("Withdrawing")
            await client.withdraw("USDC", str(int(10e9)))

        except Exception as e:
            log.error(f"Error withdrawing: {e}")
            raise


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        log.info("Exiting due to keyboard interrupt")

```
```
use bluefin_api::apis::configuration::Configuration;
use bluefin_api::apis::exchange_api::get_exchange_info;
use bluefin_api::apis::trade_api::post_withdraw;
use bluefin_api::models::{
    LoginRequest,
    WithdrawRequest, WithdrawRequestSignedFields,
};
use bluefin_pro::prelude::*;
use chrono::Utc;
use hex::FromHex;
use rand::random;
use sui_sdk_types::SignatureScheme;

type Error = Box<dyn std::error::Error>;
type Result<T> = std::result::Result<T, Error>;

// Will return an Ok(()) if the request has successfully been submitted to Bluefin
async fn send_request(request: WithdrawRequest, auth_token: &str) -> Result<()> {
    println!("Sending request...");
    // Send request and get back order hash
    let mut config = Configuration::new();
    config.bearer_access_token = Some(auth_token.into());
    config.base_path = trade::mainnet::URL.into();

    post_withdraw(&config, request).await?;

    Ok(())
}

#[tokio::main]
async fn main() -> Result<()> {
    // Then, we construct an authentication request to obtain a token.
    let request = LoginRequest {
        account_address: "INSERT_ACCOUNT_ADDRESS_HERE",
        audience: auth::mainnet::AUDIENCE.into(),
        signed_at_millis: Utc::now().timestamp_millis(),
    };

    // Next, we generate a signature for the request.
    let signature = request.signature(
        SignatureScheme::Ed25519,
        PrivateKey::from_hex("INSERT_HEX_ENCODED_PRIVATE_KEY_HERE")?,
    )?;

    // Then, we submit our authentication request to the API for the desired environment.
    let auth_token = request
        .authenticate(&signature, Environment::Mainnet)
        .await?
        .access_token;

    // Gets the 1st asset available
    let asset = get_exchange_info(&Configuration {
        base_path: exchange::mainnet::URL.into(),
        ..Configuration::default()
    })
    .await?
    .assets
    .first()
    .ok_or("Missing Asset")?
    .to_owned();

    // We get the exchange info to fetch the EDS_ID
    let contracts_info = exchange::info::contracts_config(Environment::Mainnet).await?;

    // Then, we construct a request.
    let request = WithdrawRequest {
        signed_fields: WithdrawRequestSignedFields {
            asset_symbol: asset.symbol.clone(),
            account_address: "INSERT_ACCOUNT_ADDRESS_HERE",
            amount_e9: (10.e9()).to_string(),
            salt: random::<u64>().to_string(),
            eds_id: contracts_info.eds_id,
            signed_at_millis: Utc::now().timestamp_millis(),
        },
        ..Default::default()
    };

    let request = request.sign(
        PrivateKey::from_hex("INSERT_HEX_ENCODED_PRIVATE_KEY_HERE")?,
        SignatureScheme::Ed25519,
    )?;

    send_request(request, &auth_token).await?;

    Ok(())
}

```

## HTTPs

Alternatively, call the POST /trade/withdraw endpoint using the integrated editor on the right or locally from any language supporting HTTPs network calls.

## Request & Response

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Bluefin Trade API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://trade.api.{env}.bluefin.io",
      "variables": {
        "env": {
          "default": "sui-staging",
          "enum": [
            "sui-staging",
            "sui-prod"
          ]
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Trade",
      "description": "Bluefin Trade API"
    }
  ],
  "paths": {
    "/api/v1/trade/withdraw": {
      "post": {
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "tags": [
          "Trade"
        ],
        "operationId": "postWithdraw",
        "summary": "/trade/withdraw",
        "description": "Initiates a withdraw action to remove some amount of funds from a user's account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WithdrawRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Withdraw request submitted successfully."
          },
          "400": {
            "description": "Bad Request. The request was invalid or malformed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "InvalidRequest": {
                    "value": {
                      "errorCode": "INVALID_REQUEST",
                      "message": "The provided request is invalid."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Authentication is required or invalid. Signature is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not Found. The requested resource was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests. The request was rate limited.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error. An unexpected error occurred on the server.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable. The service is currently unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WithdrawRequest": {
        "type": "object",
        "properties": {
          "signedFields": {
            "type": "object",
            "properties": {
              "assetSymbol": {
                "type": "string",
                "description": "Asset symbol of the withdrawn asset",
                "example": "ETH"
              },
              "accountAddress": {
                "type": "string",
                "description": "The Account Address from which to withdraw assets",
                "example": 2748
              },
              "amountE9": {
                "type": "string",
                "description": "The amount in e9 of the asset that the User will withdraw from their account",
                "example": 1000000000
              },
              "salt": {
                "type": "string",
                "description": "A uniqueness modifier for the request. This is added to guarantee uniqueness of the request. Usually a mix of timestamp and a random number",
                "example": "432558574839487"
              },
              "edsId": {
                "type": "string",
                "description": "the ID of the external datastore for the target network",
                "example": "eds_id"
              },
              "signedAtMillis": {
                "type": "integer",
                "format": "int64",
                "description": "The timestamp in milliseconds when the HTTP Request payload has been signed",
                "example": 12454325432
              }
            },
            "required": [
              "assetSymbol",
              "accountAddress",
              "amountE9",
              "salt",
              "edsId",
              "signedAtMillis"
            ]
          },
          "signature": {
            "type": "string",
            "description": "The signature of the request, encoded from the signedFields"
          }
        },
        "required": [
          "signedFields",
          "signature"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "errorCode": {
            "type": "string",
            "description": "A code representing the type of error."
          },
          "message": {
            "type": "string",
            "description": "A human-readable message describing the error."
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "url base64 encoded JWT token payload."
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```