> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperprop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Close one position on an account

> Closes one open position at market, wholly or in part, with the organization API key. The account keeps its status and is not locked out.

- **Whole position** (no `quantity`, or the full open size): the contract's working orders on the account are cancelled, the position is closed at market, and its take-profit and stop-loss orders are cancelled after the fill. This is what `POST .../flatten` does, for this one contract. Orders on other contracts are untouched.
- **Part of it** (`quantity` below the open size): a reduce-only market order for `quantity`. Working orders stay; take-profit and stop-loss orders keep protecting what remains.

The close is an ordinary market order: it fills at the market price with the usual commissions, updates balance and rules like any close, and appears on the real-time stream (`OrderUpdate`, `Fill`, `PositionUpdate`, `AccountUpdate`) and in order history with reason `Admin flatten: <who> — <your reason>` (trigger `admin_flatten`). An `ACCOUNT_UPDATED` event (trigger `admin_position_close`) lands on the account's event log and goes to `account.updated` webhooks.

It is refused with **409 MARKET_CLOSED** while the contract's market is closed (for example during the daily break, at the weekend or on a holiday); nothing is closed.

**Retries:** send an `Idempotency-Key` header to make retries safe; a retry with the same key returns the first answer and never closes twice. A whole-position close repeated without a key answers 404 NO_POSITION once the position is gone. On **504 CLOSE_OUTCOME_UNKNOWN** read the positions before retrying a partial close.

Requires **manage** permission on traders.

```bash
curl -X POST "https://api.hyperprop.com/platform/v1/organization/trading-accounts/7c9e6679-7425-40de-944b-e07fc1f90ae7/positions/MNQZ6/close" \
  -H "X-API-Key: hp_live_your_key_here" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: close-7c9e6679-mnqz6-001" \
  -d '{"reason": "Risk review", "quantity": 1}'
```



## OpenAPI

````yaml https://api.hyperprop.com/platform/openapi.json post /v1/organization/trading-accounts/{accountId}/positions/{contract}/close
openapi: 3.0.0
info:
  title: Hyperprop Platform API
  version: 1.0.0
  description: >-
    REST API for the Hyperprop Trading Platform — provision evaluation and
    funded trading accounts, manage traders and plans, react to account
    lifecycle events via signed webhooks, and reconcile billing. Built for prop
    firms integrating from their own backend.


    Authentication, quick start, error handling, idempotency, pagination, custom
    metadata, webhooks, and the MCP connector are documented at
    https://docs.hyperprop.com.
  x-logo:
    url: https://app.hyperprop.com/logo-icon.svg
    altText: Hyperprop
    href: https://hyperprop.com
servers:
  - url: https://api.hyperprop.com/platform
    description: Production
security: []
tags:
  - name: Trading accounts
    description: Create, update, and inspect trading accounts.
  - name: Traders
    description: Look up and update the traders in your organization.
  - name: Trading plans
    description: Define the plans you sell.
  - name: Trading rules
    description: Define how accounts are evaluated.
  - name: Instruments
    description: >-
      The contracts your organization's accounts can trade, with their
      specifications.
  - name: Lockouts
    description: Pause and resume trading on an account.
  - name: Payouts
    description: Check payout eligibility and record payouts.
  - name: Purchases
    description: Purchases recorded for your organization.
  - name: Time Machine
    description: Restore accounts to an earlier trading day or instant.
  - name: Mass credit
    description: >-
      Credit back losses across many accounts after an incident, as background
      jobs you can follow, pause, export and reverse.
  - name: Webhooks
    description: Register webhook endpoints and inspect deliveries.
  - name: Events
    description: Your organization's event history and real-time event stream.
  - name: Reconciliation
    description: Balances, end-of-day snapshots, and fills for reconciliation.
  - name: Analytics
    description: Organization performance and plan economics.
  - name: Billing
    description: 'Your Hyperprop bill: activity, billing cycles, and forecasts.'
  - name: Team and roles
    description: Manage dashboard access for your staff.
  - name: API keys
    description: >-
      Manage your organization's API keys: rotation, read-only keys and IP
      allowlists.
  - name: Logs and health
    description: >-
      API request logs, the audit log, integration health, and idempotency key
      recovery.
  - name: Organization profile
    description: Your organization's profile and logo.
  - name: Support
    description: Open and follow up on support tickets.
  - name: Partner access
    description: >-
      Read a trader's journal as an approved partner app, with the trader's own
      key.
