Portfolios
Update my portfolio allocation
Persist target allocation weights for the signed-in investor portfolio. The response matches GET portfolio by id, including the updated targetAllocation array.
POST
/
portfolios
/
me
/
allocation
Update target allocation for the signed-in user
curl --request POST \
--url https://{host}/portfolios/me/allocation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-user-id: <x-user-id>' \
--data '
{
"allocation": {
"equities_uk": 50,
"equities_eu": 50
}
}
'import requests
url = "https://{host}/portfolios/me/allocation"
payload = { "allocation": {
"equities_uk": 50,
"equities_eu": 50
} }
headers = {
"x-user-id": "<x-user-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-user-id': '<x-user-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({allocation: {equities_uk: 50, equities_eu: 50}})
};
fetch('https://{host}/portfolios/me/allocation', 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://{host}/portfolios/me/allocation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allocation' => [
'equities_uk' => 50,
'equities_eu' => 50
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/portfolios/me/allocation"
payload := strings.NewReader("{\n \"allocation\": {\n \"equities_uk\": 50,\n \"equities_eu\": 50\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-user-id", "<x-user-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/portfolios/me/allocation")
.header("x-user-id", "<x-user-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"allocation\": {\n \"equities_uk\": 50,\n \"equities_eu\": 50\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/portfolios/me/allocation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"allocation\": {\n \"equities_uk\": 50,\n \"equities_eu\": 50\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"currency": "<string>",
"holdings": [
{
"isin": "<string>",
"assetCommonId": "<string>",
"quantity": 123
}
],
"targetAllocation": [
{
"assetCommonId": "<string>",
"percentage": 123
}
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"status": 123,
"error": {
"message": "<string>",
"description": "<string>"
},
"responseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"status": 401,
"error": {
"message": "User not found"
},
"responseId": "56962f31-e1bc-4a32-8b47-623f793aa2f8"
}{
"status": 403,
"error": {
"message": "Portfolio does not belong to user"
},
"responseId": "1c8b2106-5f8f-4f71-8f06-23a53205b384"
}{
"status": 404,
"error": {
"message": "Portfolio not found"
},
"responseId": "77354fbd-2d0a-4f5a-8e15-a64c2b7ac3b5"
}Authorizations
Auth0-issued access token that includes the scopes listed for the route.
Headers
MongoDB identifier of the user whose portfolio is being queried.
Pattern:
^[a-f0-9]{24}$Body
application/json
Response
Updated portfolio view (same shape as GET portfolio by id), including holdings and target allocation.
Portfolio unique identifier.
ISO currency code for the portfolio (e.g. EUR, GBP, USD).
Array of holdings with asset details and quantities.
Show child attributes
Show child attributes
Target allocation by asset. Weights are persisted with the portfolio. May be an empty array when unset.
Show child attributes
Show child attributes
Portfolio creation timestamp.
Last update timestamp.
⌘I
Update target allocation for the signed-in user
curl --request POST \
--url https://{host}/portfolios/me/allocation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-user-id: <x-user-id>' \
--data '
{
"allocation": {
"equities_uk": 50,
"equities_eu": 50
}
}
'import requests
url = "https://{host}/portfolios/me/allocation"
payload = { "allocation": {
"equities_uk": 50,
"equities_eu": 50
} }
headers = {
"x-user-id": "<x-user-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-user-id': '<x-user-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({allocation: {equities_uk: 50, equities_eu: 50}})
};
fetch('https://{host}/portfolios/me/allocation', 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://{host}/portfolios/me/allocation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'allocation' => [
'equities_uk' => 50,
'equities_eu' => 50
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/portfolios/me/allocation"
payload := strings.NewReader("{\n \"allocation\": {\n \"equities_uk\": 50,\n \"equities_eu\": 50\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-user-id", "<x-user-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/portfolios/me/allocation")
.header("x-user-id", "<x-user-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"allocation\": {\n \"equities_uk\": 50,\n \"equities_eu\": 50\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/portfolios/me/allocation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"allocation\": {\n \"equities_uk\": 50,\n \"equities_eu\": 50\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"currency": "<string>",
"holdings": [
{
"isin": "<string>",
"assetCommonId": "<string>",
"quantity": 123
}
],
"targetAllocation": [
{
"assetCommonId": "<string>",
"percentage": 123
}
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"status": 123,
"error": {
"message": "<string>",
"description": "<string>"
},
"responseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"status": 401,
"error": {
"message": "User not found"
},
"responseId": "56962f31-e1bc-4a32-8b47-623f793aa2f8"
}{
"status": 403,
"error": {
"message": "Portfolio does not belong to user"
},
"responseId": "1c8b2106-5f8f-4f71-8f06-23a53205b384"
}{
"status": 404,
"error": {
"message": "Portfolio not found"
},
"responseId": "77354fbd-2d0a-4f5a-8e15-a64c2b7ac3b5"
}