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

# Close position

> Automatic full or partial close of an authorized position.

Send `login` and optionally `volume` and `comment`. Omit volume for a full close;
`5000` requests 0.5 lots. The API resolves symbol, direction, price and precision.
Keep one `Idempotency-Key` per intent and confirm execution.
See [the complete guide](https://api-trading-docs.ap-markets.com/trading/close.md).

See [Volume: lots and MT5 units](https://api-trading-docs.ap-markets.com/trading/volume.md) for conversions and each endpoint’s volume fields.


## OpenAPI

````yaml openapi.json POST /api/v1/positions/{position}/close
openapi: 3.1.0
info:
  title: AP Markets API — Partner Portal
  description: >-
    Secure endpoints for account ownership verification, market data, and
    trading on previously verified accounts.
  version: 0.1.0
servers:
  - url: https://api-trading.ap-markets.com
    description: AP Markets API
security: []
paths:
  /api/v1/positions/{position}/close:
    post:
      tags:
        - Trading
      summary: Close an open position
      description: >-
        Use the Position ticket and verified login. Omit volume for a full close
        or send MT5 units for a partial close (10000 = 1 lot). Pricing and
        filling are automatic. Check the result and remaining position.
      operationId: close_position_api_v1_positions__position__close_post
      parameters:
        - name: position
          in: path
          required: true
          schema:
            type: integer
            title: Position
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 16
            maxLength: 128
            pattern: ^[A-Za-z0-9._:-]{16,128}$
            example: 550e8400-e29b-41d4-a716-446655440000
          description: >-
            Persisted key for this intent. Reuse the same key and body when
            retrying; use a new key for another trading intent, including a
            modification.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClosePositionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                title: Response Close Position Api V1 Positions  Position  Close Post
        '400':
          description: Missing or invalid Idempotency-Key.
        '409':
          description: Key reused with different data or request still pending.
        '422':
          description: Invalid request or incompatible trading parameters.
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    type: string
              example:
                detail: Invalid request
      security:
        - HTTPBearer: []
components:
  schemas:
    ClosePositionRequest:
      properties:
        login:
          type: integer
          exclusiveMinimum: 0
          title: Login
          description: Verified owner account login.
          example: 123456
        volume:
          anyOf:
            - type: integer
              exclusiveMinimum: 0
            - type: 'null'
          title: Volume
          description: >-
            Optional integer MT5 units, not lots: 10000 = 1 lot independently of
            contract size. Omit to request the full current position volume;
            partial execution may leave a remainder.
          example: 100
        comment:
          type: string
          maxLength: 31
          title: Comment
          default: REST API close
      additionalProperties: false
      type: object
      required:
        - login
      title: ClosePositionRequest
      examples:
        - login: 104205
        - comment: Partial close
          login: 104205
          volume: 5000
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        Send the provider-issued token in the Authorization header using Bearer
        authentication.

````

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