{
  "openapi": "3.0.0",
  "info": {
    "title": "Notifyer System API",
    "description": "Notifyer System API Documentation - A comprehensive API for sending WhatsApp messages and managing templates",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.insightssystem.com",
      "description": "Notifyer System API"
    }
  ],
  "paths": {
    "/api:AFRA_QCy/get_templates": {
      "get": {
        "summary": "Get Templates",
        "description": "Retrieve a list of all templates associated with your account",
        "operationId": "getTemplates",
        "tags": ["Templates"],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Template"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - Account does not have access to templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "cURL",
            "source": "curl -X GET \\\n  'https://api.insightssystem.com/api:AFRA_QCy/get_templates' \\\n  -H 'Content-Type: application/json' \\\n  -H 'Authorization: Bearer YOUR_API_KEY'"
          }
        ]
      }
    },
    "/api:hFrjh8a1/send_template_message_by_api": {
      "post": {
        "summary": "Send Template Message",
        "description": "Send a template-based message to users via their phone numbers",
        "operationId": "sendTemplateMessage",
        "tags": ["Templates"],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateMessageRequest"
              },
              "examples": {
                "withVariablesAndMedia": {
                  "value": {
                    "template": "f10695a9-38d6-4f5f-8444-1f7bf52c6164",
                    "variables": {
                      "body1": "Axel",
                      "body2": "Shampoo",
                      "body3": "$1",
                      "media": "https://drive.google.com/file/d/1D35uTbceRPmCgwxVfBJZ2yxD2lQgs0bi/view?usp=sharing",
                      "visit_website": "1"
                    },
                    "phone_number": "+123476529999"
                  }
                },
                "singleVariable": {
                  "value": {
                    "template": "b65081ed-a0f6-4aaf-b148-31719b5bc567",
                    "variables": {
                      "body1": "Edith Mireles"
                    },
                    "phone_number": "+123476529999"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message sent successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMessageResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "cURL",
            "source": "curl -X POST \\\n  'https://api.insightssystem.com/api:hFrjh8a1/send_template_message_by_api' \\\n  -H 'Content-Type: application/json' \\\n  -H 'Authorization: Bearer YOUR_API_KEY' \\\n  -d '{\n    \"template\": \"f10695a9-38d6-4f5f-8444-1f7bf52c6164\",\n    \"variables\": {\n      \"body1\": \"Axel\",\n      \"body2\": \"Shampoo\",\n      \"body3\": \"$1\",\n      \"media\": \"https://drive.google.com/file/d/1D35uTbceRPmCgwxVfBJZ2yxD2lQgs0bi/view?usp=sharing\"\n    },\n    \"phone_number\": \"123476529999\"\n  }'"
          },
          {
            "lang": "JavaScript",
            "source": "const fetch = require(\"node-fetch\");\n\nasync function sendMessage() {\n  const response = await fetch(\n    \"https://api.insightssystem.com/api:hFrjh8a1/send_template_message_by_api\",\n    {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Authorization: \"Bearer YOUR_API_KEY\",\n      },\n      body: JSON.stringify({\n        template: \"f10695a9-38d6-4f5f-8444-1f7bf52c6164\",\n        variables: {\n          body1: \"Axel\",\n          body2: \"Shampoo\",\n          body3: \"$1\",\n          media: \"https://drive.google.com/file/d/1D35uTbceRPmCgwxVfBJZ2yxD2lQgs0bi/view?usp=sharing\",\n        },\n        phone_number: \"123476529999\",\n      }),\n    }\n  );\n  const data = await response.json();\n  console.log(data);\n}\n\nsendMessage();"
          },
          {
            "lang": "Go",
            "source": "package main\n\nimport (\n    \"bytes\"\n    \"encoding/json\"\n    \"fmt\"\n    \"net/http\"\n)\n\ntype RequestBody struct {\n    Template    string            `json:\"template\"`\n    Variables   map[string]string `json:\"variables\"`\n    PhoneNumber string            `json:\"phone_number\"`\n}\n\nfunc main() {\n    requestBody := RequestBody{\n        Template: \"f10695a9-38d6-4f5f-8444-1f7bf52c6164\",\n        Variables: map[string]string{\n            \"body1\": \"Axel\",\n            \"body2\": \"Shampoo\",\n            \"body3\": \"$1\",\n            \"media\": \"https://drive.google.com/file/d/1D35uTbceRPmCgwxVfBJZ2yxD2lQgs0bi/view?usp=sharing\"\n        },\n        PhoneNumber: \"123476529999\",\n    }\n\n    jsonData, _ := json.Marshal(requestBody)\n    resp, err := http.Post(\"https://api.insightssystem.com/api:hFrjh8a1/send_template_message_by_api\", \"application/json\", bytes.NewBuffer(jsonData))\n    if err != nil {\n        fmt.Println(\"Error:\", err)\n        return\n    }\n    defer resp.Body.Close()\n    fmt.Println(\"Response Status:\", resp.Status)\n}"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your Notifyer System API Token"
      }
    },
    "schemas": {
      "Template": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The unique identifier for the template"
          },
          "user_id": {
            "type": "string",
            "format": "uuid",
            "description": "UUID of the user who owns the template"
          },
          "name": {
            "type": "string",
            "description": "Descriptive name of the template"
          },
          "category": {
            "type": "string",
            "description": "Category of the template (e.g., MARKETING, UTILITY)"
          },
          "type": {
            "type": "string",
            "description": "The type of template (e.g., text)"
          },
          "language": {
            "type": "string",
            "description": "Language code of the template (e.g., en, en_US)"
          },
          "status": {
            "type": "string",
            "description": "Approval status of the template (e.g., APPROVED, REJECTED)"
          },
          "variable_counts": {
            "type": "integer",
            "description": "Number of variable placeholders in the template"
          },
          "template_formate": {
            "type": "string",
            "description": "Format string showing variable placement (e.g., [b:7])"
          },
          "template_id": {
            "type": "string",
            "format": "uuid",
            "description": "UUID of the template"
          }
        }
      },
      "TemplateMessageRequest": {
        "type": "object",
        "required": ["template", "variables", "phone_number"],
        "properties": {
          "template": {
            "type": "string",
            "format": "uuid",
            "description": "The unique template ID used for sending the message"
          },
          "variables": {
            "type": "object",
            "description": "A JSON object containing dynamic placeholders for the message template. The keys should match the variables in your template. Common variable keys include:\n- body1, body2, body3: Text variables for message content\n- media: URL for image, video, or document attachments\n- visit_website: URL's parameter for the dynamic button link",
            "additionalProperties": {
              "type": "string",
              "description": "Value for the template variable"
            }
          },
          "phone_number": {
            "type": "string",
            "description": "The recipient's phone number in international format (e.g., +123476529999)"
          }
        }
      },
      "TemplateMessageResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Indicates if the message was sent successfully"
          },
          "whatsapp_response_info": {
            "type": "object",
            "properties": {
              "contacts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "input": {
                      "type": "string",
                      "description": "The input phone number"
                    },
                    "wa_id": {
                      "type": "string",
                      "description": "The WhatsApp ID"
                    }
                  }
                }
              },
              "messages": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The WhatsApp message ID"
                    },
                    "message_status": {
                      "type": "string",
                      "description": "The status of the message"
                    }
                  }
                }
              },
              "messaging_product": {
                "type": "string",
                "description": "The messaging product (e.g., whatsapp)"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Error code"
              },
              "message": {
                "type": "string",
                "description": "Error message"
              }
            }
          }
        }
      }
    }
  }
} 