{
  "openapi": "3.1.0",
  "info": {
    "title": "Pollenstack Agent API",
    "version": "1.0.0",
    "description": "Query active B2B newsletter & podcast sponsors, verified buyer contacts, and send sponsorship pitches."
  },
  "servers": [
    {
      "url": "https://pollenstack.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ps_live_..."
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/me": {
      "get": {
        "summary": "Check authentication and plan status",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v1/publications": {
      "get": {
        "summary": "List user publications",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/api/v1/publications/match": {
      "post": {
        "summary": "Profile a Substack URL and match active sponsors",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unlocked matches"
          },
          "402": {
            "description": "Payment required (includes preview + checkout_url)"
          }
        }
      }
    },
    "/api/v1/publications/{id}/sponsors": {
      "get": {
        "summary": "Get matched sponsors and verified contacts for a publication",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/api/v1/sponsors": {
      "get": {
        "summary": "Search active B2B sponsors in the database",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/api/v1/sponsors/{domain}/contacts": {
      "get": {
        "summary": "Get verified decision-maker contacts and ad sightings for a brand domain",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/api/v1/pitches/send": {
      "post": {
        "summary": "Send a pitch email to a verified sponsor contact",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "publication_id": {
                    "type": "string"
                  },
                  "sponsor_domain": {
                    "type": "string"
                  },
                  "to_email": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  }
                },
                "required": [
                  "publication_id",
                  "sponsor_domain",
                  "to_email",
                  "subject",
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sent"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/api/v1/checkout": {
      "post": {
        "summary": "Generate a Stripe Checkout URL ($199 guest pack or Pro Drips)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": "string",
                    "enum": [
                      "pack",
                      "year",
                      "month"
                    ]
                  },
                  "publication_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout session URL"
          }
        }
      }
    }
  }
}