> ## 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 all positions on an account

> Closes every open position at market and cancels every working order on one account, immediately. The account keeps its status and is **not** locked out — the trader can trade again straight away; combine with `POST /organization/lockouts` if you also want to stop further trading.

The resulting orders carry reason `Admin flatten: <who> — <your reason>` (trigger `admin_flatten`), and an `ACCOUNT_UPDATED` event with the counts lands on the account's event log.

Requires **manage** permission on traders. If the trading engine cannot be reached the call fails with 502 and nothing is closed.

```bash
curl -X POST "https://api.hyperprop.com/platform/v1/organization/trading-accounts/7c9e6679-7425-40de-944b-e07fc1f90ae7/flatten" \
  -H "X-API-Key: hp_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"reason": "Hedging review"}'
```



## OpenAPI

````yaml /api-reference/openapi.json post /v1/organization/trading-accounts/{accountId}/flatten
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: 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: 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 key.
  - name: Logs and health
    description: API request logs, the audit log, and integration health.
  - 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}/flatten:
    post:
      tags:
        - Trading accounts
      summary: Close all positions on an account
      description: >-
        Closes every open position at market and cancels every working order on
        one account, immediately. The account keeps its status and is **not**
        locked out — the trader can trade again straight away; combine with
        `POST /organization/lockouts` if you also want to stop further trading.


        The resulting orders carry reason `Admin flatten: <who> — <your reason>`
        (trigger `admin_flatten`), and an `ACCOUNT_UPDATED` event with the
        counts lands on the account's event log.


        Requires **manage** permission on traders. If the trading engine cannot
        be reached the call fails with 502 and nothing is closed.


        ```bash

        curl -X POST
        "https://api.hyperprop.com/platform/v1/organization/trading-accounts/7c9e6679-7425-40de-944b-e07fc1f90ae7/flatten"
        \
          -H "X-API-Key: hp_live_your_key_here" \
          -H "Content-Type: application/json" \
          -d '{"reason": "Hedging review"}'
        ```
      operationId: postV1OrganizationTradingaccountsAccountidFlatten
      parameters:
        - x-format:
            guid: true
          name: accountId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Model746'
      responses:
        '200':
          description: Success - Positions closed and orders cancelled
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model748'
        '401':
          description: Authentication required
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model9'
        '403':
          description: >-
            Forbidden - This account belongs to a different organization, or the
            caller lacks traders:manage
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model749'
        '404':
          description: Not Found - No account exists with this ID
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model750'
        '500':
          description: An unexpected error occurred
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model5'
        '502':
          description: The trading engine did not accept the request; nothing was closed
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Model751'
      security:
        - X-API-Key: []
components:
  schemas:
    Model746:
      type: object
      properties:
        reason:
          type: string
          description: >-
            Why the positions are being closed. Recorded on every resulting
            order and on the account's event log.
          example: Hedging review — positions closed pending clarification
          minLength: 3
          maxLength: 200
          x-convert:
            trim: true
      required:
        - reason
    Model748:
      type: object
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/Model747'
    Model9:
      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
    Model749:
      type: object
      properties:
        statusCode:
          type: number
          example: 403
        error:
          type: string
          example: Forbidden
        message:
          type: string
          example: This account does not belong to your organization
        code:
          type: string
          example: ACCOUNT_NOT_IN_ORG
    Model750:
      type: object
      properties:
        statusCode:
          type: number
          example: 404
        error:
          type: string
          example: Not Found
        message:
          type: string
          example: Trading account not found
        code:
          type: string
          example: ACCOUNT_NOT_FOUND
    Model5:
      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
    Model751:
      type: object
      properties:
        statusCode:
          type: number
          example: 502
        error:
          type: string
          example: Bad Gateway
        message:
          type: string
          example: >-
            The trading engine did not accept the flatten request; nothing was
            closed
        code:
          type: string
          example: ENGINE_UNAVAILABLE
    Model747:
      type: object
      properties:
        accountId:
          type: string
          x-format:
            guid: true
        accountNumber:
          type: string
          example: ACME-50K-000123
        ordersCancelled:
          type: number
          example: 1
        positionsClosed:
          type: number
          example: 1
        reason:
          type: string
          example: 'Admin flatten: ops@firm.com — Hedging review'
  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 open positions for an account](/trade-api/positions/close-all-open-positions-for-an-account.md)
- [Flatten account: close positions and cancel orders](/trade-api/positions/flatten-account:-close-positions-and-cancel-orders.md)
- [Cancel all pending orders for an account (keeps live position protection)](/trade-api/orders/cancel-all-pending-orders-for-an-account-keeps-live-position-protection.md)
- [Close a specific position by contract](/trade-api/positions/close-a-specific-position-by-contract.md)
- [Create or update account lockout](/trade-api/account/create-or-update-account-lockout.md)


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