tastytradeDeveloper Docs
Legacy ↗

API Reference / Margin Requirements

Margin Requirements Dry Run

createMarginAccountsAccountNumberDryRun
post/margin/accounts/{account_number}/dry-run

Base 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"
}'

Parameters

NameInTypeDescription
account_number*pathstring
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-numberrequiredstring
  • underlying-symbolrequiredstring
  • order-typerequiredstring
  • time-in-forcerequiredstring
  • gtc-datestring <date>
  • pricestring <numeric>
  • price-effectstring

    enum: Credit, Debit

  • stop-triggerstring <numeric>
  • replaces-order-idstring <numeric>
  • legsarray<object>
    • symbolrequiredstring
    • instrument-typerequiredstring
    • quantitystring <numeric>
    • actionrequiredstring
    • remaining-quantitystring <numeric>
  • underlying-instrument-typerequiredstring

    The instrument type of the underlying symbol.

    enum: Equity, Equity Option, Future, Future Option, Cryptocurrency

    example: "Equity"

Responses

200The estimated margin impact of the order, comparing the account before and after, with per-underlying breakdowns.application/json
401Authentication failed. The Authorization bearer token is missing, expired (access tokens last 15 minutes), or the required User-Agent header is missing or malformed.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.

403Forbidden. The token is valid but its scope or the account's authority level does not permit running a margin dry-run on this account.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 account was found for the supplied account_number, or the wrong environment was used (sandbox vs production).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 order could not be evaluated. The body is missing required fields, uses non-dasherized or wrong-typed keys, or describes an order that is invalid in context (for example an unknown symbol). Read error.message for the specific 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.

429Rate limit exceeded. Back off exponentially and reduce the 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.