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

# Close position

> Convenience endpoint that sends a reduce-only order against an open position. Requires the `TRADE` permission scope.



## OpenAPI

````yaml POST /account/{account_id}/close-position
openapi: 3.1.0
info:
  title: DojiFunded Trading API
  description: >-
    Public REST interface for algorithmic trading on DojiFunded. Place orders,
    manage positions, and pull account state programmatically.
  version: 1.0.0
  contact:
    email: business@dojifunded.com
servers:
  - url: https://engine.dojifunded.com/v1
    description: Production
security:
  - apiKey: []
    apiSecret: []
tags:
  - name: Accounts
    description: Account state, positions, history, risk, and analytics.
  - name: Orders
    description: Place, cancel, and close orders across all venues.
  - name: Market data
    description: Public price feeds and symbol catalog. No authentication required.
paths:
  /account/{account_id}/close-position:
    post:
      tags:
        - Orders
      summary: Close position
      description: >-
        Convenience endpoint that sends a reduce-only order against an open
        position. Requires the `TRADE` permission scope.
      operationId: closePosition
      parameters:
        - $ref: '#/components/parameters/AccountId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - symbol
              properties:
                symbol:
                  type: string
                  description: Symbol of the position to close.
                  example: BTC-USD
                quantity:
                  type: number
                  description: Partial close quantity. Omit to close the full position.
                kind:
                  type: string
                  enum:
                    - MARKET
                    - LIMIT
                  description: Order type for the closing order. Defaults to `MARKET`.
                price:
                  type: number
                  description: Limit price (required if `kind` is `LIMIT`).
                tif:
                  type: string
                  description: Time-in-force for the closing order.
                client_id:
                  type: string
                  description: Deduplication ID. Safe to retry.
      responses:
        '200':
          description: Order result for the closing order.
          content:
            application/json:
              schema:
                type: object
                properties:
                  order:
                    $ref: '#/components/schemas/Order'
                  trades:
                    type: array
                    items:
                      $ref: '#/components/schemas/Trade'
                  violations:
                    type: array
                    items:
                      $ref: '#/components/schemas/Violation'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    AccountId:
      name: account_id
      in: path
      required: true
      description: UUID of the account. Must be owned by the authenticated user.
      schema:
        type: string
        format: uuid
  schemas:
    Order:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Order UUID.
        status:
          type: string
          description: Current order status.
          example: OPEN
        symbol:
          type: string
          description: Tradable symbol.
        side:
          type: string
          enum:
            - BUY
            - SELL
        kind:
          type: string
          enum:
            - MARKET
            - LIMIT
            - STOP
            - TAKE_PROFIT
        quantity:
          type: number
        price:
          type: number
        client_id:
          type: string
          description: Client-supplied deduplication ID.
    Trade:
      type: object
      properties:
        id:
          type: string
          description: Trade fill ID.
        symbol:
          type: string
        side:
          type: string
          enum:
            - BUY
            - SELL
        quantity:
          type: number
        price:
          type: number
          description: Fill price.
        timestamp:
          type: string
          format: date-time
    Violation:
      type: object
      properties:
        rule:
          type: string
          description: The risk rule that was tripped.
        severity:
          type: string
          description: Violation severity.
        message:
          type: string
          description: Human-readable message.
  responses:
    Unauthorized:
      description: Missing or invalid API credentials.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: unauthorized
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: not_found
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key generated at Dashboard, Settings, Developer. Format:
        `doji_ak_...`
    apiSecret:
      type: apiKey
      in: header
      name: X-API-Secret
      description: 'API secret returned once at key creation. Format: `doji_sk_...`'

````