paths:
  /v1/organization/trading-accounts/{accountId}/positions/{contract}/close:
    post:
      tags:
        - Trading accounts
      summary: Close one position on an account
      description: >-
        Closes one open position at market, wholly or in part, with the
        organization API key. The account keeps its status and is not locked
        out.


        - **Whole position** (no `quantity`, or the full open size): the
        contract's working orders on the account are cancelled, the position is
        closed at market, and its take-profit and stop-loss orders are cancelled
        after the fill. This is what `POST .../flatten` does, for this one
        contract. Orders on other contracts are untouched.

        - **Part of it** (`quantity` below the open size): a reduce-only market
        order for `quantity`. Working orders stay; take-profit and stop-loss
        orders keep protecting what remains.


        The close is an ordinary market order: it fills at the market price with
        the usual commissions, updates balance and rules like any close, and
        appears on the real-time stream (`OrderUpdate`, `Fill`,
        `PositionUpdate`, `AccountUpdate`) and in order history with reason
        `Admin flatten: <who> — <your reason>` (trigger `admin_flatten`). An
        `ACCOUNT_UPDATED` event (trigger `admin_position_close`) lands on the
        account's event log and goes to `account.updated` webhooks.


        It is refused with **409 MARKET_CLOSED** while the contract's market is
        closed (for example during the daily break, at the weekend or on a
        holiday); nothing is closed.


        **Retries:** send an `Idempotency-Key` header to make retries safe; a
        retry with the same key returns the first answer and never closes twice.
        A whole-position close repeated without a key answers 404 NO_POSITION
        once the position is gone. On **504 CLOSE_OUTCOME_UNKNOWN** read the
        positions before retrying a partial close.


        Requires **manage** permission on traders.


        ```bash

        curl -X POST
        "https://api.hyperprop.com/platform/v1/organization/trading-accounts/7c9e6679-7425-40de-944b-e07fc1f90ae7/positions/MNQZ6/close"
        \
          -H "X-API-Key: hp_live_your_key_here" \
          -H "Content-Type: application/json" \
          -H "Idempotency-Key: close-7c9e6679-mnqz6-001" \
          -d '{"reason": "Risk review", "quantity": 1}'
        ```
      operationId: postV1OrganizationTradingaccountsAccountidPositionsContractClose
      parameters:
        - description: Trading account ID
          x-format:
            guid: true
          name: accountId
          in: path
          required: true
          schema:
            type: string
        - description: >-
            Contract symbol of the open position, as on the positions read and
            the real-time stream
          name: contract
          in: path
          required: true
          schema:
            type: string
            pattern: ^[A-Za-z0-9._-]{1,40}$
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Model1481'
      responses:
        '200':
          description: Position closed (wholly or in part)
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1487'
        '400':
          description: >-
            Bad Request - Invalid parameter (`VALIDATION_ERROR`) or `quantity`
            above the open size (`QUANTITY_EXCEEDS_POSITION`)
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1489'
        '401':
          description: Authentication required
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model11'
        '403':
          description: >-
            Forbidden - The caller lacks traders:manage
            (`INSUFFICIENT_PERMISSIONS`)
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1490'
        '404':
          description: >-
            Not Found - No account with this ID in your organization
            (`ACCOUNT_NOT_FOUND`) or no open position in the contract
            (`NO_POSITION`)
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1492'
        '409':
          description: >-
            Conflict - The contract's market is closed (`MARKET_CLOSED`), the
            engine refused the closing order (`CLOSE_REJECTED`), or a request
            with this `Idempotency-Key` is still in progress. The position is
            still open.
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1493'
        '500':
          description: An unexpected error occurred
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model6'
        '502':
          description: The trading engine could not be reached; nothing was closed
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1494'
        '504':
          description: >-
            The trading engine did not answer in time; the position may or may
            not have been closed. Read the account's positions before retrying.
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model1495'
      security:
        - X-API-Key: []
