API Reference / Margin Requirements
Margin Requirements Dry Run
createMarginAccountsAccountNumberDryRun/margin/accounts/{account_number}/dry-runBase URL: https://api.tastyworks.com ()
Estimates the margin impact of a prospective order on the account without placing it. The body matches the order you would submit, plus account-number, underlying-symbol, and underlying-instrument-type (Equity, Equity Option, Future, Future Option, or Cryptocurrency). The response compares the account before and after via change-in-margin-requirement, change-in-buying-power, and the current-buying-power vs new-buying-power pair, with full per-underlying breakdowns under last-results, base-results, and new-order-results. A dry-run never creates an order, so it is safe to repeat; always run it before submitting a real order.
Code samples
curl -X POST 'https://api.tastyworks.com/margin/accounts/5WX01234/dry-run' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'User-Agent: tastytrade-docs-example/1.0' \
-H 'Content-Type: application/json' \
-d '{
"account-number": "5WX01234",
"underlying-symbol": "AAPL",
"order-type": "string",
"time-in-force": "string",
"gtc-date": "2024-01-15",
"price": "100.00",
"price-effect": "Credit",
"stop-trigger": "string",
"replaces-order-id": "abc123",
"legs": [
{
"symbol": "AAPL",
"instrument-type": "Equity",
"quantity": "1",
"action": "string",
"remaining-quantity": "1"
}
],
"underlying-instrument-type": "Equity"
}'import requests
import json
url = "https://api.tastyworks.com/margin/accounts/5WX01234/dry-run"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "tastytrade-docs-example/1.0",
}
payload = json.loads("""
{
"account-number": "5WX01234",
"underlying-symbol": "AAPL",
"order-type": "string",
"time-in-force": "string",
"gtc-date": "2024-01-15",
"price": "100.00",
"price-effect": "Credit",
"stop-trigger": "string",
"replaces-order-id": "abc123",
"legs": [
{
"symbol": "AAPL",
"instrument-type": "Equity",
"quantity": "1",
"action": "string",
"remaining-quantity": "1"
}
],
"underlying-instrument-type": "Equity"
}
""")
resp = requests.post(url, headers=headers, json=payload)
print(resp.status_code, resp.json())const resp = await fetch("https://api.tastyworks.com/margin/accounts/5WX01234/dry-run", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "tastytrade-docs-example/1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
"account-number": "5WX01234",
"underlying-symbol": "AAPL",
"order-type": "string",
"time-in-force": "string",
"gtc-date": "2024-01-15",
"price": "100.00",
"price-effect": "Credit",
"stop-trigger": "string",
"replaces-order-id": "abc123",
"legs": [
{
"symbol": "AAPL",
"instrument-type": "Equity",
"quantity": "1",
"action": "string",
"remaining-quantity": "1"
}
],
"underlying-instrument-type": "Equity"
}),
})
const data = await resp.json()
console.log(resp.status, data)package main
import (
"net/http"
"io"
"fmt"
"strings"
)
func main() {
body := strings.NewReader(`{
"account-number": "5WX01234",
"underlying-symbol": "AAPL",
"order-type": "string",
"time-in-force": "string",
"gtc-date": "2024-01-15",
"price": "100.00",
"price-effect": "Credit",
"stop-trigger": "string",
"replaces-order-id": "abc123",
"legs": [
{
"symbol": "AAPL",
"instrument-type": "Equity",
"quantity": "1",
"action": "string",
"remaining-quantity": "1"
}
],
"underlying-instrument-type": "Equity"
}`)
req, _ := http.NewRequest("POST", "https://api.tastyworks.com/margin/accounts/5WX01234/dry-run", body)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("User-Agent", "tastytrade-docs-example/1.0")
req.Header.Set("Content-Type", "application/json")
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.tastyworks.com/margin/accounts/5WX01234/dry-run"))
.header("Authorization", "Bearer YOUR_ACCESS_TOKEN")
.header("User-Agent", "tastytrade-docs-example/1.0")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"account-number": "5WX01234",
"underlying-symbol": "AAPL",
"order-type": "string",
"time-in-force": "string",
"gtc-date": "2024-01-15",
"price": "100.00",
"price-effect": "Credit",
"stop-trigger": "string",
"replaces-order-id": "abc123",
"legs": [
{
"symbol": "AAPL",
"instrument-type": "Equity",
"quantity": "1",
"action": "string",
"remaining-quantity": "1"
}
],
"underlying-instrument-type": "Equity"
}
"""))
.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" |
Request bodyapplication/json
Example
{
"account-number": "5WX01234",
"underlying-symbol": "AAPL",
"order-type": "string",
"time-in-force": "string",
"gtc-date": "2024-01-15",
"price": "100.00",
"price-effect": "Credit",
"stop-trigger": "string",
"replaces-order-id": "abc123",
"legs": [
{
"symbol": "AAPL",
"instrument-type": "Equity",
"quantity": "1",
"action": "string",
"remaining-quantity": "1"
}
],
"underlying-instrument-type": "Equity"
}Schema
account-numberrequiredstringunderlying-symbolrequiredstringorder-typerequiredstringtime-in-forcerequiredstringgtc-datestring <date>pricestring <numeric>price-effectstringenum: Credit, Debit
stop-triggerstring <numeric>replaces-order-idstring <numeric>legsarray<object>symbolrequiredstringinstrument-typerequiredstringquantitystring <numeric>actionrequiredstringremaining-quantitystring <numeric>
underlying-instrument-typerequiredstringThe instrument type of the underlying symbol.
enum: Equity, Equity Option, Future, Future Option, Cryptocurrency
example:
"Equity"
Responses
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:
read· idempotent — Rate limits & backoff - 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.