v51

latestOpenAPI 3.0.0raw.githubusercontent.com2026-08-0175184292.5 KB
Trading

Place complex order

Places a complex conditional order (OCO, OTO, or OTOCO). Only supported on certain brokerages. Please refer to the brokerage trading support page for details on which brokerages support complex orders and which types they support.

  • OCO (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
  • OTO (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
  • OTOCO (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
post/accounts/{accountId}/trading/complex

Path parameters

accountIdstring uuid required

Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

Example:917c8734-8470-4a3e-a18f-57c3f2ee6631

The ID of the account to execute the trade on.

Query parameters

userIdstring required

SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

Example:snaptrade-user-123
userSecretstring required

SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the rotate user secret endpoint.

Example:adf2aa34-8219-40f7-a6b3-60156985cc61

Request body

type'OCO' | 'OTO' | 'OTOCO' required

The complex order type.

  • OCO: One Cancels the Other — two peer orders.
  • OTO: One Triggers the Other — a trigger order and a conditional order.
  • OTOCO: One Triggers a One Cancels the Other — a trigger order and two peer orders.
client_order_idstring uuid nullable

Optional caller-supplied identifier passed through to the brokerage for idempotent order placement. Must be a canonical 36-character UUID. Idempotency enforcement is brokerage-specific - SnapTrade forwards this value to the broker but does not enforce uniqueness server-side. Refer to per-brokerage documentation for behavior on duplicate submission.

Example request

{
  "type": "OTO",
  "orders": [
    {
      "order_role": "TRIGGER",
      "instrument": {
        "symbol": "AAPL"
      },
      "order_type": "Market",
      "units": 10.5,
      "time_in_force": "Day",
      "price": 31.33,
      "stop": 29.5
    }
  ],
  "client_order_id": "550e8400-e29b-41d4-a716-446655440000"
}

Response

OK

type'OCO' | 'OTO' | 'OTOCO'

The complex order type that was placed.

brokerage_group_order_idstring nullable

The brokerage-assigned identifier that links all legs of this complex order together. Each leg will eventually appear as a separate AccountOrderRecord sharing this value. May be null if the brokerage does not return a group identifier.

Example response

{
  "type": "OTO",
  "brokerage_group_order_id": "1234567890"
}