Cancel Complex Order
deleteAccountsAccountNumberComplexOrdersId/accounts/{account_number}/complex-orders/{id}Money-movingMoney-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'import requests
url = "https://api.cert.tastyworks.com/accounts/5WX01234/complex-orders/1"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "tastytrade-docs-example/1.0",
}
resp = requests.delete(url, headers=headers)
print(resp.status_code, resp.json())const resp = await fetch("https://api.cert.tastyworks.com/accounts/5WX01234/complex-orders/1", {
method: "DELETE",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "tastytrade-docs-example/1.0",
},
})
const data = await resp.json()
console.log(resp.status, data)package main
import (
"net/http"
"io"
"fmt"
)
func main() {
req, _ := http.NewRequest("DELETE", "https://api.cert.tastyworks.com/accounts/5WX01234/complex-orders/1", nil)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("User-Agent", "tastytrade-docs-example/1.0")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.Status, string(out))
}import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.cert.tastyworks.com/accounts/5WX01234/complex-orders/1"))
.header("Authorization", "Bearer YOUR_ACCESS_TOKEN")
.header("User-Agent", "tastytrade-docs-example/1.0")
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.statusCode() + " " + resp.body());Parameters
| Name | In | Type | Description |
|---|---|---|---|
| account_number* | path | string | e.g. "5WX01234" |
| id* | path | integer | e.g. 1 |
Responses
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.
idstringThe 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-numberstringThe account number the complex order belongs to.
example:
"5WX01234"ratio-price-comparatorstringFor PAIRS orders, how the ratio price is compared against the threshold: `gte` or `lte`.
example:
"lte"ratio-price-is-threshold-based-on-notionalbooleanFor PAIRS orders, whether the threshold comparison is in notional value rather than price.
example:
falseratio-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-atstringTimestamp when the complex order reached a terminal state, if applicable.
example:
"2024-07-31T16:50:23.417+00:00"typestringThe 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.
contextrequiredstringexample:
"/accounts/{account_number}/complex-orders/{id}"
Example response
{
"error": {
"code": "unauthorized",
"message": "No valid access token was provided; access tokens expire after 15 minutes."
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "not_permitted",
"message": "User not permitted access"
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "string",
"message": "string",
"errors": [
{
"code": "string",
"message": "string",
"domain": "string"
}
]
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
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
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Example response
{
"error": {
"code": "string",
"message": "string",
"errors": [
{
"code": "string",
"message": "string",
"domain": "string"
}
]
}
}Schema
errorrequiredobjectcoderequiredstringMachine-readable error code (see the Error reference).
messagerequiredstringHuman-readable explanation.
errorsarray<object>{3 fields}Present for multi-error / validation failures; one entry per problem.
Related
- Rate-limit class:
destructive· idempotent — Rate limits & backoff - Idempotency & retries — safe retries for order placement
- Error reference — codes, causes, and fixes
Agents: this page is also Markdown (with the embedded OpenAPI definition) — append .md or send Accept: text/markdown. Index at /llms.txt.