tastytradeDeveloper Docs
Legacy ↗

API Reference / Orders

Cancel Complex Order

deleteAccountsAccountNumberComplexOrdersId
delete/accounts/{account_number}/complex-orders/{id}Money-moving

Money-moving. Dry-run first, send an ext-client-order-id, and confirm before submitting. See Idempotency & retries.

Base URL: https://api.cert.tastyworks.com (Sandbox) · https://api.tastyworks.com (Production)

Requests cancellation of all non-terminal component orders of a complex order. The `id` must be the complex order id, not its trigger order id or any nested order id. Successfully requested components transition to `Cancel Requested` and then `Cancelled` once the exchange confirms.

Code samples

curl -X DELETE 'https://api.cert.tastyworks.com/accounts/5WX01234/complex-orders/1' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'User-Agent: tastytrade-docs-example/1.0'

Parameters

NameInTypeDescription
account_number*pathstring
e.g. "5WX01234"
id*pathinteger
e.g. 1

Responses

200The complex order with its components transitioning to a cancelled state.application/json

Example response

{
  "data": {
    "id": "2000010530",
    "account-number": "5WX01234",
    "ratio-price-comparator": "lte",
    "ratio-price-is-threshold-based-on-notional": false,
    "ratio-price-threshold": "1.25",
    "terminal-at": "2024-07-31T16:50:23.417+00:00",
    "type": "OTOCO",
    "related-orders": [
      {
        "id": "abc123",
        "complex-order-id": "abc123",
        "complex-order-tag": "string",
        "replaces-order-id": "abc123",
        "replacing-order-id": "abc123",
        "status": "string"
      }
    ],
    "orders": [
      {
        "id": "abc123",
        "account-number": "5WX01234",
        "cancel-user-id": "abc123",
        "cancel-username": "string",
        "cancellable": true,
        "cancelled-at": "2024-01-15T14:30:00.000Z",
        "complex-order-id": "abc123",
        "complex-order-tag": "string",
        "confirmation-status": "string",
        "contingent-status": "string",
        "editable": true,
        "edited": true,
        "external-identifier": "string",
        "global-request-id": "abc123",
        "gtc-date": "2024-01-15",
        "in-flight-at": "2024-01-15T14:30:00.000Z",
        "liquidity-pool-instrument-type": "Equity",
        "live-at": "2024-01-15T14:30:00.000Z",
        "max-value-per-liquidity-allocation-fill": "100.00",
        "order-type": "string",
        "preflight-id": "abc123",
        "price": "100.00",
        "price-effect": "100.00",
        "received-at": "2024-01-15T14:30:00.000Z",
        "reject-reason": "string",
        "replaces-order-id": "abc123",
        "replacing-order-id": "abc123",
        "size": "string",
        "source": "string",
        "status": "string",
        "stop-trigger": "string",
        "terminal-at": "2024-01-15T14:30:00.000Z",
        "time-in-force": "string",
        "underlying-instrument-type": "Equity",
        "underlying-symbol": "AAPL",
        "updated-at": "2024-01-15T14:30:00.000Z",
        "user-id": "abc123",
        "username": "string",
        "value": "100.00",
        "value-effect": "100.00",
        "legs": [
          {
            "action": "string",
            "instrument-type": "Equity",
            "quantity": "1",
            "remaining-quantity": "1",
            "symbol": "AAPL",
            "fills": []
          }
        ],
        "order-rule": {
          "cancel-at": "2024-01-15T14:30:00.000Z",
          "cancelled-at": "2024-01-15T14:30:00.000Z",
          "route-after": "2024-01-15T14:30:00.000Z",
          "routed-at": "2024-01-15T14:30:00.000Z",
          "order-conditions": [
            {}
          ]
        }
      }
    ],
    "trigger-order": {
      "id": "abc123",
      "account-number": "5WX01234",
      "cancel-user-id": "abc123",
      "cancel-username": "string",
      "cancellable": true,
      "cancelled-at": "2024-01-15T14:30:00.000Z",
      "complex-order-id": "abc123",
      "complex-order-tag": "string",
      "confirmation-status": "string",
      "contingent-status": "string",
      "editable": true,
      "edited": true,
      "external-identifier": "string",
      "global-request-id": "abc123",
      "gtc-date": "2024-01-15",
      "in-flight-at": "2024-01-15T14:30:00.000Z",
      "liquidity-pool-instrument-type": "Equity",
      "live-at": "2024-01-15T14:30:00.000Z",
      "max-value-per-liquidity-allocation-fill": "100.00",
      "order-type": "string",
      "preflight-id": "abc123",
      "price": "100.00",
      "price-effect": "100.00",
      "received-at": "2024-01-15T14:30:00.000Z",
      "reject-reason": "string",
      "replaces-order-id": "abc123",
      "replacing-order-id": "abc123",
      "size": "string",
      "source": "string",
      "status": "string",
      "stop-trigger": "string",
      "terminal-at": "2024-01-15T14:30:00.000Z",
      "time-in-force": "string",
      "underlying-instrument-type": "Equity",
      "underlying-symbol": "AAPL",
      "updated-at": "2024-01-15T14:30:00.000Z",
      "user-id": "abc123",
      "username": "string",
      "value": "100.00",
      "value-effect": "100.00",
      "legs": [
        {
          "action": "string",
          "instrument-type": "Equity",
          "quantity": "1",
          "remaining-quantity": "1",
          "symbol": "AAPL",
          "fills": [
            {}
          ]
        }
      ],
      "order-rule": {
        "cancel-at": "2024-01-15T14:30:00.000Z",
        "cancelled-at": "2024-01-15T14:30:00.000Z",
        "route-after": "2024-01-15T14:30:00.000Z",
        "routed-at": "2024-01-15T14:30:00.000Z",
        "order-conditions": [
          {
            "id": "abc123",
            "action": "string",
            "comparator": "string",
            "indicator": "string",
            "instrument-type": "Equity",
            "is-threshold-based-on-notional": true,
            "symbol": "AAPL",
            "threshold": "string",
            "triggered-at": "2024-01-15T14:30:00.000Z",
            "triggered-value": "100.00",
            "price-components": []
          }
        ]
      }
    }
  },
  "context": "/accounts/{account_number}/complex-orders/{id}"
}

