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

# Withdraw prepaid balance to the owning wallet

> Sends FLOP from the deposit wallet to the wallet that owns the API key, and nowhere else. The amount is held first, so it cannot race a session or another withdrawal (one withdrawal per wallet in flight). The chain fee is estimated and taken out of the amount sent; the ledger books `withdrawal` (what left) and `withdrawal_fee` (fee actually paid). It answers 202 once the transfer is signed and submitted; poll `GET /v1/balance/withdrawals/{id}`. A withdrawal whose outcome is unknown keeps its hold until the chain shows it. At most 10 withdrawals per wallet per hour.



## OpenAPI

````yaml /openapi.json post /v1/balance/withdraw
openapi: 3.1.0
info:
  title: floprouter API
  version: 1.0.0
  description: >-
    The floprouter API routes chat requests to FLOP Network miners and settles
    each one on chain. One request format covers every model: chat completions
    with `provider` preferences and a `models` fallback list, model objects, a
    generation lookup, one error format and one streaming format. FLOP's own
    concepts have their own routes: miners, sessions on payment channels,
    session-key grants, the prepaid FLOP balance, settlement and on-chain
    attribution. **Base paths**: `/api/v1/...` and `/v1/...` serve the same
    routes; this document lists them under `/v1`. **Payer modes** (per key,
    overridable per request with `flop.payer`):

    - `grant`: the caller's wallet is the on-chain payer (channel `agent`) of
    every session. The wallet signs one `flopSessionKeys.createSession` grant to
    the router's delegate (`GET /v1/grants/params` returns the exact call data);
    the router then opens channels within the grant's caps. The escrow is paid
    on chain from the wallet; only the router fee comes from the prepaid
    balance. - `credit`: the router's wallet pays the session on chain; escrow
    and router fee are taken from the prepaid balance. **Balance**: fund it with
    a plain FLOP transfer from your wallet to `deposit_address` (`GET
    /v1/balance`); it is credited once the block is finalized. Withdraw with
    `POST /v1/balance/withdraw` (to the owning wallet only). Every balance can
    be recomputed from finalized chain state: billed sessions carry an encrypted
    ledger tag on chain, and the service checks its ledger against the chain
    continuously. The router fee is `fee_percent` of the session's escrow,
    charged only when the channel settles paid. **One request shape for every
    model**: the router chooses the chat envelope, template version, token
    limits and parameter support per model from what the chain and the miner's
    signed info say. Parameters a model does not support (see its
    `supported_parameters`) are ignored and named in
    `X-Floprouter-Ignored-Parameters`; `provider.require_parameters` refuses
    them instead. **Cost** (`usage.cost`, in FLOP): the escrow (prompt plus
    `max_tokens` at the model's price, paid in full on a cooperative settle)
    plus the router fee. Final once the session settles; a refunded session
    costs 0. **Timing**: a proxy in front closes responses idle for 100 s.
    Non-streaming calls answer within about 85 s: with the verified reply, or
    with HTTP 202 and the generation id to poll (`GET /v1/generation?id=`).
    Streams send `: FLOPROUTER PROCESSING` comments at least every 15 s.
    **Streaming**: chat completion chunks ending in a usage chunk (one choice
    repeating `finish_reason`) and `data: [DONE]`. Text is forwarded as the
    miner streams it and is provisional until the turn's signed receipt is
    verified at the end of the turn. A mid-stream error is one chunk with a
    top-level `error` and `finish_reason: "error"`. **Errors**: `{"error":
    {"code": <HTTP status>, "message", "metadata": {"reason", ...}}}`; 429 and
    503 carry `Retry-After`. **Miner score**: computed by the router from
    on-chain facts only (settlement history, volume, stake, slashing record,
    calibration state). The raw facts are returned beside it. **Client
    libraries**: the chat endpoint uses the widely used chat completions request
    and response format, so any client library for that format works with
    `baseURL` set to `https://api.floprouter.com/api/v1` and a floprouter key.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.floprouter.com
    description: API used by this site
security: []
tags:
  - name: Inference
    description: Chat completions and sessions.
  - name: Models
    description: >-
      Models, with their prices, limits and supported parameters, and the miners
      serving each.
  - name: Auth
    description: Wallet-signed API keys.
  - name: Grants
    description: 'Grant payer mode: the wallet stays the on-chain payer.'
  - name: Balance
    description: Prepaid balance and ledger.
  - name: Directory
    description: No key needed.
  - name: Service
    description: Health and this document.
paths:
  /v1/balance/withdraw:
    post:
      tags:
        - Balance
      summary: Withdraw prepaid balance to the owning wallet
      description: >-
        Sends FLOP from the deposit wallet to the wallet that owns the API key,
        and nowhere else. The amount is held first, so it cannot race a session
        or another withdrawal (one withdrawal per wallet in flight). The chain
        fee is estimated and taken out of the amount sent; the ledger books
        `withdrawal` (what left) and `withdrawal_fee` (fee actually paid). It
        answers 202 once the transfer is signed and submitted; poll `GET
        /v1/balance/withdrawals/{id}`. A withdrawal whose outcome is unknown
        keeps its hold until the chain shows it. At most 10 withdrawals per
        wallet per hour.
      operationId: withdrawBalance
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WithdrawRequest'
            example:
              amount: '0.03'
      responses:
        '200':
          description: Already final when the answer was ready (rare)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Withdrawal'
              example:
                object: withdrawal
                id: wd-306c854c672692e2
                to: 5GgtRwYh75jW5WrVXEYvU24ZBXxezbmqv1h523MYDMpPv3Lk
                status: sent
                requested: '0.03'
                sent: '0.027276454255'
                chain_fee: '0.002723545745'
                tx: >-
                  0xabd02d8b6cadafa9ea657b47ac88ad3296b28a5b60bbcd4b7109bec4ee895678
                block: 4497940
                error: null
                created_at: '2026-11-24T04:08:19.000Z'
                balance_after: '0.1895'
        '202':
          description: Signed and submitted; poll for the outcome
          headers:
            Location:
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Withdrawal'
              example:
                object: withdrawal
                id: wd-306c854c672692e2
                to: 5GgtRwYh75jW5WrVXEYvU24ZBXxezbmqv1h523MYDMpPv3Lk
                status: submitted
                requested: '0.03'
                sent: null
                chain_fee: null
                tx: >-
                  0xabd02d8b6cadafa9ea657b47ac88ad3296b28a5b60bbcd4b7109bec4ee895678
                block: null
                error: null
                created_at: '2026-11-24T04:08:19.000Z'
                balance_after: '0.1895'
                poll: /v1/balance/withdrawals/wd-306c854c672692e2
        '400':
          description: Invalid amount or destination
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: 400
                  message: withdrawals go only to the wallet that owns the API key
                  metadata:
                    reason: invalid_destination
        '401':
          $ref: '#/components/responses/E401'
        '402':
          description: Not enough available balance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: 402
                  message: available balance 0.0195 FLOP is less than 0.03
                  metadata:
                    reason: insufficient_balance
                    available: '0.0195'
        '409':
          description: >-
            A withdrawal for this wallet is in progress
            (`withdrawal_in_progress`), or this wallet's ledger differs from
            what the chain proves (`ledger_mismatch`); withdrawals wait until
            the difference is resolved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                in_progress:
                  value:
                    error:
                      code: 409
                      message: >-
                        a withdrawal for this wallet is still in progress (or
                        its outcome is being reconciled)
                      metadata:
                        reason: withdrawal_in_progress
                ledger_mismatch:
                  value:
                    error:
                      code: 409
                      message: >-
                        this wallet's balance differs from what the chain
                        proves; withdrawals wait until the difference is
                        resolved (GET /health, billing.ledger.reconcile)
                      metadata:
                        reason: ledger_mismatch
        '429':
          $ref: '#/components/responses/E429'
        '503':
          description: >-
            Withdrawals unavailable, deposit wallet short, transfer failed
            (nothing sent) or outcome unknown (amount held)
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: 503
                  message: >-
                    the deposit wallet cannot pay this withdrawal right now; try
                    a smaller amount later
                  metadata:
                    reason: treasury_insufficient
      security:
        - bearer: []
components:
  schemas:
    WithdrawRequest:
      type: object
      required:
        - amount
      properties:
        amount:
          type: string
          description: Decimal FLOP, or "all" for the whole available balance.
          examples:
            - '0.03'
            - all
        to:
          type: string
          description: Optional; must equal the owning wallet.
    Withdrawal:
      type: object
      properties:
        object:
          const: withdrawal
        id:
          type: string
        to:
          type: string
          description: Always the wallet that owns the API key.
        status:
          enum:
            - pending
            - submitted
            - sent
            - failed
            - unknown
          description: >-
            pending: held, not yet signed; submitted: signed and sent to the
            network; sent: final; failed: nothing left the wallet; unknown:
            signed, outcome not yet seen (the hold stays until the chain shows
            it).
        requested:
          type: string
        sent:
          type:
            - string
            - 'null'
          description: Requested amount minus the chain fee estimate.
        chain_fee:
          type:
            - string
            - 'null'
          description: Fee actually paid (TransactionFeePaid).
        tx:
          type:
            - string
            - 'null'
        block:
          type:
            - integer
            - 'null'
        error:
          type:
            - string
            - 'null'
        created_at:
          type: string
        balance_after:
          type: string
        poll:
          type: string
    Error:
      type: object
      description: >-
        `code` is the HTTP status; `metadata.reason` is floprouter's specific
        reason.
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: integer
              examples:
                - 400
                - 401
                - 402
                - 403
                - 404
                - 408
                - 409
                - 413
                - 429
                - 502
                - 503
            message:
              type: string
            metadata:
              type: object
              properties:
                reason:
                  type: string
                  examples:
                    - insufficient_balance
                    - grant_expired
                    - all_attempts_failed
                    - no_provider_supports_parameters
                    - tools_not_supported
                    - model_not_found
                    - rate_limited
                    - withdrawal_in_progress
                session_id:
                  type: string
              additionalProperties: true
  responses:
    E401:
      description: Missing or invalid key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: 401
              message: >-
                a wallet API key is required (Authorization: Bearer fr_...); see
                POST /v1/auth/challenge
              metadata:
                reason: unauthorized
    E429:
      description: Rate limit, concurrency cap, grant daily cap or demo budget
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: 429
              message: 'chat requests for this key: limit 20 per minute; retry in 41 s'
              metadata:
                reason: rate_limited
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: Wallet API key `fr_...` from `POST /v1/auth/keys`.

````

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