Deposit Savings
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
}
'import requests
url = "https://api.magebank.ai/savings/deposit"
payload = {
"agentId": "<string>",
"amount": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agentId: '<string>', amount: 123})
};
fetch('https://api.magebank.ai/savings/deposit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magebank.ai/savings/deposit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agentId' => '<string>',
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/savings/deposit"
payload := strings.NewReader("{\n \"agentId\": \"<string>\",\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magebank.ai/savings/deposit")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"<string>\",\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/savings/deposit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"<string>\",\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Successfully invested 100.50 USDC.",
"investmentId": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"transaction": {
"txHash": "0x123...abc",
"status": "completed"
}
}
{
"error": "agentId and amount are required"
// OR
"error": "Amount must be a positive number"
// OR
"error": "Agent has insufficient balance"
}
{
"error": "Agent not found"
}
{
"error": "Invalid or missing API key"
}
{
"error": "Internal server error"
}
Savings
Deposit Savings
Deposit savings into an agent’s account
POST
/
savings
/
deposit
Deposit Savings
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
}
'import requests
url = "https://api.magebank.ai/savings/deposit"
payload = {
"agentId": "<string>",
"amount": 123
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agentId: '<string>', amount: 123})
};
fetch('https://api.magebank.ai/savings/deposit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magebank.ai/savings/deposit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agentId' => '<string>',
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/savings/deposit"
payload := strings.NewReader("{\n \"agentId\": \"<string>\",\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.magebank.ai/savings/deposit")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"<string>\",\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/savings/deposit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"<string>\",\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Successfully invested 100.50 USDC.",
"investmentId": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"transaction": {
"txHash": "0x123...abc",
"status": "completed"
}
}
{
"error": "agentId and amount are required"
// OR
"error": "Amount must be a positive number"
// OR
"error": "Agent has insufficient balance"
}
{
"error": "Agent not found"
}
{
"error": "Invalid or missing API key"
}
{
"error": "Internal server error"
}
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
string
required
Your API key for authentication
Request Body
string
required
The short ID or UUID of the agent
number
required
Amount to deposit (must be positive)
Response
boolean
Whether the deposit was successful
string
Information about the deposit
string
The ID of the newly created investment
object
{
"success": true,
"message": "Successfully invested 100.50 USDC.",
"investmentId": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"transaction": {
"txHash": "0x123...abc",
"status": "completed"
}
}
{
"error": "agentId and amount are required"
// OR
"error": "Amount must be a positive number"
// OR
"error": "Agent has insufficient balance"
}
{
"error": "Agent not found"
}
{
"error": "Invalid or missing API key"
}
{
"error": "Internal server error"
}
Status Codes
| Status Code | Description |
|---|---|
| 200 | Deposit completed successfully |
| 400 | Bad Request - Invalid or missing parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 404 | Not Found - Agent not found |
| 500 | Internal 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.