{
  "openapi": "3.1.0",
  "info": {
    "title": "MON Unlock Agent API",
    "version": "1.0.3",
    "description": "Create embeddable paywalls for long-form articles. Agents validate for free, then pay via Machine Payments Protocol (HTTP 402) to publish paste-ready <mon-unlock> HTML. On-chain Monad registration may still require one publisher wallet approval.",
    "contact": {
      "name": "Open Paywall / MON Unlock",
      "email": "carlos.a.reyes00@gmail.com",
      "url": "https://mon-unlock-widget-production.up.railway.app"
    }
  },
  "servers": [
    {
      "url": "https://mon-unlock-widget-production.up.railway.app"
    }
  ],
  "x-service-info": {
    "categories": [
      "content-monetization",
      "paywall",
      "publishing",
      "embeddable-paywall",
      "pay-per-article"
    ],
    "docs": {
      "homepage": "https://mon-unlock-widget-production.up.railway.app",
      "llms": "https://mon-unlock-widget-production.up.railway.app/llms.txt",
      "apiReference": "https://mon-unlock-widget-production.up.railway.app/agents.md"
    }
  },
  "x-agent-guidance": {
    "preferredFlow": [
      "POST /api/agents/publish/validate",
      "POST /api/agents/publish (pay 402 challenge)",
      "Return embed HTML",
      "Send finishRegistrationUrl if needsManualOnChainRegistration"
    ],
    "skill": "https://mon-unlock-widget-production.up.railway.app/skill.md",
    "cursorSkill": "https://mon-unlock-widget-production.up.railway.app/.well-known/skills/mon-unlock/SKILL.md",
    "mppConfigured": true
  },
  "paths": {
    "/api/agents/health": {
      "get": {
        "operationId": "agentHealth",
        "summary": "Agent API + MPP configuration status",
        "security": [],
        "responses": {
          "200": {
            "description": "Health payload"
          }
        }
      }
    },
    "/api/agents/publish/validate": {
      "post": {
        "operationId": "validatePublish",
        "summary": "Validate publish payload and return quote (free)",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Valid payload + quote"
          },
          "400": {
            "description": "Invalid payload"
          }
        }
      }
    },
    "/api/agents/publish": {
      "post": {
        "operationId": "publishPaywall",
        "summary": "Create embed + sync article body (MPP paid)",
        "description": "Unpaid requests receive HTTP 402 with WWW-Authenticate Payment challenge. After payment, returns paste-ready embed HTML and finishRegistrationUrl for on-chain Monad registration.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.05"
          },
          "protocols": [
            {
              "mpp": {
                "method": "tempo",
                "network": "tempo",
                "chainId": 4217,
                "asset": "0x20c0000000000000000000000000000000000000",
                "amount": "50000",
                "recipient": "0x340f0aAAE5A6FB14B37F55De96EF429f08B6659F"
              }
            }
          ],
          "offers": [
            {
              "method": "tempo",
              "intent": "charge",
              "currency": "0x20c0000000000000000000000000000000000000",
              "amount": "50000",
              "description": "Create one embeddable paywall — $0.05 in pathUSD/USDC.e on Tempo"
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Published embed payload"
          },
          "400": {
            "description": "Invalid payload"
          },
          "402": {
            "description": "Payment Required"
          },
          "503": {
            "description": "MPP not configured on server"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PublishRequest": {
        "type": "object",
        "required": [
          "title",
          "articleId",
          "teaser",
          "body",
          "publisher"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "articleId": {
            "type": "string",
            "description": "URL-safe slug"
          },
          "teaser": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "publisher": {
            "type": "string",
            "description": "0x publisher wallet"
          },
          "price": {
            "type": "string",
            "description": "Article price in MON",
            "default": "1"
          },
          "author": {
            "type": "string"
          }
        }
      }
    }
  }
}