{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pageweave-dev/json-schema/pageweave-dev-domain-purchase-schema.json",
  "title": "DomainPurchase",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pageweave-dev-openapi.json#/components/schemas/DomainPurchase",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "status",
    "domain",
    "period",
    "price",
    "workspace_id",
    "website_id",
    "renewal_price",
    "vat_note",
    "approval_url",
    "failure_reason",
    "order",
    "created_at",
    "expires_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Purchase workflow UUID."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "executing",
        "expired",
        "completed",
        "cancelled",
        "failed"
      ],
      "description": "Workflow state. Only `pending` can still be approved."
    },
    "domain": {
      "type": "string",
      "description": "Normalized domain name being purchased."
    },
    "period": {
      "type": "integer",
      "description": "Registration period in years."
    },
    "price": {
      "oneOf": [
        {
          "$ref": "#/$defs/Money"
        },
        {
          "type": "null"
        }
      ],
      "description": "Quoted registration price for the period, VAT excluded."
    },
    "workspace_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Workspace the purchase belongs to."
    },
    "website_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Website the domain is attached to on completion."
    },
    "renewal_price": {
      "oneOf": [
        {
          "$ref": "#/$defs/Money"
        },
        {
          "type": "null"
        }
      ],
      "description": "Renewal fee disclosed with the offer (ERRP §4.1)."
    },
    "vat_note": {
      "type": "string",
      "description": "VAT statement that applies to the quoted prices."
    },
    "approval_url": {
      "type": "string",
      "format": "uri",
      "description": "Human approval page for the purchase (`/actions/{id}`)."
    },
    "failure_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Localized reason when the workflow failed."
    },
    "order": {
      "oneOf": [
        {
          "$ref": "#/$defs/DomainPurchaseOrder"
        },
        {
          "type": "null"
        }
      ],
      "description": "The registrar order once the purchase reached execution."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "DomainPurchaseOrder": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "status",
        "amount",
        "period_years"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "status": {
          "type": "string",
          "description": "Registrar transaction status, e.g. `pending` or `completed`."
        },
        "amount": {
          "$ref": "#/$defs/Money"
        },
        "period_years": {
          "type": "integer"
        }
      }
    },
    "Money": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "amount",
        "currency"
      ],
      "description": "Decimal amount as a locale-independent string, plus ISO 4217 currency.",
      "properties": {
        "amount": {
          "type": "string",
          "description": "Decimal string, e.g. `12.99`."
        },
        "currency": {
          "type": "string",
          "description": "ISO 4217 currency code, e.g. `EUR`."
        }
      }
    }
  }
}