POST /api/accounts/transfer
Transfer a specified amount from one account to another. Both accounts must belong to the authenticated user and have the same currency.
Authentication
This endpoint requires a valid JWT token in the Authorization header.
Authorization: Bearer <token>
Request Body
UUID of the source account
UUID of the destination account
Amount to transfer (must be positive)
Optional description for the transfer
Response
Returns both updated account balances.
Updated source account
Updated balance after transfer
Updated destination account
Updated balance after transfer
Example Request
curl -X POST http://localhost:3000/api/accounts/transfer \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"fromAccountId": "uuid-account-1",
"toAccountId": "uuid-account-2",
"amount": 500,
"description": "Monthly savings transfer"
}'
const response = await fetch('http://localhost:3000/api/accounts/transfer', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fromAccountId: 'uuid-account-1',
toAccountId: 'uuid-account-2',
amount: 500,
description: 'Monthly savings transfer'
})
});
const data = await response.json();
Example Response
{
"fromAccount": {
"id": "uuid-account-1",
"name": "Main Wallet",
"type": "WALLET",
"currency": "ARS",
"balance": 4500,
"color": "#3B82F6",
"icon": "wallet"
},
"toAccount": {
"id": "uuid-account-2",
"name": "Emergency Fund",
"type": "SAVINGS",
"currency": "ARS",
"balance": 5500,
"targetAmount": 10000,
"color": "#10B981",
"icon": "piggy-bank"
}
}
Error Responses
{
"statusCode": 400,
"message": "Amount must be positive"
}
{
"statusCode": 400,
"message": "Cannot transfer between accounts with different currencies"
}
{
"statusCode": 400,
"message": "Insufficient funds in source account"
}
{
"statusCode": 404,
"message": "Source or destination account not found"
}
Validation Rules
- Both accounts must belong to the authenticated user
- Accounts must have the same currency
- Amount must be positive and greater than zero
- Source account must have sufficient balance
- Cannot transfer to the same account
Create Account
Create a new account
List Accounts
View all your accounts