Skip to main content

Get User Wallet Details

GET /api/detalleCartera
Retrieves the wallet (cartera) details for the authenticated user.
Requires authenticated session. Uses session to identify current user.
Each user has exactly one wallet created automatically during registration with an initial balance of 0.
curl -X GET "https://api.investgo.com/api/detalleCartera" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Cookie: JSESSIONID=your_session_id"
{
  "idCartera": 5,
  "saldo": 25000.00,
  "idUsu": 5,
  "usuario": {
    "id": 5,
    "nombre": "Juan",
    "apellidoPa": "Pérez",
    "correo": "[email protected]",
    "username": "juanperez"
  }
}

List All Wallets (Admin)

GET /api/admin/listarCarteras
Retrieves all wallets in the system.
Admin authentication required
curl -X GET "https://api.investgo.com/api/admin/listarCarteras" \
  -H "Authorization: Bearer ADMIN_TOKEN"
[
  {
    "idCartera": 1,
    "saldo": 15000.00,
    "idUsu": 2,
    "usuario": {
      "id": 2,
      "nombre": "María",
      "apellidoPa": "González",
      "correo": "[email protected]"
    }
  },
  {
    "idCartera": 2,
    "saldo": 25000.00,
    "idUsu": 3,
    "usuario": {
      "id": 3,
      "nombre": "Carlos",
      "apellidoPa": "Rodríguez",
      "correo": "[email protected]"
    }
  }
]

Wallet Schema

idCartera
integer
Wallet unique identifier
saldo
double
Current wallet balance
idUsu
long
User ID who owns the wallet
usuario
object
User details

Wallet Management

Automatic Creation

Wallets are automatically created when a user registers:
  • Initial balance: 0
  • One wallet per user
  • Created in the same transaction as user registration

Balance Updates

Wallet balances are updated through:
  • Deposits: Transfer from bank account to wallet (increases balance)
  • Withdrawals: Transfer from wallet to bank account (decreases balance)
  • Investments: When investing in opportunities (decreases balance)
  • Returns: When investment opportunities pay out (increases balance)

Balance Operations

curl -X POST "https://api.investgo.com/api/deposito" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "monto": 5000.00,
    "idCuentaBancaria": 1
  }'

Balance Validation

The system enforces balance validation:
  • Cannot withdraw more than available wallet balance
  • Cannot deposit more than available bank account balance
  • All balance updates are atomic (either all succeed or all fail)

Example Balance Flow

  1. Initial State
    • Wallet balance: 10,000
    • Bank account balance: 5,000
  2. After Deposit of 3,000
    • Wallet balance: 13,000 ✓
    • Bank account balance: 2,000 ✓
  3. Attempted Withdrawal of 15,000
    • ❌ Fails: Insufficient wallet balance
    • Balances remain unchanged
  4. After Withdrawal of 8,000
    • Wallet balance: 5,000 ✓
    • Bank account balance: 10,000 ✓

Build docs developers (and LLMs) love