{
  "openapi": "3.0.0",
  "info": {
    "title": "WAGate",
    "version": "1.0.0",
    "description": "Send approved WhatsApp templates from Salesforce Flow through WAGate."
  },
  "servers": [{ "url": "https://wagate.app" }],
  "paths": {
    "/api/messages.php": {
      "post": {
        "operationId": "sendWhatsAppTemplate",
        "summary": "Send WhatsApp template",
        "description": "Sends one of your approved templates. The number of variables must match the template.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["to", "type", "template"],
                "properties": {
                  "to": { "type": "string", "description": "Phone number in international format, e.g. +15551234567" },
                  "type": { "type": "string", "enum": ["template"], "default": "template" },
                  "template": {
                    "type": "object",
                    "required": ["name", "language"],
                    "properties": {
                      "name": { "type": "string", "description": "Exact name of an approved template" },
                      "language": { "type": "string", "description": "Template language code, e.g. en, he, fr, en_US" },
                      "variables": { "type": "array", "items": { "type": "string" }, "description": "One value per {{1}}, {{2}}… in order" }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "wamid": { "type": "string" },
                    "status": { "type": "string" }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Refused (wrong variable count, unknown template, no open window…)",
            "content": {
              "application/json": {
                "schema": { "type": "object", "properties": { "ok": { "type": "boolean" }, "error": { "type": "string" } } }
              }
            }
          }
        }
      }
    }
  }
}