Schema

  • datarequiredobject (ComplexOrder)

    A complex (bracket) order that groups one or more component orders, and optionally a trigger order, into a single strategy. The strategy `type` is one of `OTOCO`, `OCO`, `OTO`, or `PAIRS` (`BLAST` is deprecated). For OTOCO and OTO orders the trigger order routes immediately and the remaining orders stay `Contingent` until it fills.

    • idstring

      The unique identifier of the complex order. Use it (not a component or trigger order id) to fetch or cancel the complex order.

      example: "2000010530"

    • account-numberstring

      The account number the complex order belongs to.

      example: "5WX01234"

    • ratio-price-comparatorstring

      For PAIRS orders, how the ratio price is compared against the threshold: `gte` or `lte`.

      example: "lte"

    • ratio-price-is-threshold-based-on-notionalboolean

      For PAIRS orders, whether the threshold comparison is in notional value rather than price.

      example: false

    • ratio-price-thresholdstring <decimal>

      For PAIRS orders, the ratio price threshold that triggers the trade. Serialized as a JSON string decimal. Decimal value serialized as a JSON string (e.g. "150.25").

      example: "1.25"

    • terminal-atstring

      Timestamp when the complex order reached a terminal state, if applicable.

      example: "2024-07-31T16:50:23.417+00:00"

    • typestring

      The complex order strategy: `OTOCO`, `OCO`, `OTO`, or `PAIRS`.

      example: "OTOCO"

    • related-ordersarray<object>{6 fields}
    • ordersarray<object>{42 fields}
    • trigger-orderobject{42 fields}

      Order with complex-order-tag: '<type>::trigger-order'. For example, 'OTO::trigger-order for OTO complex orders.

  • contextrequiredstring

    example: "/accounts/{account_number}/complex-orders/{id}"

401Missing or expired access token, or a missing/malformed `User-Agent` header.application/json

Example response

{
  "error": {
    "code": "unauthorized",
    "message": "No valid access token was provided; access tokens expire after 15 minutes."
  }
}

Schema

  • errorrequiredobject
    • coderequiredstring

      Machine-readable error code (see the Error reference).

    • messagerequiredstring

      Human-readable explanation.

    • errorsarray<object>{3 fields}

      Present for multi-error / validation failures; one entry per problem.

403The token's scope or the account authority does not permit cancelling this account's orders.application/json

Example response

{
  "error": {
    "code": "not_permitted",
    "message": "User not permitted access"
  }
}

Schema

  • errorrequiredobject
    • coderequiredstring

      Machine-readable error code (see the Error reference).

    • messagerequiredstring

      Human-readable explanation.

    • errorsarray<object>{3 fields}

      Present for multi-error / validation failures; one entry per problem.

404No complex order with this id exists on the account.application/json

Example response

{
  "error": {
    "code": "string",
    "message": "string",
    "errors": [
      {
        "code": "string",
        "message": "string",
        "domain": "string"
      }
    ]
  }
}

Schema

  • errorrequiredobject
    • coderequiredstring

      Machine-readable error code (see the Error reference).

    • messagerequiredstring

      Human-readable explanation.

    • errorsarray<object>{3 fields}

      Present for multi-error / validation failures; one entry per problem.

422The complex order (or all its components) is already in a terminal status and cannot be cancelled. Read `error.message` for the reason.application/json

Example response

{
  "error": {
    "code": "preflight_check_failure",
    "message": "One or more preflight checks failed",
    "errors": [
      {
        "code": "preflight_check_failure",
        "message": "A specific validation failed for this order."
      }
    ]
  }
}

Schema

  • errorrequiredobject
    • coderequiredstring

      Machine-readable error code (see the Error reference).

    • messagerequiredstring

      Human-readable explanation.

    • errorsarray<object>{3 fields}

      Present for multi-error / validation failures; one entry per problem.

429Request rate exceeded. Back off exponentially and reduce your request rate.application/json

Example response

{
  "error": {
    "code": "string",
    "message": "string",
    "errors": [
      {
        "code": "string",
        "message": "string",
        "domain": "string"
      }
    ]
  }
}

Schema

  • errorrequiredobject
    • coderequiredstring

      Machine-readable error code (see the Error reference).

    • messagerequiredstring

      Human-readable explanation.

    • errorsarray<object>{3 fields}

      Present for multi-error / validation failures; one entry per problem.

Related

Agents: this page is also Markdown (with the embedded OpenAPI definition) — append .md or send Accept: text/markdown. Index at /llms.txt.