GET
/
savings
/
{agentId}
curl --request GET \
  --url https://api.magebank.ai/savings/{agentId} \
  --header 'x-api-key: <x-api-key>'
{
  "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"
    }
  ]
}

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

agentId
string
required

The short ID or UUID of the agent

Request Headers

x-api-key
string
required

Your API key for authentication

Response

investments
array
{
  "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"
    }
  ]
}

Status Codes

Status CodeDescription
200List of investments retrieved successfully
400Bad Request - Invalid agent ID format
401Unauthorized - Invalid or missing API key
404Not Found - Agent not found
500Internal 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.