Skip to content
API status
API reference

Close every open position

POST
/api/v1/management/servers/{serverId}/accounts/{accountNumber}/positions/close-all
curl --request POST \
--url https://api.koneth.com/api/v1/management/servers/6be9a699-2f28-402e-b64e-93ba6bdafe1b/accounts/7001042/positions/close-all \
--header 'Authorization: <Authorization>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: account-create-client-1042' \
--header 'X-Request-Id: onboarding-client-1042' \
--data '{ "side": "ALL", "requestId": "close-all-client-1042" }'

Closes all open positions on an account, or only the BUY or SELL side. Each position closes at its own authoritative quote, and the response result reports how many closed and which positions failed. Requires positions:write.

serverId
required
string format: uuid

UUID of a trading server owned by your organization.

Example
6be9a699-2f28-402e-b64e-93ba6bdafe1b
accountNumber
required
string
>= 4 characters <= 32 characters /^[A-Za-z0-9_-]+$/

Trading account number.

Example
7001042
Idempotency-Key
required
string
>= 1 characters <= 100 characters

Unique key for this logical mutation. Reuse it only when retrying the same operation. Maximum 100 characters.

Example
account-create-client-1042
X-Request-Id
string

Optional correlation ID used for API request billing and logs.

Example
onboarding-client-1042
Media typeapplication/json
object
side
string
default: ALL
Allowed values: ALL BUY SELL
requestId
required
string
>= 1 characters <= 100 characters
Example
{
"side": "ALL",
"requestId": "close-all-client-1042"
}

An earlier command was returned for the idempotency key.

Media typeapplication/json
object
command
required
object
id
required
string format: uuid
operation
required
string
Allowed values: account.create account.update account.enable account.disable account.archive account.password_reset account.investor_password_reset account.history_export finance.deposit finance.withdraw trade.open trade.cancel trade.modify position.close position.modify position.close_all
status
required
string
Allowed values: queued leased succeeded failed expired
managedAccountId
One of:
string format: uuid
attempts
required
integer
payload
object
key
additional properties
any
result
One of:
object
key
additional properties
any
errorCode
One of:
string
errorMessage
One of:
string
idempotencyKey
required
string
createdAt
required
string format: date-time
completedAt
One of:
string format: date-time
key
additional properties
any
duplicate
required
boolean
Example
{
"command": {
"operation": "account.create",
"status": "queued"
}
}

Operation queued.

Media typeapplication/json
object
command
required
object
id
required
string format: uuid
operation
required
string
Allowed values: account.create account.update account.enable account.disable account.archive account.password_reset account.investor_password_reset account.history_export finance.deposit finance.withdraw trade.open trade.cancel trade.modify position.close position.modify position.close_all
status
required
string
Allowed values: queued leased succeeded failed expired
managedAccountId
One of:
string format: uuid
attempts
required
integer
payload
object
key
additional properties
any
result
One of:
object
key
additional properties
any
errorCode
One of:
string
errorMessage
One of:
string
idempotencyKey
required
string
createdAt
required
string format: date-time
completedAt
One of:
string format: date-time
key
additional properties
any
duplicate
required
boolean
Example
{
"command": {
"operation": "account.create",
"status": "queued"
}
}

Invalid request.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Examplegenerated
{
"error": "example",
"issues": [
{}
]
}

Management API authentication is missing or invalid.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Example
{
"error": "Management API authentication required"
}

The organization cannot cover the active API request price.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Example
{
"error": "Insufficient API credits"
}

The key lacks the required scope or server access.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Example
{
"error": "Missing API scope: accounts:read"
}

The requested resource was not found.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Examplegenerated
{
"error": "example",
"issues": [
{}
]
}

The request conflicts with the current resource state.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Examplegenerated
{
"error": "example",
"issues": [
{}
]
}

Unexpected server error.

Media typeapplication/json
object
error
required
string
issues

Validation issue details when the request fails schema validation.

Array<object>
object
key
additional properties
any
Example
{
"error": "Internal server error"
}