Blocked requests
Every STX host sits behind a firewall at the edge, in front of the API. It can refuse a request before the request reaches the API. A refusal from the edge is not an API error: the request was never signed, checked or acted on, so it is safe to send again once the cause is gone.
Send a User-Agent
Section titled “Send a User-Agent”Every request needs a User-Agent header: REST calls, GET /api_version and the WebSocket
handshake alike. A request without one is refused with 403, even when it is correctly signed.
Browsers and most HTTP clients send one by default. Some WebSocket and low-level HTTP
libraries, such as Node’s ws, send none unless you set it. Name your integration and its
version:
User-Agent: acme-trader/2.3.1What a blocked API request returns
Section titled “What a blocked API request returns”A request to an API path (/api, /api_version, /socket) that the edge blocks gets a JSON
body in place of the API’s response:
{ "error": "rate_limited", "message": "Too many requests. Quote the reference when you contact STX support.", "reference": "x-amz-cf-id response header"}error |
Status | Why | What to do |
|---|---|---|---|
restricted_jurisdiction |
403 |
The request came from a country where STX is not available. | Send requests only from where your account is allowed to trade. |
unusual_network |
403 |
The request came from a network the edge does not accept, such as some VPNs, proxies and hosting providers, or it looked automated. | Send it from another network. If your servers are refused, contact support with the reference. |
rate_limited |
429 |
Too many requests from your address in a short time. | Wait for the number of seconds in the Retry-After header, then retry with backoff. |
Treat error as the field to branch on: message is for people and can change. New values
may be added, so handle a code you do not recognize like any other 403.
The API’s own errors also carry error, but not reference, so reference tells the two
apart. A 403 whose body is HTML rather than JSON also comes from the edge: the request
without a User-Agent above gets one.
Quote the reference to support
Section titled “Quote the reference to support”The body is the same for every request, so reference does not hold the id itself: it names
the response header that does. Every response carries an x-amz-cf-id header, a unique id for
that request at the edge. Log it with every 403 and 429, and quote it, with the time of the
request (UTC) and the address you sent it from, when you contact support. That is
how STX finds the exact request that was refused.
HTTP/2 429content-type: application/jsonretry-after: 60x-amz-cf-id: 6h1rWj3kPQ0vZb8nC2mX4yT9uLs5eA7dF1gH3jK0lN2oQ4rS6tU8w==
