401 errors on the Liquidate API only

Hello,

I’ve been using the Tradovate API and I’m experiencing an issue with 401s on the liquidate position api. For example..

Unauthorized for url: https://demo.tradovateapi.com/v1/order/liquidateposition

I don’t believe it’s an expired token issue because the login is successful, I make a few api calls for accounts, orders, positions, but when I try to liquidate I get a 401.

No other endpoints are causing issues.

My request in python looks like:

My token permissions are:

Any idea what could be causing the issue?

Thanks.

You are missing “positions”:

You can get it from: position/list

2 Likes

Trying setting “admin” to False. It is not the same property as “isAutomated”.

Hi Frik,

I’m using the liquidatePosition api, not liquidatePositions api

The former takes an accountId and contractId, not a list of positions.

Cool. Then the contract ID might be wrong. Where do you get the contract ID?

I did a quick test and if I set admin: true, then I get the same 401 error. Setting admin: false resolves the issue for me.

The issue is that even though it works, it never returns an orderId… so you cannot track the filled price to update the profit on the trade without extra effort.

PositionLog / fillPair will allow you to reconcile the profits based on the contractId

a[{"e":"props","d":{"entityType":"positionLog","eventType":"Created","entity":{"id":217455664051,"accountId":10702815,"contractId":3819017,"timestamp":"2025-05-05T10:46:17.909Z","tradeDate":{"year":2025,"month":5,"day":5},"netPos":0,"bought":3,"boughtValue":16988.75,"sold":3,"soldValue":16988.25,"archived":false,"positionChangeType":"Trade","fillId":217455664045}}},{"e":"props","d":{"entityType":"fillPair","eventType":"Created","entity":{"id":217455664050,"positionId":217455663932,"buyFillId":217455664045,"sellFillId":217455664022,"qty":1,"buyPrice":5662.0,"sellPrice":5661.25,"active":true,"archived":false}}}]

BTW: executionReport seems like a better way to track the close price for profit calculations