POST
/
agents
/
withdraw
curl --request POST \
  --url https://api.magebank.ai/agents/withdraw \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <x-api-key>' \
  --data '{
  "userid": "<string>",
  "agentid": "<string>",
  "amount": 123,
  "currency": "<string>"
}'
{
  "success": true,
  "txHash": "0x123...abc",
  "message": "Successfully withdrew 50 USDC from agent to user",
  "updatedBalance": "50"
}

Withdrawal Process: Transfers funds from the agent’s wallet to the user’s wallet. The operation includes: 1. Verification of user and agent existence 2. Validation of withdrawal amount against available balance 3. Transfer of funds on blockchain 4. Update of agent balance in database 5. Creation of transaction record

Request Headers

x-api-key
string
required

Your API key for authentication

Request Body

userid
string
required

ID of the user receiving the withdrawal

agentid
string
required

ID of the agent sending the funds

amount
number
required

Amount to withdraw

currency
string
default:"USDC"

Currency type to withdraw (defaults to USDC)

Response

success
boolean

Whether the withdrawal was successful

txHash
string

Transaction hash on the blockchain

message
string

Information about the withdrawal

updatedBalance
string

New balance of the agent after the withdrawal

{
  "success": true,
  "txHash": "0x123...abc",
  "message": "Successfully withdrew 50 USDC from agent to user",
  "updatedBalance": "50"
}

Status Codes

Status CodeDescription
200Funds withdrawn successfully
400Invalid request parameters
404Not Found
500Transaction failed

Balance Requirement: The agent must have sufficient balance to complete the withdrawal. The transaction will fail if the requested amount exceeds the available balance.

Blockchain Transaction: This operation creates an on-chain transaction which may take a few moments to be confirmed depending on network conditions.