Skip to navigation

Update Position Exits

View as Markdown

Create or update position exits for an account.

Available to: Traders (own account); organization administrators (any account in their organization)

Environments: Demo, Live

Rate Limit: No endpoint-specific limit

On Live, some organizations restrict administrators from accessing other members’ accounts unless they hold an approved trading permission for that account.

Set when an account’s position in each contract is flattened. Pass the accountId and an items array of 1 to 256 entries, each with a contractId, an optional flattenTimestamp, and an optional repeatInterval. If the account already has a position exit for a contract, it’s replaced with the values you send (omitting flattenTimestamp or repeatInterval clears it); otherwise a new one is created. The response returns the saved position exits in userAccountPositionExits.

If some contracts fail to save, the rest are still saved. The response lists each failed contract in errorText (separated by ;), and userAccountPositionExits holds only the ones that saved.

Common Failure Scenarios

  • The same contractId appears more than once in items. This returns HTTP 200 with "Contracts must be unique" in errorText, and nothing is saved.
  • The account is archived, closed, or restricted, or its type isn’t eligible for position exits. This returns HTTP 200 with "Wrong account state" in errorText.
  • No account matches accountId, or the caller can’t access the account or its owner. All of these return HTTP 404 with an empty body. A trading permission on someone else’s account isn’t enough: a trader can only read their own user record, so the lookup of the account’s owner fails.
  • The caller’s user type, or the API key’s permissions, don’t include full access to the Risks resource. This returns HTTP 401 with "Access is denied".
  • accountId isn’t greater than 0, items is empty or has more than 256 entries, or an item’s contractId or repeatInterval isn’t greater than 0. These return HTTP 400.

This endpoint returns HTTP 200 for both successful and rejected requests, so check the errorText field to confirm the result. Other failures, such as denied access or an invalid request, return their own HTTP status.

Error Messages

MessageResponseTrigger
"Account Id should be greater than 0"400accountId isn’t greater than 0.
"Items should be specified"400items is empty.
"Items should be no longer than 256"400items has more than 256 entries.
"Contract Id should be greater than 0"400An item’s contractId isn’t greater than 0.
"Repeat Interval should be greater than 0"400An item’s repeatInterval is included and isn’t greater than 0.
"Access is denied"401The caller’s user type, or the API key’s permissions, don’t include full access to the Risks resource.
(no message text)404No account matches accountId, or the caller can’t see the account or its owner.
"Contracts must be unique"200 (in errorText)The same contractId appears more than once in items.
"Wrong account state"200 (in errorText)The account is archived, closed, or restricted, or isn’t a customer, house, or employee account.
"Cannot create/update position exit for contract {contractId}"200 (in errorText)Saving the position exit for that contract failed. Several failures are joined with ;.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
accountIdlongRequired
itemslist of objectsRequired

Response

UpdatePositionExitsResponse
userAccountPositionExitslist of objects
errorTextstringOptional<=8192 characters

Non-empty if the request failed