{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/marketsdk/json-schema/marketsdk-order-object-schema.json",
  "title": "OrderObject",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/marketsdk-openapi.json#/components/schemas/OrderObject",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "order"
      ]
    },
    "id": {
      "type": "string"
    },
    "listing": {
      "type": "string"
    },
    "buyer": {
      "type": "string"
    },
    "seller": {
      "type": "string"
    },
    "quantity": {
      "type": "number"
    },
    "price": {
      "$ref": "#/$defs/OrderPriceObject"
    },
    "fee": {
      "description": "The customer's platform fee, fixed when the order was created.",
      "allOf": [
        {
          "$ref": "#/$defs/MoneyObject"
        }
      ]
    },
    "payments": {
      "type": "boolean",
      "description": "Whether payments were on when the order was created."
    },
    "payment": {
      "anyOf": [
        {
          "$ref": "#/$defs/OrderPaymentObject"
        },
        {
          "type": "null"
        }
      ]
    },
    "state": {
      "type": "string",
      "enum": [
        "awaiting_payment",
        "committed",
        "claimed",
        "disputed",
        "completed",
        "cancelled",
        "expired"
      ]
    },
    "state_reason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "payment_expired",
        "backed_out",
        "mutual",
        "auto_confirmed",
        "dispute",
        null
      ]
    },
    "claimed_by": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "buyer",
        "seller",
        null
      ]
    },
    "cancellation_proposal": {
      "anyOf": [
        {
          "$ref": "#/$defs/CancellationProposalObject"
        },
        {
          "type": "null"
        }
      ]
    },
    "timer_expires_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the current state's timer passes."
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "review_window_closes_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "dispute_window_closes_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "object",
    "id",
    "listing",
    "buyer",
    "seller",
    "quantity",
    "price",
    "fee",
    "payments",
    "payment",
    "state",
    "state_reason",
    "claimed_by",
    "cancellation_proposal",
    "timer_expires_at",
    "completed_at",
    "review_window_closes_at",
    "dispute_window_closes_at",
    "metadata",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "CancellationProposalObject": {
      "type": "object",
      "properties": {
        "proposed_by": {
          "type": "string",
          "enum": [
            "buyer",
            "seller"
          ]
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "description": "The proposal lapses after this. A lapsed or declined proposal changes nothing."
        }
      },
      "required": [
        "proposed_by",
        "expires_at"
      ]
    },
    "MoneyObject": {
      "type": "object",
      "properties": {
        "amount": {
          "type": "number",
          "description": "Integer minor units."
        },
        "currency": {
          "type": "string"
        }
      },
      "required": [
        "amount",
        "currency"
      ]
    },
    "OrderPaymentObject": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "awaiting_payment",
            "succeeded",
            "canceled"
          ]
        },
        "checkout_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Stripe-hosted checkout, when checkout URLs were given."
        },
        "client_secret": {
          "type": [
            "string",
            "null"
          ],
          "description": "For Stripe Elements on your own page, with your own Stripe publishable key."
        },
        "amount_refunded": {
          "type": "number",
          "description": "Refunded so far. Minor units."
        },
        "amount_released": {
          "type": "number",
          "description": "Released to the seller so far. Minor units."
        },
        "release_status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "held",
            "releasing",
            "released",
            "failed",
            "nothing_to_release",
            null
          ],
          "description": "Null until the buyer has paid. The seller share is held until the order completes, unless the marketplace releases at commitment."
        }
      },
      "required": [
        "id",
        "status",
        "checkout_url",
        "client_secret",
        "amount_refunded",
        "amount_released",
        "release_status"
      ]
    },
    "OrderPriceObject": {
      "type": "object",
      "properties": {
        "unit_amount": {
          "type": "number",
          "description": "Per unit, fixed when the order was created. Minor units."
        },
        "amount": {
          "type": "number",
          "description": "unit_amount times quantity. Minor units."
        },
        "currency": {
          "type": "string"
        }
      },
      "required": [
        "unit_amount",
        "amount",
        "currency"
      ]
    }
  }
}