{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sharedforest-com/json-schema/sharedforest-com-order-schema.json",
  "title": "Order",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sharedforest-com-openapi.json#/components/schemas/Order",
  "type": "object",
  "required": [
    "id",
    "status",
    "quantity",
    "unitAmount",
    "total",
    "currency",
    "channel",
    "checkoutUrl",
    "confirmUrl",
    "treeIds",
    "createdAt",
    "paidAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^ord_"
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "paid",
        "fulfilled",
        "expired",
        "refunded",
        "disputed",
        "cancelled",
        "refund_pending"
      ],
      "description": "refund_pending: paid, but no tree could be planted or a refund is due. The operator refunds."
    },
    "quantity": {
      "type": "integer"
    },
    "unitAmount": {
      "type": "integer",
      "description": "Final price in euro cents."
    },
    "total": {
      "type": "integer",
      "description": "Final price in euro cents."
    },
    "currency": {
      "type": "string",
      "const": "eur"
    },
    "channel": {
      "type": "string",
      "enum": [
        "web",
        "mcp",
        "api"
      ]
    },
    "billingChoice": {
      "type": "string",
      "enum": [
        "one_time",
        "subscription"
      ]
    },
    "checkoutUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Stripe Checkout URL while status is open and the buyer confirmed."
    },
    "confirmUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Agent orders: the page where the human confirms and pays."
    },
    "treeIds": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Filled when fulfilled."
    },
    "createdAt": {
      "type": "integer",
      "description": "ms since epoch"
    },
    "paidAt": {
      "type": [
        "integer",
        "null"
      ],
      "description": "ms since epoch"
    },
    "refundDue": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Cents still to refund while status is refund_pending."
    },
    "paidThrough": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Subscription paid-through timestamp in milliseconds."
    },
    "firstTermEndsAt": {
      "type": [
        "integer",
        "null"
      ],
      "description": "End of the subscription's 12-month minimum term in milliseconds."
    },
    "cancelAt": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Scheduled end at the first term; null while renewal is active."
    },
    "cancelledAt": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Effective cancellation time in milliseconds."
    }
  }
}