Get User Investments
curl --request GET \
--url https://api.magebank.ai/savings/myinvestments \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.magebank.ai/savings/myinvestments"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.magebank.ai/savings/myinvestments', 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/myinvestments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/savings/myinvestments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.magebank.ai/savings/myinvestments")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/savings/myinvestments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"agents": [
{
"agent": "Payment Assistant",
"investment_id": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"totalBalance": 1200.5,
"investedAmount": 1000,
"currentValue": 1200.5,
"interest": 200.5,
"current": 1000,
"daysInvested": 365
},
{
"agent": "Marketing Budget",
"investment_id": "inv_j88MTaxp3Zm3KDnWtLuPpB",
"totalBalance": 300.25,
"investedAmount": 300,
"currentValue": 300.25,
"interest": 0.25,
"current": 500,
"daysInvested": 2
}
]
}
{
"agents": []
}
{
"error": "Invalid or missing API key"
}
{
"error": "Internal Server Error"
}
Savings
Get User Investments
Get all active investments for the authenticated user
GET
/
savings
/
myinvestments
Get User Investments
curl --request GET \
--url https://api.magebank.ai/savings/myinvestments \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.magebank.ai/savings/myinvestments"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.magebank.ai/savings/myinvestments', 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/myinvestments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/savings/myinvestments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.magebank.ai/savings/myinvestments")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/savings/myinvestments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"agents": [
{
"agent": "Payment Assistant",
"investment_id": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"totalBalance": 1200.5,
"investedAmount": 1000,
"currentValue": 1200.5,
"interest": 200.5,
"current": 1000,
"daysInvested": 365
},
{
"agent": "Marketing Budget",
"investment_id": "inv_j88MTaxp3Zm3KDnWtLuPpB",
"totalBalance": 300.25,
"investedAmount": 300,
"currentValue": 300.25,
"interest": 0.25,
"current": 500,
"daysInvested": 2
}
]
}
{
"agents": []
}
{
"error": "Invalid or missing API key"
}
{
"error": "Internal Server Error"
}
Active Investments: Retrieve a comprehensive list of all active investments across all your agents with real-time value calculations.
Request Headers
string
required
Your API key for authentication
Response
array
Show Agent Investment Details
Show Agent Investment Details
string
Name of the agent
string
Investment ID in short format
number
Total balance including investment value
number
Principal amount invested
number
Current value with interest
number
Interest earned to date
number
Current balance in agent’s account
number
Days the investment has been active
{
"agents": [
{
"agent": "Payment Assistant",
"investment_id": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"totalBalance": 1200.5,
"investedAmount": 1000,
"currentValue": 1200.5,
"interest": 200.5,
"current": 1000,
"daysInvested": 365
},
{
"agent": "Marketing Budget",
"investment_id": "inv_j88MTaxp3Zm3KDnWtLuPpB",
"totalBalance": 300.25,
"investedAmount": 300,
"currentValue": 300.25,
"interest": 0.25,
"current": 500,
"daysInvested": 2
}
]
}
{
"agents": []
}
{
"error": "Invalid or missing API key"
}
{
"error": "Internal Server Error"
}
Status Codes
| Status Code | Description |
|---|---|
| 200 | List of active investments retrieved successfully |
| 401 | Unauthorized - Invalid or missing API key |
| 500 | Internal Server Error |
Active Only: This endpoint returns only active investments; completed or cancelled investments are not included.
Real-time Calculations: Interest values are calculated in real-time based on the current platform interest rate and exact investment duration.
Total Balance: The
totalBalance for each agent includes both the investment value and the regular wallet balance.