For AI agents: the documentation index is available at https://docs.snaptrade.com/llms.txt, and the comprehensive documentation index is available at https://docs.snaptrade.com/llms-full.txt. The complete public OpenAPI specification is available at https://docs.snaptrade.com/openapi.yaml. Complete public OpenAPI specification with all documented operations, schemas, servers, and authentication requirements. Use it for SDK generation and API tooling; beta operations are marked x-beta. Markdown versions of documentation pages are available by appending .md to the URL path.
Trading

Cancel order

post
https://api.snaptrade.com/accounts/{accountId}/trading/cancel

Cancels an order in the specified account. Accepts order IDs for all asset types.

Execute an API Request

Authentication Method

Use a Commercial API Key when your app manages users and their connection experience.

Credentials
Path
accountIdstring (format: uuid)required

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

Request Body
brokerage_order_idstringrequired

Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

Request
Installation
$
npm install snaptrade-typescript-sdk
1
import {
2
Snaptrade,
3
SnaptradeAuth,
4
} from "snaptrade-typescript-sdk";
5
6
const snaptrade = new Snaptrade({
7
auth: SnaptradeAuth.commercialApiKey({
8
consumerKey: "CONSUMER_KEY",
9
clientId: "CLIENT_ID",
10
}),
11
});
12
13
const response =
14
await snaptrade.trading.cancelOrder({
15
accountId:
16
"917c8734-8470-4a3e-a18f-57c3f2ee6631",
17
userId: "USER_ID",
18
userSecret: "USER_SECRET",
19
brokerage_order_id:
20
"66a033fa-da74-4fcf-b527-feefdec9257e",
21
});
22
console.log(response.data);

Response fields

object

Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

raw_responseobject or null

The raw response from the brokerage.

1
{
2
"brokerage_order_id": "66a033fa-da74-4fcf-b527-feefdec9257e",
3
"raw_response": {
4
"order_id": "1234567890",
5
"status": "CANCELLED"
6
}
7
}