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

# Withdraw from a paper account

> Debits the paper account's available balance and returns the resulting wallet, to set up scenarios such as a low balance. Funds held by open orders or position margin cannot be withdrawn; above the available balance, it fails with 422 InsufficientFunds and changes nothing. It posts a Withdrawal transaction. If the outcome is unclear, check ListTransactions before retrying.



## OpenAPI

````yaml api-reference/platform/plurex-platform-api.yaml POST /api/v1/paper/command/Withdraw
openapi: 3.2.0
info:
  title: Plurex Platform API
  version: 1.0.0
  description: >-
    Trade across exchanges and brokers through one API, and paper trade any of
    them with the same calls.


    **Venues** are the exchanges where markets trade. Venue operations are
    public market data: markets, order books, recent trades, prices, quotes,
    statistics, funding, open interest and candles. They need no API key.


    **Hosts** hold trading accounts and execute orders on a venue's markets, for
    example an exchange's own account service or a broker. Host operations cover
    each host's tradable markets and order rules, and every account action:
    orders, fills, balances, positions, margin, leverage and transactions. A
    venue market tells you what is trading; the matching host market tells you
    what you may order there.


    **Tenants** own trading resources: every account belongs to one tenant. You
    act as your tenant, and your API keys are created under it. Find your tenant
    ID next to your API keys on the DevTools page of the Plurex app.


    **Accounts** are your accounts on hosts. Connect an exchange or broker
    account with its API credentials, or create a **paper** account. A paper
    host simulates a real host against that venue's live order book, so a paper
    account trades through exactly the same host operations and can be switched
    for a real one without code changes.


    **Capabilities.** Hosts and venues differ. Each host and venue lists every
    operation it supports, and each market lists its order types, settings and
    market data. Check these before calling: an unsupported call returns 422
    NotSupported.


    **Requests.** Every operation is a POST with a JSON body (Content-Type
    application/json). Account operations need both the X-API-KEY and
    X-API-SECRET headers. Unknown fields, unknown enum values and wrong types
    are rejected with 400. Every error has the ErrorEnvelope shape; its code
    says what went wrong. Account changes also arrive as WebSocket streams,
    described in the AsyncAPI document.


    **Compatibility.** Enum values, union variants, error codes and fields are
    added over time without a new version. Ignore fields you do not recognise,
    and treat unknown enum values and variants as an unrecognised case instead
    of failing. Removing or renaming any of them would be a breaking change.
servers:
  - url: https://api.plurex.io
security:
  - ApiKey: []
    ApiSecret: []
tags:
  - name: venues
    summary: Market data
    description: >-
      Public market data from the exchanges where markets trade. No API key
      needed.
    kind: nav
  - name: venue-markets
    summary: Venues and markets
    description: The venues and their markets, with the market data each market supports.
    parent: venues
    kind: nav
  - name: order-books
    summary: Order books
    description: A market's current bids and asks.
    parent: venues
    kind: nav
  - name: public-trades
    summary: Public trades
    description: A market's recent public trades.
    parent: venues
    kind: nav
  - name: market-observations
    summary: Prices and market statistics
    description: >-
      Current prices, best quotes, statistics, indicative funding and open
      interest, read in batches of instruments.
    parent: venues
    kind: nav
  - name: candles
    summary: Candles
    description: Closed OHLC candles by price kind and interval, newest first.
    parent: venues
    kind: nav
  - name: hosts
    summary: Trading
    description: >-
      Trading on an account: each host's tradable markets and order rules,
      orders, fills, balances, positions, margin, market settings and
      transactions. Paper accounts use these same operations.
    kind: nav
  - name: host-markets
    summary: Hosts and markets
    description: >-
      The hosts and their tradable markets, with each market's order types,
      order rules and settings.
    parent: hosts
    kind: nav
  - name: orders
    summary: Orders
    description: Submit, cancel and read orders.
    parent: hosts
    kind: nav
  - name: fills
    summary: Fills
    description: The account's executions, by order, instrument or across the account.
    parent: hosts
    kind: nav
  - name: portfolio
    summary: Balances and positions
    description: Wallet balances, open positions, margin and per-market account state.
    parent: hosts
    kind: nav
  - name: market-settings
    summary: Leverage and position mode
    description: Read and set the account's leverage and position mode for a market.
    parent: hosts
    kind: nav
  - name: transactions
    summary: Transactions
    description: 'Balance postings: fees, funding payments, deposits and so on.'
    parent: hosts
    kind: nav
  - name: accounts
    summary: Accounts
    description: Connect, list and manage a tenant's exchange, broker and paper accounts.
    kind: nav
  - name: paper
    summary: Paper trading
    description: >-
      Create, fund and draw down paper accounts and set their simulated fees.
      Trade them through the hosts operations like any other account.
    kind: nav
  - name: paper-accounts
    summary: Paper accounts
    description: Create, fund and draw down paper accounts.
    parent: paper
    kind: nav
  - name: paper-fees
    summary: Paper fees
    description: Choose the fee tier a paper account is charged.
    parent: paper
    kind: nav
  - name: public
    summary: No API key
    description: Public market data and discovery; no authentication needed.
    kind: badge
  - name: optional
    summary: Check capabilities
    description: >-
      Not every host or venue supports this operation; check its capabilities
      first or expect 422 NotSupported.
    kind: badge
  - name: paged
    summary: Paged
    description: Returns pages; follow nextCursor until null.
    kind: badge
  - name: batch
    summary: Batch
    description: Takes a list of identifiers or instruments and handles them in one call.
    kind: badge
  - name: not-repeat-safe
    summary: Not safe to repeat
    description: >-
      Repeating the call repeats its effect. If the outcome is unclear, check
      before retrying. Commands without this badge are safe to repeat.
    kind: badge
