# TypeScript SDK — Clearing: Instant Orders

Get instant quotes and execute instant trades. All methods are on `client.clearingInstant`.

See the [API specifications](/api-specifications) for full request/response schemas and the [authentication guide](/tools/typescript-sdk/authentication) for setup.

## Methods

### getInstantQuote

`POST /v1/instant/quote` · Authenticated

Requests a price quote for an instant trade. The request uses `totalSpend` to specify the trade size. For **buy** orders, `totalSpend` is the fiat amount you want to spend (e.g. USD). For **sell** orders, `totalSpend` is the **CCY1 quantity** you want to sell (e.g. BTC amount), not a dollar amount.

```ts
const quote = await client.clearingInstant.getInstantQuote({
  symbol: "BTCUSD",
  side: "buy",
  totalSpend: "100.00",
});

console.log(`Quote: ${quote.price} per BTC, fee: ${quote.fee}`);
console.log(`Quantity: ${quote.quantity} ${quote.quantityCurrency}`);
console.log(`Total spend: ${quote.totalSpend} ${quote.totalSpendCurrency}`);
console.log(`Quote ID: ${quote.quoteId}`); // number — pass this to executeInstantOrder
```

> **Tip:** Quotes are time-limited (`maxAgeMs` tells you how long). Execute promptly or request a fresh quote. `quoteId` is a **number** (not bigint or string). Prices, quantities, and fees are decimal strings.

This is a POST mutation — never automatically retried.

### executeInstantOrder

`POST /v1/instant/execute` · Authenticated

Executes an instant trade using a previously obtained quote. The request body is [validated client-side](/tools/typescript-sdk/deep-dives/request-validation). The SDK enforces:

- `symbol` — required string
- `quantity` — required string
- `price` — required string
- `fee` — required string
- `side` — required enum: `"buy"` or `"sell"`
- `quoteId` — required number

```ts
const result = await client.clearingInstant.executeInstantOrder({
  symbol: "BTCUSD",
  side: "buy",
  quantity: quote.quantity!,
  price: quote.price!,
  fee: quote.fee!,
  quoteId: quote.quoteId!,
});

// orderId is optional in the response
if (result.orderId != null) {
  console.log(`Order ID: ${result.orderId}`);
}
console.log(`Executed: ${result.quantity} ${result.quantityCurrency} @ ${result.price}`);
```

> **Caveat:** This is a POST mutation — never automatically retried. The `quoteId` must reference a valid, unexpired quote from `getInstantQuote`. All string fields (`quantity`, `price`, `fee`) must match the quote response values exactly. The `quoteId` in the request is a `number`.


## Typical instant trade flow

1. Request a quote with `getInstantQuote` using `totalSpend`
2. Display the quote to the user (price, quantity, fees)
3. Execute with `executeInstantOrder`, passing the `quoteId` and the exact `price`, `quantity`, and `fee` from the quote

```ts
// 1. Get a quote — specify how much to spend
const quote = await client.clearingInstant.getInstantQuote({
  symbol: "ETHUSD",
  side: "buy",
  totalSpend: "500.00",
});

// 2. Execute the quote — pass exact values from the quote response
const execution = await client.clearingInstant.executeInstantOrder({
  symbol: "ETHUSD",
  side: "buy",
  quantity: quote.quantity!,
  price: quote.price!,
  fee: quote.fee!,
  quoteId: quote.quoteId!,
});
```

## What's next

- [Clearing Orders](/tools/typescript-sdk/reference/clearing/clearing-orders) — standard OTC clearing order management
- [Request Validation](/tools/typescript-sdk/deep-dives/request-validation) — how client-side validation works
- [Data Types](/tools/typescript-sdk/deep-dives/data-types) — decimal strings and bigint fields
