{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/aifinpay-io/json-schema/aifinpay-io-merchant-config-preview-schema.json",
  "title": "MerchantConfigPreview",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/aifinpay-io-openapi.json#/components/schemas/MerchantConfigPreview",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "preview_id",
    "digest",
    "expires_at",
    "base_revision",
    "context_revision",
    "changes",
    "errors",
    "can_confirm",
    "id_map",
    "config"
  ],
  "properties": {
    "preview_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "digest": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "base_revision": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "context_revision": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "changes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "action",
          "kind",
          "summary"
        ],
        "properties": {
          "action": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "gateway_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "summary": {
            "type": "string"
          }
        }
      }
    },
    "errors": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "path",
          "code",
          "message"
        ],
        "properties": {
          "path": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "can_confirm": {
      "type": "boolean"
    },
    "id_map": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "config": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "format",
        "version",
        "revision",
        "router_slug",
        "default_gateway_id",
        "legacy_gateway_id",
        "gateways"
      ],
      "properties": {
        "format": {
          "const": "aifinpay-merchant-config",
          "type": "string"
        },
        "version": {
          "const": 1,
          "type": "integer"
        },
        "revision": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "router_slug": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 100
        },
        "default_gateway_id": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 100
        },
        "legacy_gateway_id": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 100
        },
        "gateways": {
          "type": "array",
          "maxItems": 8,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "slug",
              "type",
              "enabled_intent",
              "priority",
              "upstream_base_url"
            ],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "slug": {
                "type": "string",
                "pattern": "^[a-z0-9][a-z0-9-]{2,39}$"
              },
              "type": {
                "type": "string",
                "const": "hosted_x402"
              },
              "enabled_intent": {
                "type": "boolean"
              },
              "priority": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000
              },
              "upstream_base_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "description": {
                "type": "string",
                "maxLength": 500
              },
              "metadata": {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "minLength": 1,
                  "maxLength": 40
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 200
                }
              },
              "chains": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string"
                }
              },
              "payment_assets": {
                "type": "array",
                "uniqueItems": true,
                "items": {
                  "type": "string"
                }
              },
              "resources": {
                "type": "array",
                "maxItems": 500,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "route_pattern",
                    "type"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 100
                    },
                    "route_pattern": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "page",
                        "api",
                        "dataset",
                        "mcp_tool",
                        "product"
                      ]
                    },
                    "name": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "maxLength": 60
                    },
                    "description": {
                      "type": "string",
                      "maxLength": 500
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "paywall_enabled": {
                      "type": "boolean"
                    },
                    "currency": {
                      "const": "USD",
                      "type": "string"
                    },
                    "billing_unit": {
                      "const": "request",
                      "type": "string"
                    },
                    "unit_weight": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 100000
                    },
                    "price_usd": {
                      "type": "string",
                      "pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]{1,6})?$"
                    },
                    "tier": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "standard",
                        "complex",
                        "premium",
                        null
                      ]
                    },
                    "chains": {
                      "type": "array",
                      "uniqueItems": true,
                      "items": {
                        "type": "string"
                      }
                    },
                    "payment_assets": {
                      "type": "array",
                      "uniqueItems": true,
                      "items": {
                        "type": "string"
                      }
                    },
                    "daily_unit_limit": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 1,
                      "maximum": 100000000
                    },
                    "fallback_gateway_id": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "minLength": 1,
                      "maxLength": 100
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}