Overview
This guide explains how to execute a portfolio buy transaction that distributes an investment amount across multiple assets in a user’s portfolio. The flow includes fetching automations to determine if monthly investment buttons should be enabled, verifying cash availability, previewing the transaction, and executing based on smart execution preferences.All investment operations require M2M authentication with a bearer token and the
x-user-id header to specify which user’s portfolio to access.Prerequisites
- Access to API endpoints
- M2M bearer token with required scopes
x-user-idheader (user identifier, MongoDB ObjectId format)- Portfolio ID for the user
Portfolio Quick Buy Flow
1
Fetch automations
Before displaying the portfolio buy interface, fetch the user’s automations to determine if the monthly investment button should be enabled.Call
GET /automations to retrieve all recurring investment automations for the user.Successful response returns an array of automations. Filter for
category: "TopUpAutomation" and status: "Active" to determine if monthly automation is enabled.2
Fetch available cash
Retrieve the user’s available cash balance to verify sufficient funds for the investment.Call
GET /cash to retrieve the available cash balance across all currencies.3
Fetch portfolio buy preview
Get a preview of the portfolio buy transaction to show execution options, fees breakdown, and estimated orders.Call
POST /investments/portfolio/preview with the portfolio ID, order amount, and allocation method.The preview response includes:
- Execution windows for both scenarios
- Fees breakdown (commission, FX, realtime execution)
- Estimated quantities per asset
- Foreign currency rates (if applicable)
4
Execute portfolio buy based on smart execution toggle
Execute the portfolio buy transaction based on the user’s smart execution preference.Call
POST /investments/portfolio/orders with the portfolio ID, order amount, allocation method, and execution preference.Successful execution returns an
AssetTransaction object with:- Transaction ID and status
- Execution window information
- Array of orders created
- Fees breakdown
- Display amounts and quantities
Error Handling
- 400 Bad Request: Validation failure or business rule violation (e.g., insufficient cash, invalid allocation method, target allocation not set up)
- 401/403: Authentication/authorization failures
- 404 Not Found: Portfolio not found or does not belong to user
See Also
- API Reference → Preview Portfolio Buy
- API Reference → Execute Portfolio Buy Order
- API Reference → Get Automations
- API Reference → Get Cash