Link ungrouped positions into a group.
POST
/api/position-groups/link
const url = 'https://api.tradr.cloud/api/position-groups/link';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"labelOverride":"example","positionIds":["2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tradr.cloud/api/position-groups/link \ --header 'Content-Type: application/json' \ --data '{ "labelOverride": "example", "positionIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ] }'Authed. Links 2 to 8 existing open or closed, ungrouped positions sharing one account and underlying into a new group. Writes only the group row and each leg’s groupId — no fill or ledger row, and each leg’s updatedAt is left unchanged. Refuses a draft leg or one already in a group (409, naming the symbol), legs in different accounts or with a bad leg set (400, naming the leg index), or a foreign position id (404), before any write.
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
labelOverride
string
positionIds
required
Array<string>
Examplegenerated
{ "labelOverride": "example", "positionIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ]}Responses
Section titled “ Responses ”The new group
Validation error
A position id was not found (or not owned by the user).
A leg is a draft or already grouped; names its symbol.