POST
/
savings
/
deposit
curl --request POST \
  --url https://api.magebank.ai/savings/deposit \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <x-api-key>' \
  --data '{
  "agentId": "<string>",
  "amount": 123
}'
{
  "success": true,
  "message": "Successfully invested 100.50 USDC.",
  "investmentId": "inv_k77NTwxp2Ym3JCmVsKtXQA",
  "transaction": {
    "txHash": "0x123...abc",
    "status": "completed"
  }
}

Investment Creation: Creates a new investment by depositing funds into an agent’s savings account. The operation converts the agent ID to UUID format if provided in short format, validates the deposit amount, and creates a new investment record.

Request Headers

x-api-key
string
required

Your API key for authentication

Request Body

agentId
string
required

The short ID or UUID of the agent

amount
number
required

Amount to deposit (must be positive)

Response

success
boolean

Whether the deposit was successful

message
string

Information about the deposit

investmentId
string

The ID of the newly created investment

transaction
object
{
  "success": true,
  "message": "Successfully invested 100.50 USDC.",
  "investmentId": "inv_k77NTwxp2Ym3JCmVsKtXQA",
  "transaction": {
    "txHash": "0x123...abc",
    "status": "completed"
  }
}

Status Codes

Status CodeDescription
200Deposit completed successfully
400Bad Request - Invalid or missing parameters
401Unauthorized - Invalid or missing API key
404Not Found - Agent not found
500Internal Server Error

Agent ID Format: The API accepts both short ID format (agent_xxx) and UUID format for the agent ID parameter.

Amount Validation: The deposit amount must be a positive number. The system will validate this before processing the transaction.

Investment Record: A new investment record is created when the deposit is processed successfully. This can be used to track the investment’s growth over time.