OUTCOME · Create or advance
What changes
Creates or advances only the position resource described by this contract after authorization, validation, policy, and idempotency gates pass.
v2Markets and execution
/api/v2/positions/{market_id}/closuresPURPOSE + BUSINESS CONTEXT
WHEN THIS CALL IS USEFUL
Call this when a market-data, trading, risk, or reconciliation client needs to apply the documented position transition after re-reading the current authoritative state so it can understand market, order, trade, position, or collateral state without confusing a read model with execution authority.
OUTCOME · Create or advance
Creates or advances only the position resource described by this contract after authorization, validation, policy, and idempotency gates pass.
WHY IT MATTERS
ISOLATION + AUTHORITY
The authenticated owner, market, order, position, matching, risk, publisher, and settlement boundaries remain distinct. Documentation, contract visibility, and read access grant no execution authority; possession of a write scope still cannot bypass market status, risk, admission, allowlist, suspension, matching, publisher, or settlement gates. Current trading, matching, prediction, ingress, publisher, allowlist, suspension, market-status, and traffic controls remain frozen unless separately approved through their controlling process.
BEFORE YOU CALL
WHAT TO DO NEXT
AGENT GUIDANCE
The stable V2 contract does not imply NXG authority. Legacy Python remains the authoritative order path while NXG is observational; shadow evidence cannot enable ingress, publishing, allowlists, or unsuspend a market. The source-ready successor path reserves collateral in Core before submission, retains ambiguous in-doubt holds for an idempotent retry, atomically swaps replacement reservations, and commits fill settlement with terminal release. These controls are not a production or authority claim. Promotion requires separate market-scoped authority and traffic approvals after collateral, settlement, reconciliation, rollback, and emergency re-suspension evidence passes.
The exact deployed parameters, schemas, responses, security requirements, and Hybrid-Chain agent metadata are authoritative at this operation's production OpenAPI JSON Pointer. The readable tables below add integration guidance; the deployed OpenAPI controls if guidance and the machine contract ever differ.
Open the authoritative production contract ↗EXTENDED INTEGRATION GUIDANCE
Examples illustrate integration intent; the referenced OpenAPI operation and component schemas define the executable shape.
PARAMETERS
AuthorizationheaderRequiredBearer tokenCredential containing the trading:write scope.EXAMPLEBearer hc_live_…
Idempotency-KeyheaderRequiredASCII string · 1–128Caller-generated key reused for every retry of the same logical mutation.EXAMPLElaunch-treasury-v1-001
market_idpathRequireduppercase hyphen-separated identifier · 3–64 charactersCanonical base, quote, and optional instrument identifier. Lowercase, underscore, repeated-hyphen, and slash aliases are rejected.EXAMPLEBTC-USD-PERP
venuebodyOptionaldex | securities | virtualVenue containing the position; defaults to dex.
quantitybodyOptionalpositive decimal stringQuantity to close; omitted closes the complete live position.
reporting_identifierbodyOptionalstring · max 255Optional sub-client or regulatory attribution.
external_referencebodyRequiredstring · 1–255Caller-stable business reference.
REQUEST
{
"venue": "securities",
"quantity": "0.25",
"reporting_identifier": "sub-client-7",
"external_reference": "close-20260814-001"
}RESPONSES
{
"order_id": "order-close-1234",
"market_id": "BTC-USD-PERP",
"status": "ACCEPTED",
"side": "SELL",
"quantity": "0.25",
"reduce_only": true
}{
"code": "invalid_json",
"message": "The JSON body or Idempotency-Key header is malformed."
}invalid_json{
"code": "invalid_credentials",
"message": "The bearer credential is missing, expired, or invalid."
}invalid_credentials{
"code": "insufficient_scope",
"message": "The credential lacks trading:write authority."
}insufficient_scope{
"code": "order_not_found",
"message": "The owner-scoped order, trade, position, or market does not exist in the selected venue."
}order_not_found{
"code": "insufficient_collateral",
"message": "Core could not reserve the replacement or closure requirement before submission; the existing order remains unchanged."
}insufficient_collateral{
"code": "order_conflict",
"message": "The idempotency key or authoritative lifecycle state conflicts with the request."
}order_conflict{
"code": "order_rejected",
"message": "The canonical mutation or authoritative matching implementation rejected the request."
}order_rejected{
"code": "matching_unavailable",
"message": "Core or the current authoritative matching implementation is unavailable."
}matching_unavailableOPERATIONAL NOTES
This route is implemented in canonical gateway source and appears in the production OpenAPI snapshot observed 2026-09-11T06:35:11.572Z. Authentication, tenant, feature, venue, and market policy still apply.
Verify the exact production OpenAPI operation ↗Return to the V2 directory ↗