Skip to main content

Create Portfolio

Overview

The Create Portfolio API allows you to create or update a portfolio for a specific business with product allocations and percentages.

Resource Access

  • HTTP Method: POST
  • Endpoint: /v1/businesses/{business_id}/portfolio
  • Authentication: Bearer token required

Path Parameters

ParameterTypeRequiredDescription
business_idstring (UUID)YesUnique identifier for the business

Request Headers

HeaderValueRequiredDescription
Acceptapplication/jsonYesContent type for the response
AuthorizationBearer {access_token}YesBearer token for authentication

Request Body

The request body should contain a JSON object with the following structure:

{
"products": [
{
"product": "managed_money_market",
"percentage": 45
},
{
"product": "managed_treasuries",
"percentage": 45
},
{
"product": "managed_income",
"percentage": 10
}
]
}

Products Array

FieldTypeRequiredDescription
productstringYesProduct type. Allowed values: managed_money_market, managed_treasuries, managed_income
percentagenumberYesPercentage allocation for this product (0-100)

Note: The sum of all product percentages should typically equal 100, though this may be validated on the server side.

Response

Success Response (200 OK)

{
"id": "urn:uuid:portfolio-123",
"business_id": "urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc",
"products": [
{
"product": "managed_money_market",
"percentage": 45
},
{
"product": "managed_treasuries",
"percentage": 45
},
{
"product": "managed_income",
"percentage": 10
}
],
"created_at": "2022-01-01T00:00:00.000Z",
"updated_at": "2022-01-01T00:00:00.000Z"
}

Error Responses

  • 400 Bad Request: Invalid input data
  • 401 Unauthorized: Invalid or missing authentication token
  • 404 Not Found: Business not found
  • 422 Unprocessable Entity: Validation failed (e.g., percentages don't sum correctly)

Code Examples

cURL

curl -X POST \
'https://api.example.com/v1/businesses/urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc/portfolio' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-d '{
"products": [
{
"product": "managed_money_market",
"percentage": 45
},
{
"product": "managed_treasuries",
"percentage": 45
},
{
"product": "managed_income",
"percentage": 10
}
]
}'

Python

import requests

url = "https://api.example.com/v1/businesses/urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc/portfolio"
headers = {
"Accept": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
"products": [
{
"product": "managed_money_market",
"percentage": 45
},
{
"product": "managed_treasuries",
"percentage": 45
},
{
"product": "managed_income",
"percentage": 10
}
]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

JavaScript (Node.js)

const axios = require('axios');

const url = 'https://api.example.com/v1/businesses/urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc/portfolio';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
};
const data = {
products: [
{
product: 'managed_money_market',
percentage: 45
},
{
product: 'managed_treasuries',
percentage: 45
},
{
product: 'managed_income',
percentage: 10
}
]
};

axios.post(url, data, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response.data);
});

Interactive API Explorer