Skip to main content

POST /api/accounts/:id/deposit

Deposit a specified amount into an account. This is a test/utility endpoint for adding funds to accounts during development.
This endpoint is intended for testing and development purposes. In a production environment, you would typically use transactions to record income rather than directly depositing funds.

Authentication

This endpoint requires a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Path Parameters

id
string
required
UUID of the account to deposit into

Request Body

amount
number
required
Amount to deposit (must be positive)

Response

Returns the updated account with the new balance.
id
string
Account UUID
name
string
Account name
type
string
Account type (WALLET, SAVINGS, INVESTMENT, CREDIT_CARD)
currency
string
Account currency code
balance
number
Updated balance after deposit
color
string
Account color (hex code)
icon
string
Account icon name

Example Request

cURL
curl -X POST http://localhost:3000/api/accounts/uuid-123/deposit \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 1000
  }'
JavaScript
const accountId = 'uuid-123';
const response = await fetch(`http://localhost:3000/api/accounts/${accountId}/deposit`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    amount: 1000
  })
});

const data = await response.json();

Example Response

{
  "id": "uuid-123",
  "name": "Main Wallet",
  "type": "WALLET",
  "currency": "ARS",
  "balance": 6000,
  "color": "#3B82F6",
  "icon": "wallet",
  "isDefault": true,
  "userId": "user-uuid",
  "createdAt": "2024-01-15T10:00:00.000Z",
  "updatedAt": "2024-01-15T11:30:00.000Z"
}

Error Responses

{
  "statusCode": 400,
  "message": "Amount must be positive"
}
{
  "statusCode": 404,
  "message": "Account not found"
}
{
  "statusCode": 401,
  "message": "Unauthorized"
}

Use Cases

Testing

Quickly add funds to accounts during development and testing

Initial Setup

Set up initial balances when onboarding users
For production use, create income transactions instead of using this deposit endpoint. This maintains proper transaction history and audit trails.

Alternative Approach

Instead of using the deposit endpoint, consider creating an income transaction:
curl -X POST http://localhost:3000/api/transactions \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "INCOME",
    "amount": 1000,
    "currency": "ARS",
    "description": "Initial deposit",
    "accountId": "uuid-123"
  }'
This approach maintains a full transaction history and is recommended for production use.

Build docs developers (and LLMs) love