{
  "openapi": "3.0.3",
  "info": {
    "title": "Web2Application Push Connector API",
    "version": "1.0.0",
    "description": "Limited public API for sending push notifications from Lovable, Base44, Make, and Zapier. Authenticate with a connector API key created in your Web2Application dashboard. Do not use Firebase keys or WordPress secrets here."
  },
  "servers": [
    {
      "url": "https://web2application.com/w2a/integrations/v1"
    }
  ],
  "security": [
    {
      "ConnectorApiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ConnectorApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Connector key from Web2Application → your app → Integration / API keys (starts with w2a_live_). Never put this key in frontend code or VITE_ variables."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": false },
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" }
            }
          }
        }
      },
      "PushMessage": {
        "type": "object",
        "required": ["title", "body"],
        "properties": {
          "title": { "type": "string", "maxLength": 120 },
          "body": { "type": "string", "maxLength": 500 },
          "link": { "type": "string", "format": "uri", "maxLength": 2000 },
          "image_url": { "type": "string", "format": "uri", "maxLength": 2000 }
        }
      }
    }
  },
  "paths": {
    "/me.php": {
      "get": {
        "operationId": "getConnectedApp",
        "summary": "Get connected app",
        "description": "Returns the app bound to this connector key. Use to verify the connection.",
        "responses": {
          "200": {
            "description": "Connected app summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "app_id": { "type": "integer" },
                        "app": {
                          "type": "object",
                          "properties": {
                            "id": { "type": "integer" },
                            "name": { "type": "string" },
                            "website_url": { "type": "string" },
                            "api_enabled": { "type": "boolean" }
                          }
                        },
                        "key_name": { "type": "string" },
                        "scopes": {
                          "type": "array",
                          "items": { "type": "string" }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    },
    "/push/user.php": {
      "post": {
        "operationId": "sendPersonalPush",
        "summary": "Send personal push",
        "description": "Send a push to one customer email already linked to a device in the app. If the email has no device, the API may return soft success with skipped=true.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  { "$ref": "#/components/schemas/PushMessage" },
                  {
                    "type": "object",
                    "required": ["email"],
                    "properties": {
                      "email": { "type": "string", "format": "email" }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "push_id": { "type": "integer" },
                        "email": { "type": "string" },
                        "app_id": { "type": "integer" },
                        "delivered": { "type": "boolean" },
                        "skipped": { "type": "boolean" },
                        "devices": { "type": "integer" },
                        "reason": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    },
    "/push/broadcast.php": {
      "post": {
        "operationId": "sendBroadcastPush",
        "summary": "Send broadcast push",
        "description": "Send a push to all devices of the connected app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PushMessage" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "push_id": { "type": "integer" },
                        "app_id": { "type": "integer" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/push/emails.php": {
      "post": {
        "operationId": "sendPushToEmails",
        "summary": "Send push to multiple emails",
        "description": "Send a personal push to up to 50 emails. Missing devices are skipped without failing the whole request.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  { "$ref": "#/components/schemas/PushMessage" },
                  {
                    "type": "object",
                    "required": ["emails"],
                    "properties": {
                      "emails": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 50,
                        "items": { "type": "string", "format": "email" }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "app_id": { "type": "integer" },
                        "sent": { "type": "array", "items": { "type": "object" } },
                        "skipped": { "type": "array", "items": { "type": "object" } },
                        "failed": { "type": "array", "items": { "type": "object" } }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