paths:
  /api/v1/paper/command/Withdraw:
    post:
      tags:
        - paper-accounts
        - not-repeat-safe
      summary: Withdraw from a paper account
      description: >-
        Debits the paper account's available balance and returns the resulting
        wallet, to set up scenarios such as a low balance. Funds held by open
        orders or position margin cannot be withdrawn; above the available
        balance, it fails with 422 InsufficientFunds and changes nothing. It
        posts a Withdrawal transaction. If the outcome is unclear, check
        ListTransactions before retrying.
      operationId: paperWithdraw
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WithdrawCommand'
      responses:
        '200':
          description: Successful result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseEnvelopeWallet'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '415':
          $ref: '#/components/responses/UnsupportedMediaType'
        '422':
          $ref: '#/components/responses/Rejected'
        '500':
          $ref: '#/components/responses/UnexpectedError'
        '503':
          $ref: '#/components/responses/Unavailable'
      security:
        - ApiKey: []
          ApiSecret: []
components:
  schemas:
    WithdrawCommand:
      type: object
      properties:
        accountId:
          type: string
        amount:
          $ref: '#/components/schemas/Decimal'
          description: Positive amount to withdraw; at most the asset's available balance.
        asset:
          type: string
      required:
        - accountId
        - amount
        - asset
      description: Removes an amount of an asset from a paper account's available balance.
    ResponseEnvelopeWallet:
      type: object
      description: Success response; data holds the result.
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/Wallet'
    Decimal:
      type: string
      pattern: ^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
      description: >-
        An exact decimal number encoded as a string. No binary floating-point
        rounding.
    Wallet:
      type: object
      properties:
        id:
          type:
            - string
            - 'null'
          description: >-
            Host wallet identifier; null when the host has a single unnamed
            wallet per asset.
        name:
          type:
            - string
            - 'null'
          description: Host wallet name; null when the host does not name wallets.
        asset:
          type: string
        totalBalance:
          $ref: '#/components/schemas/Decimal'
        availableBalance:
          $ref: '#/components/schemas/Decimal'
      required:
        - id
        - name
        - asset
        - totalBalance
        - availableBalance
      description: The account's balance of one asset in one host wallet.
    ErrorEnvelope:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
      required:
        - code
        - message
      description: >-
        Every error has this shape, at every HTTP status, including unknown
        paths (404 NotFound) and wrong methods (405 MethodNotAllowed). code is
        the specific reason. Each operation describes when to retry and how to
        check the outcome; an error alone does not prove a command had no
        effect.
    ErrorCode:
      type: string
      enum:
        - InvalidRequest
        - Unauthenticated
        - Forbidden
        - AccountNotFound
        - OrderNotFound
        - NotFound
        - MethodNotAllowed
        - DuplicateClientOrderId
        - OrderAlreadyClosed
        - Conflict
        - UnsupportedMediaType
        - InsufficientFunds
        - InvalidProviderCredentials
        - AccountLimit
        - NotSupported
        - Rejected
        - RateLimited
        - UnexpectedError
        - CancelAllFailed
        - UpstreamFailure
        - Unavailable
        - UpstreamTimeout
      description: >-
        Stable error reason. The HTTP status for each code is fixed:
        InvalidRequest (400): Malformed JSON, wrong types, unknown fields or
        enum values, or invalid values.; Unauthenticated (401): Missing or
        invalid API key headers.; Forbidden (403): Authenticated, but without
        access to the account or operation.; AccountNotFound (404): The
        accountId does not exist.; OrderNotFound (404): The account exists, but
        the order identifier does not.; NotFound (404): Unknown path, host or
        venue.; MethodNotAllowed (405): The path exists but only accepts POST.;
        DuplicateClientOrderId (409): An order with this clientOrderId already
        exists.; OrderAlreadyClosed (409): The order is already filled,
        cancelled or rejected.; Conflict (409): A unique value (for example an
        account name) is already used.; UnsupportedMediaType (415): The request
        is not Content-Type application/json.; InsufficientFunds (422): The
        account cannot fund the order or withdrawal.; InvalidProviderCredentials
        (422): The provider rejected the account credentials.; AccountLimit
        (422): An account or subscription limit was reached.; NotSupported
        (422): The host does not support this operation, variant or instrument.;
        Rejected (422): The host or validation rejected the command.;
        RateLimited (429): The provider rate limited the request.;
        UnexpectedError (500): Unexpected server failure.; CancelAllFailed
        (502): At least one sub-cancel failed; reconcile with ListOpenOrders.;
        UpstreamFailure (502): The provider failed or returned an unusable
        response.; Unavailable (503): The service or provider is temporarily
        unavailable.; UpstreamTimeout (504): The provider did not respond in
        time. New codes may be added; treat an unknown code by its HTTP status.
  responses:
    BadRequest:
      description: 400 BadRequest; code is InvalidRequest.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            InvalidRequest:
              summary: >-
                The body is malformed, has unknown fields or wrong types, or a
                value is invalid
              value:
                code: InvalidRequest
                message: Invalid cursor
    Unauthenticated:
      description: 401 Unauthenticated; code is Unauthenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            Unauthenticated:
              summary: The API key headers are missing or invalid
              value:
                code: Unauthenticated
                message: Unauthorized
    Forbidden:
      description: 403 Forbidden; code is Forbidden.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            Forbidden:
              summary: The key cannot access this account or operation
              value:
                code: Forbidden
                message: Forbidden
    NotFound:
      description: 404 NotFound; code is AccountNotFound, OrderNotFound or NotFound.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            AccountNotFound:
              summary: The accountId does not exist
              value:
                code: AccountNotFound
                message: 'Account not found: acc_123'
            OrderNotFound:
              summary: The account exists, but the order identifier does not
              value:
                code: OrderNotFound
                message: 'Order not found: ord_456'
            NotFound:
              summary: Unknown path, host or venue
              value:
                code: NotFound
                message: Not Found
    UnsupportedMediaType:
      description: 415 UnsupportedMediaType; code is UnsupportedMediaType.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            UnsupportedMediaType:
              summary: The request is not Content-Type application/json
              value:
                code: UnsupportedMediaType
                message: Content type text/plain is not supported
    Rejected:
      description: >-
        422 Rejected; code is InsufficientFunds, InvalidProviderCredentials,
        AccountLimit, NotSupported or Rejected.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            InsufficientFunds:
              summary: The account cannot fund the order or withdrawal
              value:
                code: InsufficientFunds
                message: Insufficient Funds
            InvalidProviderCredentials:
              summary: The provider rejected the account credentials
              value:
                code: InvalidProviderCredentials
                message: Unprocessable Entity
            AccountLimit:
              summary: An account or subscription limit was reached
              value:
                code: AccountLimit
                message: Subscription limit reached
            NotSupported:
              summary: The host does not support this operation, variant or instrument
              value:
                code: NotSupported
                message: Unprocessable Entity
            Rejected:
              summary: The host or validation rejected the command
              value:
                code: Rejected
                message: Order price is not a multiple of the price increment
    UnexpectedError:
      description: 500 UnexpectedError; code is UnexpectedError.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            UnexpectedError:
              summary: Unexpected server failure
              value:
                code: UnexpectedError
                message: Internal Server Error
    Unavailable:
      description: 503 Unavailable; code is Unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            Unavailable:
              summary: The service or provider is temporarily unavailable
              value:
                code: Unavailable
                message: Service Unavailable
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-KEY
    ApiSecret:
      type: apiKey
      in: header
      name: X-API-SECRET

````

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