components:
  schemas:
    Model1481:
      type: object
      properties:
        reason:
          type: string
          description: >-
            Why the position is being closed. Recorded on the resulting orders
            and on the account's event log.
          example: Risk review
          minLength: 3
          maxLength: 200
          x-convert:
            trim: true
        quantity:
          type: integer
          description: >-
            How much to close, in the position's units (futures: contracts;
            perpetuals: units of the contract's `quantityStep`, as `quantity` on
            the positions read). Omit to close the whole position.
          example: 1
          minimum: 1
          maximum: 4294967295
      required:
        - reason
    Model1487:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Model1486'
    Model1489:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: number
          example: 400
        error:
          type: string
          example: Bad Request
        message:
          type: string
          example: 'Cannot close 3 of MNQZ6: only 2 is open'
        code:
          $ref: '#/components/schemas/Model1488'
    Model11:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 401
        error:
          type: string
          example: Unauthorized
        message:
          type: string
          example: Authentication required
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: UNAUTHORIZED
    Model1490:
      type: object
      properties:
        statusCode:
          type: number
          example: 403
        error:
          type: string
          example: Forbidden
        message:
          type: string
          example: Your role does not have write access to "Traders & accounts"
        code:
          $ref: '#/components/schemas/code'
    Model1492:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: number
          example: 404
        error:
          type: string
          example: Not Found
        message:
          type: string
          example: No open position in MNQZ6
        code:
          $ref: '#/components/schemas/Model1491'
    Model1493:
      type: object
      properties:
        success:
          type: boolean
          example: false
        statusCode:
          type: number
          example: 409
        error:
          type: string
          example: Conflict
        message:
          type: string
          example: Market is closed. Trading resumes at session open.
        code:
          type: string
          example: MARKET_CLOSED
    Model6:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 500
        error:
          type: string
          example: Internal Server Error
        message:
          type: string
          example: An unexpected error occurred
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: INTERNAL_ERROR
    Model1494:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 502
        error:
          type: string
          example: Error
        message:
          type: string
          example: The trading engine could not be reached; nothing was closed
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: ENGINE_UNAVAILABLE
    Model1495:
      type: object
      properties:
        success:
          type: boolean
          description: Always false on errors
          example: false
        statusCode:
          type: number
          example: 504
        error:
          type: string
          example: Error
        message:
          type: string
          example: >-
            The trading engine did not answer in time; the position may or may
            not have been closed. Read the account's positions before retrying.
        code:
          type: string
          description: Machine-readable error code — switch on this, not on message text
          example: CLOSE_OUTCOME_UNKNOWN
    Model1486:
      type: object
      properties:
        accountId:
          type: string
          example: 7c9e6679-7425-40de-944b-e07fc1f90ae7
          x-format:
            guid: true
        accountNumber:
          type: string
          example: ACC-50K-000123
        contract:
          type: string
          example: MNQZ6
        side:
          $ref: '#/components/schemas/Model1482'
        requestedQuantity:
          type: integer
          description: Quantity sent to close
          example: 1
        remainingQuantity:
          type: integer
          description: Open size left on the contract after the close; 0 when closed
          example: 1
        closed:
          type: boolean
          description: True when no position is left on the contract
          example: false
        ordersCancelled:
          type: integer
          description: >-
            Working orders cancelled with a whole-position close (entries,
            take-profit and stop-loss); 0 for a partial close
          example: 0
        orders:
          $ref: '#/components/schemas/Model1485'
        reason:
          type: string
          example: 'Admin flatten: API key — Risk review'
    Model1488:
      type: string
      example: QUANTITY_EXCEEDS_POSITION
      enum:
        - VALIDATION_ERROR
        - QUANTITY_EXCEEDS_POSITION
    code:
      type: string
      example: INSUFFICIENT_PERMISSIONS
      enum:
        - INSUFFICIENT_PERMISSIONS
    Model1491:
      type: string
      example: NO_POSITION
      enum:
        - ACCOUNT_NOT_FOUND
        - NO_POSITION
    Model1482:
      type: string
      description: Direction of the position before the close
      example: long
      enum:
        - long
        - short
    Model1485:
      type: array
      description: The closing order(s), with their fill
      items:
        $ref: '#/components/schemas/Model1484'
    Model1484:
      type: object
      properties:
        orderId:
          type: string
          x-format:
            guid: true
        contract:
          type: string
          example: MNQZ6
        side:
          $ref: '#/components/schemas/Model1483'
        type:
          type: string
          example: market
        quantity:
          type: integer
          example: 1
        filledQuantity:
          type: integer
          example: 1
        status:
          type: string
          description: >-
            `filled` when the close executed; `rejected` with `rejectReason`
            otherwise
          example: filled
        avgFillPrice:
          type: number
          example: 20010.5
        filledAt:
          type: string
          example: '2026-10-30T14:41:07.312Z'
        rejectReason:
          type: string
          example: null
        reason:
          type: string
          example: 'Admin flatten: API key — Risk review'
    Model1483:
      type: string
      example: sell
      enum:
        - buy
        - sell
  securitySchemes:
    X-API-Key:
      type: apiKey
      name: X-API-Key
      in: header
      description: >-
        Organization API key. Format: "hp_live_{key}". Organization admins
        manage the key in the dashboard.

````

## Related topics

- [Close all positions on an account](https://docs.hyperprop.com/platform-api/trading-accounts/close-all-positions-on-an-account.md)
- [Close all positions across accounts](https://docs.hyperprop.com/platform-api/trading-accounts/close-all-positions-across-accounts.md)
- [Close all open positions for an account](https://docs.hyperprop.com/trade-api/positions/close-all-open-positions-for-an-account.md)
- [Flatten account: close positions and cancel orders](https://docs.hyperprop.com/trade-api/positions/flatten-account:-close-positions-and-cancel-orders.md)
- [Set TP/SL at the position level for one (account, contract) pair.](https://docs.hyperprop.com/trade-api/positions/set-tpsl-at-the-position-level-for-one-account-contract-pair.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.