Set, replace or remove the stop loss and take profit of a position
const url = 'https://app.proofperps.com/v1/api/accounts/example/positions/example/brackets';const options = { method: 'PUT', headers: { 'Idempotency-Key': 'example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"expected_position_qty":1,"expected_stop_loss":1,"stop_loss":1,"stop_loss_trail":1,"take_profit":1,"take_profits":[{"price":1,"share":1}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://app.proofperps.com/v1/api/accounts/example/positions/example/brackets \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: example' \ --data '{ "expected_position_qty": 1, "expected_stop_loss": 1, "stop_loss": 1, "stop_loss_trail": 1, "take_profit": 1, "take_profits": [ { "price": 1, "share": 1 } ] }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”1 to 64 printable ASCII characters. The same key and body give the stored answer again (replayed: true) and do nothing; another body under the same key is a 422 IDEMPOTENCY_KEY_REUSED. For a new order it is its client_order_id (letters, digits and . _ : - only).
Request Bodyrequired
Section titled “Request Bodyrequired”object
Take-profit targets in place of take_profit: each {price, share}, the shares whole percents of at least 1 summing to 100 (for a position’s brackets, no share moves the targets).
object
Example generated
{ "expected_position_qty": 1, "expected_stop_loss": 1, "stop_loss": 1, "stop_loss_trail": 1, "take_profit": 1, "take_profits": [ { "price": 1, "share": 1 } ]}Responses
Section titled “Responses”The same JSON the terminal gets from its route of the same name.
object
Example generated
{}VALIDATION_ERROR: a parameter, a header or the body is not as described.
object
object
object
Example
{ "error": { "source": "api" }}API_KEY_INVALID: the key is missing, malformed, unknown or revoked (detail.reason CONTRACT_WALLET_REVOKED: the contract wallet that made it no longer accepts its sign-in; the key is revoked).
object
object
object
Example
{ "error": { "source": "api" }}API_KEY_READ_ONLY: a key of the read scope called an order route.
object
object
object
Example
{ "error": { "source": "api" }}NOT_FOUND: an account that is not yours (exactly like an unknown one), an order, a market.
object
object
object
Example
{ "error": { "source": "api" }}A conflict of state (the position or the order moved since you read it, an order no longer open).
object
object
object
Example
{ "error": { "source": "api" }}A refusal of the rules or of the execution (detail.reason), or IDEMPOTENCY_KEY_REUSED.
object
object
object
Example
{ "error": { "source": "api" }}RATE_LIMITED: wait Retry-After seconds (per key, and per trader for the order routes).
object
object
object
Example
{ "error": { "source": "api" }}API_DISABLED, API_TRADING_DISABLED, ORDERS_BLOCKED, STORAGE_UNAVAILABLE or SIWE_RPC_UNAVAILABLE (the node of the contract wallet that made the key cannot answer): nothing was done, try later.
object
object
object
Example
{ "error": { "source": "api" }}