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

# 提交提現

> 提交已簽名的提現請求。

提交已簽名的提現請求。

> [!NOTE]
>
> 使用 Broker API Key 呼叫，並在請求頭提供 `X-User-Wallet-Address`。網關會校驗錢包與 Broker 的歸屬關係。 認證規則見[Broker API 認證與簽名](https://dexbuilder.mintlify.site/zh-TW/api-reference/common/broker-authentication.md)。

## 使用說明

* `r`、`v`、`s` 為使用者的簽名分量；`timestamp` 為毫秒級時間戳，須與[獲取提現簽名資料](https://dexbuilder.mintlify.site/zh-TW/api-reference/dexbuilder/withdraw-sign-data.md)的回傳值一致。
* `to_address` 可省略；若提供，須與已綁定的 `address` 一致，且與簽名資料請求保持一致。
* `Idempotency-Key` 必填。同一使用者在此介面以相同 Key 重試時，回傳首次成功的回應。`success=true` 表示已受理；最終狀態請查詢[提現狀態](https://dexbuilder.mintlify.site/zh-TW/api-reference/dexbuilder/withdraw-status.md)。


## OpenAPI

````yaml openapi/dexbuilder-zh-TW.yaml POST /api/v4/dexbuilder/withdraw/submit
openapi: 3.0.3
info:
  title: DexBuilder 平台 Broker API
  version: 1.0.0
  description: DexBuilder 平台 Broker API，涵蓋資產配置、使用者、充值與提現能力。認證和使用者錢包校驗見本站統一網關說明。
servers:
  - url: https://api.dexbuilder.com
security: []
paths:
  /api/v4/dexbuilder/withdraw/submit:
    post:
      tags:
        - 提現
      summary: 提交提現
      description: 提交已簽名的提現請求；支持 Idempotency-Key 冪等。
      operationId: dexBuilderWithdrawSubmit
      parameters:
        - $ref: '#/components/parameters/SubUserWalletAddr'
        - $ref: '#/components/parameters/IdempotencyKey'
        - $ref: '#/components/parameters/DeviceType'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PerpWithdrawSubmitRequest'
      responses:
        '200':
          description: 受理成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvelopeWithdrawSubmit'
        '400':
          $ref: '#/components/responses/OpenAPIBadRequest'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          $ref: '#/components/responses/GatewayUnauthorized'
        '403':
          $ref: '#/components/responses/ProjectAccessDenied'
      security:
        - BrokerAPIKey: []
          Timestamp: []
          Signature: []
components:
  parameters:
    SubUserWalletAddr:
      name: X-User-Wallet-Address
      in: header
      required: true
      description: 目標終端使用者錢包地址。網關校驗該錢包對應的使用者屬於當前 Broker。
      schema:
        type: string
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: >-
        冪等鍵，最長 128 字符，建議使用 UUID。同一使用者在同一提交介面使用相同 Key
        重試時，服務端回傳首次成功請求的回應；網路超時後可使用原 Key 重試。不同請求不得復用 Key。
      schema:
        type: string
        maxLength: 128
      example: 7c9e6679-7425-40de-944b-e07fc1f90ae7
    DeviceType:
      name: x-perp-device-type
      in: header
      required: true
      description: >-
        DexBuilder 設備類型：1 Android、2 iOS、3 WEB。缺少或無效時回傳
        INVALID_DEVICE_TYPE。僅適用於明確列出此請求標頭的平台介面。
      schema:
        type: string
        enum:
          - '1'
          - '2'
          - '3'
      example: '3'
  schemas:
    PerpWithdrawSubmitRequest:
      type: object
      properties:
        r:
          type: string
          description: 對 sign_data.data 簽名的 r（0x hex）
        v:
          type: integer
          description: 簽名 v，整數（如 27/28）
        s:
          type: string
          description: 簽名 s（0x hex）
        chain:
          $ref: '#/components/schemas/OpenAPIChainId'
        token_address:
          type: string
          description: 代幣合約
        address:
          type: string
          description: 使用者錢包，須與 sign_data 請求一致
        token_amount:
          type: string
          description: 提現數量
        to_address:
          type: string
          description: 選填；若提供，必須與綁定的簽名錢包地址一致。不支援提現至第三方地址。
        timestamp:
          type: integer
          format: int64
          description: 須等於 sign_data 回應中的 timestamp
        token_symbol:
          type: string
          description: 代幣符號
      required:
        - r
        - v
        - s
        - timestamp
        - chain
        - token_address
        - address
        - token_amount
        - token_symbol
    EnvelopeWithdrawSubmit:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/PerpWithdrawSubmitResponse'
    ErrorEnvelope:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          required:
            - label
          properties:
            label:
              type: string
              description: 穩定的機器可讀錯誤標識
            data:
              nullable: true
              description: 錯誤時一般為 null
    OpenAPIChainId:
      type: string
      enum:
        - base
        - bsc
        - ethereum
        - solana
        - arbitrum
      description: 網路標識：base、bsc、ethereum、solana 或 arbitrum。
      example: ethereum
    EnvelopeBase:
      type: object
      properties:
        code:
          type: integer
          example: 0
          description: 業務碼，`0` 表示成功
        message:
          type: string
          example: success
          description: 人類可讀說明，成功時為 success
        reason:
          type: string
          description: 錯誤原因標識；成功時通常為空字符串
        trace_id:
          type: string
          description: 鏈路追蹤 ID，排障時提供
    PerpWithdrawSubmitResponse:
      type: object
      properties:
        event_id:
          type: string
          description: 提現事件 UUID，用於 GET /withdraw/status
        success:
          type: boolean
          description: 是否受理成功
  responses:
    OpenAPIBadRequest:
      description: 請求無效（參數、請求體、使用者身份或業務校驗）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            invalidArgument:
              summary: 參數無效
              value:
                label: INVALID_ARGUMENT
                message: invalid argument
            userNotFound:
              summary: 使用者不存在
              value:
                label: USER_NOT_FOUND
                message: User not found
            missingHeader:
              summary: 缺少必要請求頭
              value:
                label: MISSING_REQUIRED_HEADER
                message: invalid headers
    GatewayUnauthorized:
      description: Broker API Key、簽名或時間戳無效
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            invalidKey:
              summary: 無效 API Key
              value:
                label: INVALID_KEY
                message: Invalid key provided
                code: 401
                trace_id: abc123
            invalidSignature:
              summary: 簽名錯誤
              value:
                label: INVALID_SIGNATURE
                message: Invalid signature
                code: 401
                trace_id: abc123
    ProjectAccessDenied:
      description: 專案未綁定或 Broker/API Key 不匹配
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            code: 40300801
            reason: P_DEX_BUILDER_IN_PROJECT_ACCESS_DENIED
            label: PROJECT_ACCESS_DENIED
            message: project access denied
            data: null
  securitySchemes:
    BrokerAPIKey:
      type: apiKey
      in: header
      name: KEY
      description: Broker API Key
    Timestamp:
      type: apiKey
      in: header
      name: Timestamp
      description: Unix 秒級時間戳
    Signature:
      type: apiKey
      in: header
      name: SIGN
      description: 使用 Broker Secret Key 生成的 HMAC-SHA512 十六進制簽名

````

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