Get Agent Investments
curl --request GET \
--url https://api.magebank.ai/savings/{agentId} \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.magebank.ai/savings/{agentId}"
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/{agentId}', 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/{agentId}",
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/{agentId}"
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/{agentId}")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/savings/{agentId}")
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{
"investments": [
{
"id": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"agent_id": "agent_k77NTwxp2Ym3JCmVsKtXQA",
"amount": 1000,
"invested_at": "2025-04-15T11:00:08.432269+00:00",
"status": "active",
"current_value": "1050.00",
"interest_earned": "50.00"
},
{
"id": "inv_p99QTaxp3Zm3KDnWtLuRrD",
"agent_id": "agent_k77NTwxp2Ym3JCmVsKtXQA",
"amount": 500,
"invested_at": "2025-03-10T09:15:22.123456+00:00",
"status": "completed",
"current_value": "515.25",
"interest_earned": "15.25"
}
]
}
{
"error": "Bad request"
}
{
"error": "Invalid or missing API key"
}
```json 404
{
"error": "Agent not found"
}
{
"error": "Internal server error"
}
Savings
Get Agent Investments
Get all investments for a specific agent
GET
/
savings
/
{agentId}
Get Agent Investments
curl --request GET \
--url https://api.magebank.ai/savings/{agentId} \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.magebank.ai/savings/{agentId}"
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/{agentId}', 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/{agentId}",
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/{agentId}"
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/{agentId}")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/savings/{agentId}")
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{
"investments": [
{
"id": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"agent_id": "agent_k77NTwxp2Ym3JCmVsKtXQA",
"amount": 1000,
"invested_at": "2025-04-15T11:00:08.432269+00:00",
"status": "active",
"current_value": "1050.00",
"interest_earned": "50.00"
},
{
"id": "inv_p99QTaxp3Zm3KDnWtLuRrD",
"agent_id": "agent_k77NTwxp2Ym3JCmVsKtXQA",
"amount": 500,
"invested_at": "2025-03-10T09:15:22.123456+00:00",
"status": "completed",
"current_value": "515.25",
"interest_earned": "15.25"
}
]
}
{
"error": "Bad request"
}
{
"error": "Invalid or missing API key"
}
```json 404
{
"error": "Agent not found"
}
{
"error": "Internal server error"
}
Investment History: Retrieves all investments (both active and completed) associated with a specific agent. For active investments, calculates the current value and interest earned based on the principal amount, interest rate, and investment duration. Returns detailed information including investment status and creation timestamp.
Path Parameters
string
required
The short ID or UUID of the agent
Request Headers
string
required
Your API key for authentication
Response
array
Show Investment Object
Show Investment Object
string
Unique investment identifier in short ID format
string
ID of the agent associated with this investment
number
Principal amount invested
string
Timestamp when the investment was created
string
Current status of the investment (active, completed, cancelled)
string
Current value of the investment including earned interest
string
Interest earned on the investment to date
{
"investments": [
{
"id": "inv_k77NTwxp2Ym3JCmVsKtXQA",
"agent_id": "agent_k77NTwxp2Ym3JCmVsKtXQA",
"amount": 1000,
"invested_at": "2025-04-15T11:00:08.432269+00:00",
"status": "active",
"current_value": "1050.00",
"interest_earned": "50.00"
},
{
"id": "inv_p99QTaxp3Zm3KDnWtLuRrD",
"agent_id": "agent_k77NTwxp2Ym3JCmVsKtXQA",
"amount": 500,
"invested_at": "2025-03-10T09:15:22.123456+00:00",
"status": "completed",
"current_value": "515.25",
"interest_earned": "15.25"
}
]
}
{
"error": "Bad request"
}
{
"error": "Invalid or missing API key"
}
```json 404
{
"error": "Agent not found"
}
{
"error": "Internal server error"
}
Status Codes
| Status Code | Description |
|---|---|
| 200 | List of investments retrieved successfully |
| 400 | Bad Request - Invalid agent ID format |
| 401 | Unauthorized - Invalid or missing API key |
| 404 | Not Found - Agent not found |
| 500 | Internal Server Error |
All Investment Statuses: This endpoint returns all investments for the agent regardless of status (active, completed, cancelled).
Real-time Calculations: For active investments, current values and interest earned are calculated in real-time based on the current interest rate and investment duration.
Completed Investments: For completed investments, the values shown represent the final amounts at the time of withdrawal.