Skip to content

Errors & retries

What each endpoint can return is in the API reference, and request limits are in Rate limits. The SDK turns every error response into a typed exception, so you can catch the case you care about:

try
{
await client.GetOrderAsync(orderId);
}
catch (STXNotFoundException)
{
Console.WriteLine("no such order");
}
catch (STXRateLimitException ex)
{
Console.WriteLine($"slow down, retry after {ex.RetryAfter}");
}
Exception Thrown for
STXValidationException 400
STXAuthenticationException 401
STXForbiddenException 403, such as a write with a read_only key
STXBlockedException 403 from the firewall in front of the API (Reason, Reference); see Blocked requests
STXRestrictedJurisdictionException 403 restricted_jurisdiction: a location the exchange does not serve
STXUnusualNetworkException 403 unusual_network: a network the exchange does not accept, such as an anonymizing proxy
STXInsufficientScopeException 403 on an OAuth token without the scope the call needs (RequiredScopes)
STXIpNotAllowedException 403 ip_not_allowed
STXTermsRequiredException 403 terms_required: the member has new STX terms to accept (TermsUrl)
STXNotFoundException 404
STXRejectedException 422
STXFillModeNotAllowedException 422: the market does not take the order’s fill mode (FillMode); see Post-only and fill-or-kill
STXPostOnlyWouldMatchException a post-only order that would have matched (Reason, Order)
STXRateLimitException 429 (RetryAfter, and Reference when the firewall answered)
STXServerException 5xx
STXTransportException no response: connection, DNS, TLS or timeout
STXConfigException a client misconfiguration, such as a missing key
STXChannelException a refused or unanswered WebSocket join or command (Reason, Reply)
STXNotAvailableException a feature this exchange does not have yet (Feature, Host); see What you can do
STXComboException, STXComboPriceMovedException a refused combo command; see Combos

All of them derive from STXException. API errors derive from STXApiException and carry Message (the API’s error text), StatusCode, Body, Method and Path.

Failure GET, DELETE POST
429 retried after Retry-After retried after Retry-After
5xx retried not retried
No response retried not retried
403, including a blocked request not retried not retried
Any other 4xx not retried not retried

A 429 is retried after the server’s Retry-After, in full; when that is longer than MaxBackoff (30 seconds by default), the call is not retried and the STXRateLimitException reaches you with RetryAfter. A failed POST may still have placed the order, so it is never resent; see Avoid duplicate orders. Each attempt is signed again. The default is 3 attempts with exponential backoff from 500 ms, capped at 30 seconds.

using var patient = new STXClient(new STXClientOptions
{
Retry = STXRetryPolicy.Default with { MaxAttempts = 5 },
Timeout = TimeSpan.FromSeconds(10),
});
using var noRetries = new STXClient(new STXClientOptions { Retry = STXRetryPolicy.None });

A firewall in front of the API can refuse a request before it reaches the exchange. It answers with an error and a message, and the SDK throws a typed exception carrying them, with Reference, the request’s id from the x-amz-cf-id response header:

error Status Exception
restricted_jurisdiction 403 STXRestrictedJurisdictionException
unusual_network 403 STXUnusualNetworkException
rate_limited 429 STXRateLimitException, with RetryAfter (60 seconds) and Reference
try
{
await client.GetBalanceAsync();
}
catch (STXBlockedException ex)
{
Console.WriteLine($"{ex.Reason}: {ex.Message} (reference {ex.Reference})");
// restricted_jurisdiction: STX isn't available in your country. Quote the reference when you contact STX support. (reference Yq3vD8KXhZ2mN0pLr6sT4uWb9eFgHjKl1cVxQaZs-_d0EnRoPiUyTw==)
}
catch (STXRateLimitException ex) when (ex.Reference is not null)
{
Console.WriteLine($"rate limited, retry after {ex.RetryAfter}");
}

Quote the Reference when you contact Support. A blocked request is never retried. A 403 with no JSON body at all is also a STXBlockedException, with Reason blocked: the API refuses requests without a User-Agent header. The client always sends one (STXClient.UserAgent, on REST and on the WebSocket handshake), so check that no proxy or custom HttpMessageHandler removes it.

OnResponse is called after every attempt with the method, path, status, duration and bodies, and LoggerFactory sends the SDK’s own log lines (retries, reconnects) to your logging:

using var client = new STXClient(new STXClientOptions
{
OnResponse = e => Console.WriteLine($"{e.Method} {e.Path} {e.Status} {e.Duration.TotalMilliseconds:0} ms"),
LoggerFactory = loggerFactory,
});
await client.GetMeAsync();
// GET /api/v1/me 200 84 ms

STX is operated by XV Exchange, LLC, a Designated Contract Market regulated by the U.S. Commodity Futures Trading Commission (CFTC). Contracts traded on STX are cleared by XV Clearing, LLC, a CFTC-registered Derivatives Clearing Organization. Trading involves substantial risk of loss and may not be appropriate for everyone. Members risk losing the cost to enter any transaction, including fees. Consider whether trading is appropriate for you in light of your experience and financial resources. Nothing on this site is investment advice or a recommendation to trade. Past performance is not indicative of future results.

© 2026 STX. All rights reserved.llms.txtllms-full.txtView as Markdown
Docs version v1.10.5