---
agentTools:
  siteIndex: https://docs.alpaca.markets/llms.txt
  projectIndex: https://docs.alpaca.markets/us/llms.txt
---

# New "group_id" and "group_role" fields on orders

Adds two optional fields to the `Order` and `OrderLeg` schemas so callers can identify which bracket, OTO, or OCO order an individual order belongs to:

* `group_id`: an opaque UUID shared by every order in the same `bracket`, `oto`, or `oco` order, including legs and replacements.
* `group_role`: one of `entry`, `take_profit`, or `stop_loss` from the new `OrderGroupRole` enum. For `oco` orders, the top-level order is `take_profit`.

Both keys are omitted for orders that are not part of a `bracket`, `oto`, or `oco` order. New bracket-order response examples have been added.

## Broker API

Trade events delivered over SSE carry `group_id` and `group_role` on the order payload, so stream-only clients can group legs that arrive individually with `legs: null`. A bracket-leg trade update example has been added.

### Affected Endpoints

* `POST /v1/trading/accounts/{account_id}/orders`
* `GET /v1/trading/accounts/{account_id}/orders`
* `GET /v1/trading/accounts/{account_id}/orders/{order_id}`
* `GET /v1/trading/accounts/{account_id}/orders:by_client_order_id`
* `PATCH /v1/trading/accounts/{account_id}/orders/{order_id}`
* `DELETE /v1/trading/accounts/{account_id}/orders`
* `POST /v1/trading/accounts/{account_id}/orders/estimation`
* `DELETE /v1/trading/accounts/{account_id}/positions`
* `DELETE /v1/trading/accounts/{account_id}/positions/{symbol_or_asset_id}`
* `GET /v1/rebalancing/runs`
* `GET /v1/rebalancing/runs/{run_id}`
* `GET /v2/events/trades`

## Trading API

* `POST /v2/orders`
* `GET /v2/orders`
* `GET /v2/orders/{order_id}`
* `GET /v2/orders:by_client_order_id`
* `PATCH /v2/orders/{order_id}`
* `DELETE /v2/positions`
* `DELETE /v2/positions/{symbol_or_asset_id}`