{
  "openapi": "3.1.0",
  "info": {
    "title": "DualSpatium & DualRestock API",
    "version": "1.0.0",
    "description": "API for DualSpatium platform and DualRestock Shopify back-in-stock alerts."
  },
  "servers": [
    {
      "url": "https://dualspatium.com",
      "description": "Production edge server"
    }
  ],
  "x-service-info": {
    "categories": [
      "e-commerce",
      "shopify",
      "notifications",
      "inventory"
    ],
    "provider": "DualSpatium"
  },
  "paths": {
    "/api/v1/alerts/subscribe": {
      "post": {
        "summary": "Subscribe customer to back-in-stock restock alert",
        "operationId": "subscribeAlert",
        "description": "Subscribes a customer's email address for automatic notification upon inventory restock in Shopify.",
        "x-payment-info": {
          "intent": "charge",
          "method": "stripe",
          "amount": 0.05,
          "currency": "USD",
          "description": "Pay-per-alert subscription processing fee",
          "offers": [
            {
              "intent": "charge",
              "method": "stripe",
              "amount": 0.05,
              "currency": "USD",
              "description": "Pay-per-alert subscription processing fee"
            },
            {
              "intent": "charge",
              "method": "tempo",
              "amount": "0.05",
              "currency": "USD",
              "description": "Micro-payment charge via Tempo"
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "productId": {
                    "type": "string",
                    "description": "Shopify product GID"
                  },
                  "variantId": {
                    "type": "string",
                    "description": "Shopify variant GID"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Customer notification email"
                  }
                },
                "required": [
                  "productId",
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Alert subscription created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "subscriptionId": { "type": "string" },
                    "status": { "type": "string", "example": "active" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment Required via x402 or MPP"
          }
        }
      }
    },
    "/api/v1/plans/checkout": {
      "post": {
        "summary": "Initiate agent checkout for DualRestock subscription",
        "operationId": "checkoutPlan",
        "description": "Creates an agent checkout session for DualRestock Starter or Growth plan.",
        "x-payment-info": {
          "intent": "session",
          "method": "stripe",
          "amount": 9.99,
          "currency": "USD",
          "description": "DualRestock Starter BYOK Monthly Plan",
          "offers": [
            {
              "intent": "session",
              "method": "stripe",
              "amount": 9.99,
              "currency": "USD",
              "description": "DualRestock Starter BYOK Monthly Plan"
            },
            {
              "intent": "session",
              "method": "card",
              "amount": 9.99,
              "currency": "USD",
              "description": "Credit/Debit Card Checkout Session"
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": "string",
                    "enum": ["starter", "growth"]
                  },
                  "shop": {
                    "type": "string"
                  }
                },
                "required": ["plan", "shop"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout session initialized successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checkoutUrl": { "type": "string", "format": "uri" },
                    "sessionId": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "summary": "API Health and Uptime Check",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "Service is healthy and ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" },
                    "service": { "type": "string", "example": "DualSpatium REST API" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
