# API Order Failures

**URL:** <https://community.tradovate.com/t/api-order-failures/4098>\
**Category:** Community Support\
**Created:** [March 1, 2022, 4:44pm UTC](https://community.tradovate.com/t/api-order-failures/4098 "2022-03-01T16:44:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 1, 2022, 4:44pm UTC](https://community.tradovate.com/t/api-order-failures/4098/1 "2022-03-01T16:44:35Z")

</div>

Hi @Alexander

We are seeing a bunch of API failures when placing orders – please see a sample below – there’s no specific pattern observed since this is happening at irregular intervals and it’s happening on all actions - create / modify / delete. Could you help understand the cause of this?

Endpoint: [https://demo.tradovateapi.com/v1/order/placeoso](https://demo.tradovateapi.com/v1/order/placeoso)

Request (sensitive fields masked):  
{  
“accountSpec”: “**",  
“accountId”: ,  
“clOrdId”: "",  
“action”: “Buy”,  
“symbol”: “ESH2”,  
“orderQty”: 2,  
“orderType”: “Stop”,  
“timeInForce”: “GTC”,  
“isAutomated”: true,  
“stopPrice”: 4284.0,  
“bracket1”: {  
“action”: “Sell”,  
“clOrdId”: "**”,  
“orderType”: “Limit”,  
“timeInForce”: “GTC”,  
“price”: 5300.0  
},  
“bracket2”: {  
“action”: “Sell”,  
“clOrdId”: “\*\*\*\*”,  
“orderType”: “Stop”,  
“timeInForce”: “GTC”,  
“stopPrice”: 4000.0  
}  
}

Response:  
HTTP 408 – Request Timeout – Request Timeout, error id: 504c553f-5633-4bcf-be01-0adfbd3472f0

Sometimes we also see HTTP return code 401 (expired access token) – however, there are successful placeorder API calls seen few milliseconds before and after the failure using the same token – couldn’t explain the cause – please advise.

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 1, 2022, 4:51pm UTC](https://community.tradovate.com/t/api-order-failures/4098/2 "2022-03-01T16:51:15Z")

</div>

I think that both these responses and the 200’s with UnknownReason failure text from your other post are related. I’m looking into this right now.

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 1, 2022, 7:02pm UTC](https://community.tradovate.com/t/api-order-failures/4098/3 "2022-03-01T19:02:15Z")

</div>

Can you provide a timestamp for these calls, or reproduce them and acquire timestamps? Even just one call would help us do some research.

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 1, 2022, 7:31pm UTC](https://community.tradovate.com/t/api-order-failures/4098/4 "2022-03-01T19:31:38Z")

</div>

Sure. These are New York Time.

2022-03-01T12:48:34.063-05:00 401 – Unauthorized – Access is denied   
2022-03-01T13:01:20.159-05:00 408 – Request Timeout error id: 1b812801-15f5-454c-99f5-60f4afea97a2

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 1, 2022, 7:34pm UTC](https://community.tradovate.com/t/api-order-failures/4098/5 "2022-03-01T19:34:05Z")

</div>

> [@fin1](#):
>
> 2022-03-01T13:01:20.159-05:00  
> 2022-03-01T12:48:34.063-05:00

Are these for the same error ID or new error IDs?

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 1, 2022, 7:38pm UTC](https://community.tradovate.com/t/api-order-failures/4098/6 "2022-03-01T19:38:06Z")

</div>

Sorry, our messages crossed. Different. I updated the message above with the error content.

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 1, 2022, 7:44pm UTC](https://community.tradovate.com/t/api-order-failures/4098/7 "2022-03-01T19:44:45Z")

</div>

Here are a few more with additional context.

2022-03-01T13:05:03.723-05:00 POST for order id RTYH21020D – 408 – Request Timeout – Request Timeout, error id: 26c01b3f-5e4e-44ab-9118-f8c2425d5351 2022/03/01/[$LATEST]ccfa7c06132d4da9ace9139b153978d9

2022-03-01T13:05:05.120-05:00 POST for order id YMH21032m30 – 408 – Request Timeout – Request Timeout, error id: 632adcf6-27df-4a9f-94f1-18c2d9e83363 2022/03/01/[$LATEST]ccfa7c06132d4da9ace9139b153978d9

2022-03-01T12:48:34.063-05:00 DELETE for order id RTYH21034m30 – 401 – Unauthorized – Access is denied 2022/03/01/[$LATEST]6d1581c6c7064056a2e0cc235965e73c

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 2, 2022, 1:14pm UTC](https://community.tradovate.com/t/api-order-failures/4098/8 "2022-03-02T13:14:17Z")

</div>

The 408 errors - apparently this means you’ve exceeded the maximum number of concurrent connections for your user. The max connections is 1 or 2 for a retail user - 1 if you are using a standard subscription, 2 if you pay for a subscription to Dual Connections (available in Application Settings → Subscriptions). I’d suggest looking at the execution of your restart process, see if maybe you try to log on while you’re already logged on. You can always call `/auth/renewAccessToken` to reset your token’s expiry.

At least the first 401 error you sent me ended up being an attempt to cancel an order that had been completed an archived the previous day. So in that case, look at how you get the data for a request to cancel an order. You can check an order’s execution status using it’s `ordStatus` field.

Hope that helps you find some answers @fin1!

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 2, 2022, 2:40pm UTC](https://community.tradovate.com/t/api-order-failures/4098/9 "2022-03-02T14:40:20Z")

</div>

Thanks @Alexander , as always. I’ll review and be in touch.

Question for now regarding the max number of connections … If I’m logged in at [https://trader.tradovate.com/](https://trader.tradovate.com/) or the mobile app and then api, does that count as two connections or should the api connection still work? I see api orders still being placed when I’m logged in but of course we have the 408 errors every so often. I also see that I’m forcibly logged out from the web occasionally when several api orders are being placed together. I have the standard subscription.

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 2, 2022, 3:11pm UTC](https://community.tradovate.com/t/api-order-failures/4098/10 "2022-03-02T15:11:45Z")

</div>

To watch the Trader UI and use an app with your API key takes up both of your connections, if you have purchased Dual Subscriptions. Logging into Trader UI while running an app with only one max concurrent connection will result in the app’s connection being dropped and vice versa.

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 2, 2022, 3:47pm UTC](https://community.tradovate.com/t/api-order-failures/4098/11 "2022-03-02T15:47:53Z")

</div>

Thanks @Alexander

I just purchased dual subscription.

I have a api app and a websocket app. Would they count as two connections by themselves? Thank you!

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 2, 2022, 4:23pm UTC](https://community.tradovate.com/t/api-order-failures/4098/12 "2022-03-02T16:23:48Z")

</div>

You could use just one app for both HTTP API and WebSocket API. They can be used interchangeably/situationally. But if you actually ran two apps with different API Keys, yes it would count as two connections.

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 2, 2022, 5:16pm UTC](https://community.tradovate.com/t/api-order-failures/4098/13 "2022-03-02T17:16:15Z")

</div>

Thanks @Alexander . That helps.  
Just to confirm … Would using the same API key but two different tokens (one for REST API app and the other for Websocket app - I have different apps) count as two connections?

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 2, 2022, 5:42pm UTC](https://community.tradovate.com/t/api-order-failures/4098/14 "2022-03-02T17:42:13Z")

</div>

Can they communicate? You could probably reuse the token if they can. But if not, yes it would count as two connections.

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 9, 2022, 8:23pm UTC](https://community.tradovate.com/t/api-order-failures/4098/15 "2022-03-09T20:23:15Z")

</div>

Hi @Alexander ,

We have made changes so we are using only one token now but we still see 408s and 401s. We are using the one token between two apps (api and websocket).

Appreciate if you could provide some guidance.

Thanks as always!

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 9, 2022, 9:12pm UTC](https://community.tradovate.com/t/api-order-failures/4098/16 "2022-03-09T21:12:08Z")

</div>

Is there any point at which you attempt to get a new key or possibly store an old key? Is there any kind of consistency to the time that these errors occur?

---

<div class="post-metadata">

**Author:** ![Arthur](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Arthur](https://community.tradovate.com/u/Arthur)\
**Post date:** [March 9, 2022, 10:16pm UTC](https://community.tradovate.com/t/api-order-failures/4098/17 "2022-03-09T22:16:09Z")

</div>

Hi @fin1, chiming in to your query here. Do you know when you are getting the 401s? If it is happening around the 80 minute mark, it is definitely a renew access token issue.

After the token expires, it will no longer work for any REST orders until you renew it. If you received a successful response only milliseconds after getting the 401, I would assume that is just an asynchronous event that got back to you late.

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 14, 2022, 2:19am UTC](https://community.tradovate.com/t/api-order-failures/4098/18 "2022-03-14T02:19:54Z")

</div>

Hi @Alexander

We have been testing further and made some changes but we still have the same issue for some reason. Please see the explanation and follow-up questions below.

We have confirmed the app is using only one token and during this time the Trader App Web UI is also being used. We assume this means we are using 2 active connections. We thought we shouldn’t be seeing any more 401s and 408s since we have purchased two connections. However, we continue to see 401s and 408s just as before.

We are also using mdAccessToken for subscribing to market data (md/subscribeQuote) when ‘accessToken’ is being used for place order APIs and “user/syncrequest” websocket endpoint. Does this cause any issue?

Could you please advise possible next steps? In order to help you troubleshoot this further, the log events along with timestamps associated with this issue are provided below. We hope this helps to correlate events on your side.

Thanks!  
Note : yPGTq\*\*\*\*\*\*\*\*\*\* is the active token at that time and it’s the only token active in the system used by all scaled instances (potentially multiple IP addresses in AWS where our app is deployed).  
………….

[All times in ET time zone] 2022-03-13T20:00:09.648-04:00 getToken()::obtained token from auth api \>\> yPGTqWgWh1\*\*\*\*\*\*\*\*

2022-03-13T20:00:10.473-04:00. !!!Retrying because of this response – Response:: PATCH for order id ZWK21003H4 – 401 – Unauthorized – Access is denied

> > Getting token again (Retry) 2022-03-13T20:00:10.482-04:00 getToken()::obtained token from auth api \>\> yPGTqWgWh1\*\*\*\*\*\*\*\*\*\*\*\*\*

(Retry failed) 2022-03-13T20:00:10.514-04:00 RAW response:: MODIFY/PATCH order for order id ZWK21003H4 – \<Response [401]\>

---

<div class="post-metadata">

**Author:** ![Alexander](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/alexander/32/988_2.png) [@Alexander](https://community.tradovate.com/u/Alexander)\
**Post date:** [March 14, 2022, 12:30pm UTC](https://community.tradovate.com/t/api-order-failures/4098/19 "2022-03-14T12:30:51Z")

</div>

That `mdAccessToken` is really only there for backwards compatibility with the Trader application. For all regular API users, you should use `accessToken`. The `mdAccessToken` can be safely ignored. Looking into AWS IP handling may be worthwhile.

Also, I noticed you’re only documenting a 401 here. Are you still getting the 408s too, or just the 401s now?

---

<div class="post-metadata">

**Author:** ![fin1](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@fin1](https://community.tradovate.com/u/fin1)\
**Post date:** [March 14, 2022, 8:22pm UTC](https://community.tradovate.com/t/api-order-failures/4098/20 "2022-03-14T20:22:38Z")

</div>

Thanks @Alexander !

We have more 408s than 401s. For example, there were 38 occurrences of 408 error and 1 occurrence of 401 between 3/13 9pm - 3/14 9am ET – last occurrence in this time span was at 2022-03-14T07:21:10.431-04:00 – all times in ET

We also had 21 occurrences of 1006 error during this time (screenshot attached).

We didn’t use the Trader app at all during this time so there were two connections for the api to use. At no point during this time, we were using more than one token for the api.

We have pretty much run out of ideas at this time. Appreciate if you could help troubleshoot/resolve this based on what you see at the Tradovate end. Thank you!

 ![image (1)](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/c/cecf87600f88f8365d47a4bedd90d5f60dbfcbfb.png)

[Next page](https://community.tradovate.com/t/api-order-failures/4098.md?page=2)
