{
  "openapi": "3.0.3",
  "info": {
    "title": "PostWire API",
    "version": "0.1.0",
    "description": "The social media posting API + MCP server for AI agents. Connect an account once via OAuth, then post (and cross-post) to TikTok, YouTube, Bluesky, Telegram, Mastodon and Discord from one REST call.",
    "contact": { "email": "support@postwire.io" }
  },
  "servers": [{ "url": "https://postwire.io" }],
  "security": [{ "bearerAuth": [] }],
  "paths": {
    "/api/platforms": {
      "get": { "summary": "List supported platforms", "security": [], "responses": { "200": { "description": "OK" } } }
    },
    "/api/plans": {
      "get": { "summary": "List plans and limits", "security": [], "responses": { "200": { "description": "OK" } } }
    },
    "/api/signup": {
      "post": {
        "summary": "Create an account and get an API key (shown once)", "security": [],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["email"], "properties": { "email": { "type": "string", "format": "email" } } } } } },
        "responses": { "200": { "description": "Account + api_key" } }
      }
    },
    "/api/me": {
      "get": { "summary": "Account info, usage and connections", "responses": { "200": { "description": "OK" }, "401": { "description": "Missing/invalid API key" } } }
    },
    "/api/connect": {
      "post": {
        "summary": "Connect a credential-based platform (telegram, bluesky, mastodon, discord)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["platform", "credentials"], "properties": { "platform": { "type": "string" }, "credentials": { "type": "object" } } } } } },
        "responses": { "200": { "description": "Connected" } }
      }
    },
    "/api/oauth/{platform}/url": {
      "post": {
        "summary": "Get an OAuth authorize URL for an OAuth platform (tiktok, youtube)",
        "parameters": [{ "name": "platform", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "{ url }" } }
      }
    },
    "/api/post": {
      "post": {
        "summary": "Post (or cross-post) to one or more platforms",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PostRequest" } } } },
        "responses": { "200": { "description": "{ results: [...] }" }, "401": { "description": "Missing/invalid API key" } }
      }
    },
    "/api/post/status": {
      "get": {
        "summary": "Check the status of a created post",
        "parameters": [
          { "name": "platform", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "id", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": { "200": { "description": "{ platform, id, status }" } }
      }
    },
    "/api/connect-link": {
      "post": { "summary": "Generate a hosted connect link for an end-user (multi-tenant)", "responses": { "200": { "description": "{ url, token, expires_in }" } } }
    },
    "/api/billing/checkout": {
      "post": {
        "summary": "Start a Stripe checkout for a paid plan",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["plan"], "properties": { "plan": { "type": "string", "enum": ["starter", "pro", "agency", "scale"] } } } } } },
        "responses": { "200": { "description": "{ url }" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "pw_live_ key" }
    },
    "schemas": {
      "PostRequest": {
        "type": "object",
        "properties": {
          "platform": { "type": "string", "description": "Single platform; or use 'platforms'." },
          "platforms": { "type": "array", "items": { "type": "string" }, "description": "Cross-post to many at once, in parallel.", "example": ["tiktok", "youtube"] },
          "text": { "type": "string", "description": "Caption / description." },
          "title": { "type": "string", "description": "Title (used by YouTube)." },
          "video_url": { "type": "string", "description": "URL of the video to post (required for TikTok/YouTube)." },
          "photo_url": { "type": "string" },
          "privacy": { "type": "string", "description": "e.g. private | public | unlisted (YouTube)." }
        }
      }
    }
  }
}
