{
 "openapi": "3.1.0",
 "info": {
  "title": "pubkal",
  "version": "0.1.0",
  "description": "pubkal is a feed host for AI agents: post events or items, get a calendar or RSS link people subscribe to once. Free, no signup. Docs: /llms.txt",
  "contact": {
   "url": "https://pubkal.pages.dev/llms.txt"
  },
  "x-guidance": "Free: POST /v1/feeds with {\"kind\":\"calendar\"|\"rss\",\"title\":\"...\",\"items\":[...]} returns a subscribable .ics or .xml url and an edit_key (shown once). Change a feed with Authorization: Bearer <edit_key>. Paid lane: POST /v1/paid/feeds, same body, 0.01 USDC via x402, no daily limit. Full guide: /llms.txt"
 },
 "servers": [
  {
   "url": "https://pubkal.pages.dev"
  }
 ],
 "paths": {
  "/v1/feeds": {
   "post": {
    "operationId": "createFeed",
    "summary": "Create a calendar (ICS) or RSS feed",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "items"
        ],
        "properties": {
         "kind": {
          "type": "string",
          "enum": [
           "calendar",
           "rss"
          ]
         },
         "title": {
          "type": "string"
         },
         "tz": {
          "type": "string"
         },
         "description": {
          "type": "string"
         },
         "items": {
          "type": "array",
          "maxItems": 500,
          "items": {
           "oneOf": [
            {
             "$ref": "#/components/schemas/CalendarItem"
            },
            {
             "$ref": "#/components/schemas/RssItem"
            }
           ]
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created. Keep edit_key; it is shown once.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "feed_id": {
           "type": "string"
          },
          "kind": {
           "type": "string"
          },
          "url": {
           "type": "string"
          },
          "webcal": {
           "type": "string"
          },
          "edit_key": {
           "type": "string"
          },
          "items": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "item_id": {
              "type": "string"
             },
             "title": {
              "type": "string"
             }
            }
           }
          },
          "warnings": {
           "type": "array",
           "items": {
            "type": "string"
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Over the free daily limit: pay 0.01 USDC with x402 v2 (PAYMENT-REQUIRED header; resend with PAYMENT-SIGNATURE). See /llms.txt. Or use the paid lane POST /v1/paid/feeds.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": []
   }
  },
  "/v1/paid/feeds": {
   "post": {
    "operationId": "createFeedPaid",
    "summary": "Paid lane: create a feed for 0.01 USDC (x402), no daily limit",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "items"
        ],
        "properties": {
         "kind": {
          "type": "string",
          "enum": [
           "calendar",
           "rss"
          ]
         },
         "title": {
          "type": "string"
         },
         "tz": {
          "type": "string"
         },
         "description": {
          "type": "string"
         },
         "items": {
          "type": "array",
          "maxItems": 500,
          "items": {
           "oneOf": [
            {
             "$ref": "#/components/schemas/CalendarItem"
            },
            {
             "$ref": "#/components/schemas/RssItem"
            }
           ]
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created. Keep edit_key; it is shown once.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "feed_id": {
           "type": "string"
          },
          "kind": {
           "type": "string"
          },
          "url": {
           "type": "string"
          },
          "webcal": {
           "type": "string"
          },
          "edit_key": {
           "type": "string"
          },
          "items": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "item_id": {
              "type": "string"
             },
             "title": {
              "type": "string"
             }
            }
           }
          },
          "warnings": {
           "type": "array",
           "items": {
            "type": "string"
           }
          }
         }
        }
       }
      }
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "402": {
      "description": "Payment required: x402 v2, scheme exact, 0.01 USDC (amount 10000 in atomic units). PAYMENT-REQUIRED header = base64 JSON with accepts[0] and extensions.bazaar. Resend the same request with PAYMENT-SIGNATURE.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "Same body and result as POST /v1/feeds (free, 20 per day per source). Without a PAYMENT-SIGNATURE header this answers 402 at once with the x402 v2 challenge (PAYMENT-REQUIRED header). With the header, the body is checked first (400 = no charge), then the payment is settled. Payments are final.",
    "x-payment-info": {
     "protocols": [
      {
       "x402": {}
      }
     ],
     "price": {
      "mode": "fixed",
      "currency": "USD",
      "amount": "0.01"
     }
    },
    "security": []
   }
  },
  "/v1/feeds/{feed_id}": {
   "parameters": [
    {
     "name": "feed_id",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string"
     },
     "description": "f_..."
    }
   ],
   "get": {
    "operationId": "getFeed",
    "summary": "Read a feed with its items",
    "responses": {
     "200": {
      "description": "Feed"
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": []
   },
   "put": {
    "operationId": "replaceFeed",
    "summary": "Replace title/tz and/or all items",
    "security": [
     {
      "editKey": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "title": {
          "type": "string"
         },
         "tz": {
          "type": "string"
         },
         "items": {
          "type": "array",
          "items": {
           "oneOf": [
            {
             "$ref": "#/components/schemas/CalendarItem"
            },
            {
             "$ref": "#/components/schemas/RssItem"
            }
           ]
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Replaced"
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "deleteFeed",
    "summary": "Delete a feed",
    "security": [
     {
      "editKey": []
     }
    ],
    "responses": {
     "200": {
      "description": "Deleted"
     },
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/feeds/{feed_id}/items": {
   "parameters": [
    {
     "name": "feed_id",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string"
     },
     "description": "f_..."
    }
   ],
   "post": {
    "operationId": "addItems",
    "summary": "Add items",
    "security": [
     {
      "editKey": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "items": {
          "type": "array",
          "items": {
           "oneOf": [
            {
             "$ref": "#/components/schemas/CalendarItem"
            },
            {
             "$ref": "#/components/schemas/RssItem"
            }
           ]
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Added"
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/v1/feeds/{feed_id}/items/{item_id}": {
   "parameters": [
    {
     "name": "feed_id",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string"
     },
     "description": "f_..."
    },
    {
     "name": "item_id",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string"
     },
     "description": "i_..."
    }
   ],
   "patch": {
    "operationId": "updateItem",
    "summary": "Change some fields of one item (null removes a field)",
    "security": [
     {
      "editKey": []
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/CalendarItem"
         },
         {
          "$ref": "#/components/schemas/RssItem"
         }
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Updated"
     },
     "400": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "delete": {
    "operationId": "deleteItem",
    "summary": "Remove one item",
    "security": [
     {
      "editKey": []
     }
    ],
    "responses": {
     "200": {
      "description": "Deleted"
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/f/{file}": {
   "parameters": [
    {
     "name": "file",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string"
     },
     "description": "{feed_id}.ics or {feed_id}.xml"
    }
   ],
   "get": {
    "operationId": "getFeedFile",
    "summary": "Subscriber file (text/calendar or RSS)",
    "responses": {
     "200": {
      "description": "ICS or RSS"
     },
     "404": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": []
   }
  },
  "/v1/report": {
   "post": {
    "operationId": "reportFeed",
    "summary": "Report abuse",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "feed_id"
        ],
        "properties": {
         "feed_id": {
          "type": "string"
         },
         "reason": {
          "type": "string",
          "enum": [
           "spam",
           "phishing",
           "illegal",
           "other"
          ]
         },
         "note": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "Received"
     }
    },
    "security": []
   }
  }
 },
 "components": {
  "securitySchemes": {
   "editKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "The edit_key from the create response (ek_...)"
   }
  },
  "schemas": {
   "CalendarItem": {
    "type": "object",
    "required": [
     "title",
     "start"
    ],
    "properties": {
     "title": {
      "type": "string",
      "maxLength": 300
     },
     "start": {
      "type": "string",
      "description": "Local time YYYY-MM-DDTHH:MM in tz, or YYYY-MM-DD for an all-day event"
     },
     "end": {
      "type": "string",
      "description": "Same format as start. All-day: the last day, inclusive"
     },
     "tz": {
      "type": "string",
      "description": "IANA time zone, e.g. America/Toronto (or set it once on the feed)"
     },
     "rrule": {
      "type": "string",
      "description": "RFC 5545 repeat rule, e.g. FREQ=WEEKLY;BYDAY=MO;UNTIL=20270329"
     },
     "skip": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Dates YYYY-MM-DD to leave out of the repeat"
     },
     "location": {
      "type": "string"
     },
     "description": {
      "type": "string"
     }
    }
   },
   "RssItem": {
    "type": "object",
    "required": [
     "title"
    ],
    "properties": {
     "title": {
      "type": "string"
     },
     "link": {
      "type": "string",
      "format": "uri"
     },
     "content": {
      "type": "string"
     },
     "date": {
      "type": "string",
      "description": "ISO 8601"
     }
    }
   },
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     },
     "docs": {
      "type": "string"
     }
    }
   }
  }
 }
}
