{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/plaxswap-com/json-schema/plaxswap-com-order-view-schema.json",
  "title": "OrderView",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/plaxswap-com-openapi.json#/components/schemas/OrderView",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "14 characters.",
      "pattern": "^[0-9a-z]{14}$"
    },
    "type": {
      "$ref": "#/$defs/OrderType"
    },
    "status": {
      "$ref": "#/$defs/OrderStatus"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "expiresAt": {
      "type": "string",
      "description": "The order stops accepting deposits after this time.",
      "format": "date-time"
    },
    "from": {
      "$ref": "#/$defs/MethodRef"
    },
    "to": {
      "$ref": "#/$defs/MethodRef"
    },
    "depositAddress": {
      "type": [
        "string",
        "null"
      ],
      "description": "Where to send. null while identity verification must happen first."
    },
    "depositMemo": {
      "type": [
        "string",
        "null"
      ],
      "description": "Required memo or tag for the deposit, on networks that use one."
    },
    "depositAddressUrl": {
      "type": [
        "string",
        "null"
      ]
    },
    "depositMin": {
      "type": "string",
      "pattern": "^\\d+(\\.\\d+)?$"
    },
    "depositMax": {
      "type": "string",
      "pattern": "^\\d+(\\.\\d+)?$"
    },
    "expectedDeposit": {
      "type": [
        "string",
        "null"
      ],
      "description": "Fixed orders: the exact amount to send.",
      "pattern": "^\\d+(\\.\\d+)?$"
    },
    "plannedDeposit": {
      "type": [
        "string",
        "null"
      ],
      "description": "Variable orders: the amount the customer said they would send (null when not given).",
      "pattern": "^\\d+(\\.\\d+)?$"
    },
    "expectedSettle": {
      "type": [
        "string",
        "null"
      ],
      "description": "Fixed orders: the guaranteed payout.",
      "pattern": "^\\d+(\\.\\d+)?$"
    },
    "rate": {
      "type": [
        "string",
        "null"
      ],
      "description": "Fixed orders: the locked rate.",
      "pattern": "^\\d+(\\.\\d+)?$"
    },
    "settleAddress": {
      "type": "string",
      "description": "Shortened (for example bc1qxy…f2kd) unless the caller has the order token or created it with their API key."
    },
    "settleMemo": {
      "type": [
        "string",
        "null"
      ]
    },
    "refundAddress": {
      "type": [
        "string",
        "null"
      ]
    },
    "refundMemo": {
      "type": [
        "string",
        "null"
      ]
    },
    "kyc": {
      "type": "object",
      "properties": {
        "status": {
          "$ref": "#/$defs/KycStatus"
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "status",
        "reason"
      ]
    },
    "travelRule": {
      "type": "object",
      "properties": {
        "required": {
          "type": "boolean"
        },
        "provided": {
          "type": "boolean"
        }
      },
      "required": [
        "required",
        "provided"
      ]
    },
    "deposits": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DepositView"
      }
    },
    "events": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/OrderEventView"
      },
      "description": "History of the order, oldest first (up to 200)."
    },
    "averageSeconds": {
      "type": "integer"
    },
    "addressesMasked": {
      "type": "boolean",
      "description": "true when the caller only has the order link, so addresses are shortened."
    },
    "paymentLinkId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Set when this order pays a payment link (/pay/<id>): the payout address belongs to the link's recipient."
    },
    "gatewayPaymentId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Set when this order pays a merchant's payment (/checkout/<id>): the payout address belongs to the merchant."
    }
  },
  "required": [
    "id",
    "type",
    "status",
    "createdAt",
    "expiresAt",
    "from",
    "to",
    "depositAddress",
    "depositMemo",
    "depositAddressUrl",
    "depositMin",
    "depositMax",
    "expectedDeposit",
    "plannedDeposit",
    "expectedSettle",
    "rate",
    "settleAddress",
    "settleMemo",
    "refundAddress",
    "refundMemo",
    "kyc",
    "travelRule",
    "deposits",
    "events",
    "averageSeconds",
    "paymentLinkId",
    "gatewayPaymentId"
  ],
  "$defs": {
    "DepositStatus": {
      "type": "string",
      "enum": [
        "pending",
        "processing",
        "review",
        "settling",
        "settled",
        "refund",
        "refunding",
        "refunded",
        "frozen",
        "failed"
      ]
    },
    "DepositView": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^d_[0-9a-z]{16}$"
        },
        "txid": {
          "type": "string",
          "description": "Deposit transaction id."
        },
        "txUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "fromAddress": {
          "type": [
            "string",
            "null"
          ],
          "description": "Sender, when the network has one. Shortened on shared links."
        },
        "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$"
        },
        "amountUsd": {
          "type": [
            "number",
            "null"
          ],
          "description": "Value when the deposit arrived, in US dollars."
        },
        "confirmations": {
          "type": "integer"
        },
        "requiredConfirmations": {
          "type": "integer"
        },
        "status": {
          "$ref": "#/$defs/DepositStatus"
        },
        "reason": {
          "anyOf": [
            {
              "$ref": "#/$defs/ReasonCode"
            },
            {
              "type": "null"
            }
          ]
        },
        "reasonText": {
          "type": [
            "string",
            "null"
          ],
          "description": "Plain-English text for reason, safe to show."
        },
        "rate": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d+(\\.\\d+)?$"
        },
        "settleAmount": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d+(\\.\\d+)?$"
        },
        "settleMinimum": {
          "type": [
            "string",
            "null"
          ],
          "description": "Swaps converted on our exchange account: the least the payout can be. If the price falls below it before conversion, the deposit is refunded instead.",
          "pattern": "^\\d+(\\.\\d+)?$"
        },
        "exchangeStage": {
          "type": [
            "string",
            "null"
          ],
          "description": "Swaps converted on our exchange account, while processing: forwarding (our transfer to the exchange), converting, or sending (the exchange is sending the payout; settleTxid follows once it is on the network).",
          "enum": [
            "forwarding",
            "converting",
            "sending"
          ]
        },
        "settleTxid": {
          "type": [
            "string",
            "null"
          ]
        },
        "settleTxUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "payoutConfirmations": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The payout (or refund) we sent: network confirmations so far, as last checked."
        },
        "payoutRequiredConfirmations": {
          "type": "integer",
          "description": "Confirmations that network needs before the payout (or refund) counts as arrived."
        },
        "refundAmount": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d+(\\.\\d+)?$"
        },
        "refundNetworkFeeUsd": {
          "type": [
            "number",
            "null"
          ],
          "description": "Network fees the refund kept back, in US dollars."
        },
        "refundHandlingFeeUsd": {
          "type": [
            "number",
            "null"
          ],
          "description": "Handling fee the refund kept back, in US dollars. Only on refunds the customer caused; 0 when none."
        },
        "refundTxid": {
          "type": [
            "string",
            "null"
          ]
        },
        "refundTxUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "detectedAt": {
          "type": "string",
          "format": "date-time"
        },
        "confirmedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "settledAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "refundedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "reviewDueAt": {
          "type": [
            "string",
            "null"
          ],
          "description": "Review holds that are refunded automatically: the decision deadline.",
          "format": "date-time"
        },
        "manualDecision": {
          "type": "boolean",
          "description": "In review with no automatic refund deadline: a person decides (high risk, sanctions, payout problems)."
        }
      },
      "required": [
        "id",
        "txid",
        "txUrl",
        "fromAddress",
        "amount",
        "amountUsd",
        "confirmations",
        "requiredConfirmations",
        "status",
        "reason",
        "reasonText",
        "rate",
        "settleAmount",
        "settleMinimum",
        "exchangeStage",
        "settleTxid",
        "settleTxUrl",
        "payoutConfirmations",
        "payoutRequiredConfirmations",
        "refundAmount",
        "refundNetworkFeeUsd",
        "refundHandlingFeeUsd",
        "refundTxid",
        "refundTxUrl",
        "detectedAt",
        "confirmedAt",
        "settledAt",
        "refundedAt",
        "reviewDueAt",
        "manualDecision"
      ]
    },
    "KycStatus": {
      "type": "string",
      "enum": [
        "none",
        "required",
        "pending",
        "approved",
        "rejected"
      ]
    },
    "MethodRef": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "assetId": {
          "type": "string"
        },
        "networkId": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "decimals": {
          "type": "integer"
        },
        "memoRequired": {
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "assetId",
        "networkId",
        "label",
        "decimals",
        "memoRequired"
      ]
    },
    "OrderEventView": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "type": {
          "type": "string",
          "description": "For example \"deposit.confirmed\". The same names as the webhook events."
        },
        "message": {
          "type": "string",
          "description": "Plain-English text, safe to show."
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "type",
        "message",
        "createdAt"
      ]
    },
    "OrderStatus": {
      "type": "string",
      "enum": [
        "waiting",
        "pending",
        "processing",
        "review",
        "settling",
        "settled",
        "refund",
        "refunding",
        "refunded",
        "frozen",
        "failed",
        "expired",
        "cancelled",
        "multiple"
      ]
    },
    "OrderType": {
      "type": "string",
      "description": "fixed: locked price, exact amount. variable: any amount within limits, market rate when it confirms.",
      "enum": [
        "fixed",
        "variable"
      ]
    },
    "ReasonCode": {
      "type": "string",
      "description": "Why a deposit left the normal path. reasonText explains it in plain English.",
      "enum": [
        "amount_under_min",
        "amount_over_max",
        "incorrect_amount",
        "order_expired",
        "max_one_deposit",
        "too_many_deposits",
        "coin_unavailable",
        "rate_unavailable",
        "low_effective_rate",
        "duplicate",
        "risk_review",
        "kyc_required",
        "limit_exceeded",
        "sanctions_match",
        "jurisdiction_blocked",
        "below_refund_cost",
        "travel_rule_required",
        "review_timeout",
        "payout_failed",
        "deposit_dropped",
        "kyc_location",
        "kyc_rejected",
        "legal_hold",
        "rate_moved",
        "manual",
        "partner_limit"
      ]
    }
  }
}