Skip to content

Close a whole position at market (reduce-only)

POST
/v1/api/accounts/{account_id}/positions/{symbol}/close
curl --request POST \
--url https://app.proofperps.com/v1/api/accounts/example/positions/example/close \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: example' \
--data '{ "expected_position_qty": 1 }'
account_id
required
Account Id
string
symbol
required
Symbol
string
Idempotency-Key
required
string
>= 1 characters <= 64 characters

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).

Media typeapplication/json
object
expected_position_qty

Signed; refused 409 when the position is no longer this.

integer format: int64

Example generated

{
"expected_position_qty": 1
}

The same JSON the terminal gets from its route of the same name.

Media typeapplication/json
object

Example generated

{}

VALIDATION_ERROR: a parameter, a header or the body is not as described.

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

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).

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

Example

{
"error": {
"source": "api"
}
}

API_KEY_READ_ONLY: a key of the read scope called an order route.

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

Example

{
"error": {
"source": "api"
}
}

NOT_FOUND: an account that is not yours (exactly like an unknown one), an order, a market.

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

Example

{
"error": {
"source": "api"
}
}

A conflict of state (the position or the order moved since you read it, an order no longer open).

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

Example

{
"error": {
"source": "api"
}
}

A refusal of the rules or of the execution (detail.reason), or IDEMPOTENCY_KEY_REUSED.

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

Example

{
"error": {
"source": "api"
}
}

RATE_LIMITED: wait Retry-After seconds (per key, and per trader for the order routes).

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

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.

Media typeapplication/json
object
error
required
object
code
required
string
detail
required
object
message
required
string
source
required
string
Allowed values: api engine exec
trace_id
required
string

Example

{
"error": {
"source": "api"
}
}