Create Portfolio Block
/extensions/roboinvestor/{graph_id}/operations/create-portfolio-blockPart of Extensions: RoboInvestor.
Create a portfolio with optional initial positions in a single atomic envelope. Each position references an existing security; this operation never mints securities (use create-security). Whole envelope validates before any write.
Idempotency: supply an Idempotency-Key header to make safe retries; replays within 24 hours return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.
Authentication
Authenticate in any one of these ways — not all of them:
- API key in the
X-API-Keyheader. - Bearer token in the
Authorizationheader.
Path parameters
| Name | Type | Description |
|---|---|---|
graph_idrequired | string | Graph Id |
Header parameters
| Name | Type | Description |
|---|---|---|
Idempotency-Keyoptional | string | Idempotency-Key |
Request body
Required, application/json.
| Field | Type | Description | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
portfoliorequired | PortfolioBlockPortfolioFields | Core portfolio fields — name, currency, owning entity, etc. PortfolioBlockPortfolioFields fields
| |||||||||||||||||||||||||||||||||
positionsoptional | PortfolioBlockPositionAdd[] | Initial positions to mint inside the new portfolio. Each references an existing security; pass `[]` to create an empty portfolio. PortfolioBlockPositionAdd fields
|
Example request
curl -X POST "https://api.robosystems.ai/extensions/roboinvestor/{graph_id}/operations/create-portfolio-block" \
-H "X-API-Key: $ROBOSYSTEMS_API_KEY" \
-H "Idempotency-Key: <Idempotency-Key>" \
-H "Content-Type: application/json" \
-d '{
"portfolio": {
"base_currency": "USD",
"description": "Mid-cap public equities",
"entity_id": "ent_acme_holdings",
"inception_date": "2026-01-01",
"name": "Q1 2026 Growth",
"strategy": "growth"
},
"positions": [
{
"acquisition_date": "2026-01-15",
"cost_basis": 1850000,
"currency": "USD",
"current_value": 2010000,
"quantity": 100,
"quantity_type": "shares",
"security_id": "sec_aapl",
"valuation_date": "2026-04-30",
"valuation_source": "broker_statement"
},
{
"acquisition_date": "2026-02-08",
"cost_basis": 2125000,
"currency": "USD",
"current_value": 2240000,
"quantity": 50,
"quantity_type": "shares",
"security_id": "sec_msft",
"valuation_date": "2026-04-30",
"valuation_source": "broker_statement"
}
]
}'Responses
200 Successful Response
| Field | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operationrequired | string | Kebab-case operation name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
operationIdrequired | string | op_-prefixed ULID for audit and SSE correlation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
statusrequired | string | Operation lifecycle state One of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
resultoptional | PortfolioBlockEnvelope | Command-specific result payload PortfolioBlockEnvelope fields
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
atrequired | string | ISO-8601 UTC timestamp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
createdByoptional | string | User ID that initiated the operation (null for legacy callers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
idempotentReplayoptional | boolean | True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions. Default: |
| Status | Meaning |
|---|---|
| 400 | Invalid request |
| 401 | Authentication required |
| 403 | Access denied |
| 404 | Resource not found |
| 409 | Idempotency-Key conflict — key reused with different body |
| 422 | Validation error |
| 429 | Rate limit exceeded |
| 500 | Internal server error |