---
title: "Delete Portfolio Block"
method: POST
path: "/extensions/roboinvestor/{graph_id}/operations/delete-portfolio-block"
tags: ["RoboInvestor"]
---

# Delete Portfolio Block

`POST /extensions/roboinvestor/{graph_id}/operations/delete-portfolio-block`

## Request

- Base URL: `https://api.robosystems.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.robosystems.ai/extensions/roboinvestor/{graph_id}/operations/delete-portfolio-block`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Cascade-delete the portfolio plus all of its positions. When active positions exist, the request must include `confirm_active_positions: true` — safety belt to prevent accidental cascade. Disposed-only portfolios delete without the flag.

**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.

## Path parameters

- `graph_id` string, required

## Headers

- `Idempotency-Key` string, nullable

## Request body

- DeletePortfolioBlockOperation: CQRS body for `POST /operations/delete-portfolio-block`. Cascade-deletes the portfolio plus all of its positions. When the portfolio still has active positions, the operation is rejected unless `confirm_active_positions=true` is set — safety belt to prevent accidental cascade.
  - `portfolio_id` string, required: Target portfolio ID.
  - `confirm_active_positions` boolean: Required acknowledgement when the portfolio has active positions. Set `true` to consent to cascade-deleting them; leave `false` and the operation returns 409 if any active positions exist.

## Response `200`

Successful Response

- OperationEnvelopeDeletePortfolioBlockResponse
  - `operation` string, required: Kebab-case operation name
  - `operationId` string, required: op_-prefixed ULID for audit and SSE correlation
  - `status` 'completed' | 'pending' | 'failed', required: Operation lifecycle state
  - `result` DeletePortfolioBlockResponse: Result envelope for `delete-portfolio-block`. `positions_deleted` carries the count of position rows removed alongside the portfolio.
    - `deleted` boolean, required: `true` when the portfolio row was removed.
    - `portfolio_id` string, required: ID of the portfolio that was deleted.
    - `positions_deleted` integer, required: Count of position rows cascade-deleted with the portfolio.
  - `at` string, required: ISO-8601 UTC timestamp
  - `createdBy` string, nullable: User ID that initiated the operation
  - `idempotentReplay` boolean: True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

## Other responses

- `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

---

[API](https://skmtc.dev/robosystems/apis/robosystems-api.md) · [All operations](https://skmtc.dev/robosystems/apis/robosystems-api/llms.txt) · [OpenAPI document](https://skmtc.dev/robosystems/apis/robosystems-api/revisions/e661e2d5ca6a?raw)
