{
    "info": {
        "_postman_id": "wa-api-v1-collection",
        "name": "WhatsApp API v1",
        "description": "Complete API collection for sending WhatsApp template messages via third-party API with App Key authentication.",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        "_exporter_id": "wa-app"
    },
    "item": [
        {
            "name": "Authentication",
            "item": [
                {
                    "name": "Test Authentication",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "X-App-Key",
                                "value": "{{app_key}}",
                                "type": "text"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{app_secret}}",
                                "type": "text"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/templates",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "templates"
                            ]
                        },
                        "description": "Test if your App Key and Secret are valid by fetching templates."
                    },
                    "response": []
                }
            ],
            "description": "Authentication is done via X-App-Key and X-App-Secret headers. All endpoints require these headers."
        },
        {
            "name": "Templates",
            "item": [
                {
                    "name": "Get All Templates",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "X-App-Key",
                                "value": "{{app_key}}",
                                "type": "text"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{app_secret}}",
                                "type": "text"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/templates",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "templates"
                            ]
                        },
                        "description": "Retrieve a list of all approved templates available for your account. Returns template names, variables, and metadata."
                    },
                    "response": [
                        {
                            "name": "Success Response",
                            "originalRequest": {
                                "method": "GET",
                                "header": [],
                                "url": {
                                    "raw": "{{base_url}}/templates",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "templates"
                                    ]
                                }
                            },
                            "status": "OK",
                            "code": 200,
                            "_postman_previewlanguage": "json",
                            "header": [
                                {
                                    "key": "Content-Type",
                                    "value": "application/json"
                                }
                            ],
                            "cookie": [],
                            "body": "{\n    \"success\": true,\n    \"data\": {\n        \"templates\": [\n            {\n                \"name\": \"welcome_message\",\n                \"display_name\": \"Welcome Message\",\n                \"category\": \"MARKETING\",\n                \"language\": \"en\",\n                \"header_type\": \"TEXT\",\n                \"body_text\": \"Hello {{name}}, welcome to our service!\",\n                \"footer_text\": \"Thank you for joining us.\",\n                \"variables\": [\n                    {\n                        \"component\": \"BODY\",\n                        \"position\": 1,\n                        \"name\": \"name\"\n                    }\n                ],\n                \"created_at\": \"2024-01-15T10:30:00.000Z\"\n            }\n        ],\n        \"total\": 1\n    }\n}"
                        }
                    ]
                }
            ],
            "description": "Endpoints for managing and retrieving WhatsApp message templates."
        },
        {
            "name": "Messages",
            "item": [
                {
                    "name": "Send Template Message",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "X-App-Key",
                                "value": "{{app_key}}",
                                "type": "text"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{app_secret}}",
                                "type": "text"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "type": "text"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"to\": \"+1234567890\",\n    \"template_name\": \"welcome_message\",\n    \"template_language\": \"en\",\n    \"variables\": {\n        \"name\": \"John Doe\"\n    }\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "url": {
                            "raw": "{{base_url}}/messages/send",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "messages",
                                "send"
                            ]
                        },
                        "description": "Send a WhatsApp template message to a specified phone number. The phone number must be in E.164 format (e.g., +1234567890).\n\nRequired fields:\n- `to`: Recipient phone number\n- `template_name`: Name of approved template\n- `template_language`: Language code (en or ar)\n- `variables`: Object with template variable values"
                    },
                    "response": [
                        {
                            "name": "Success Response",
                            "originalRequest": {
                                "method": "POST",
                                "header": [],
                                "body": {
                                    "mode": "raw",
                                    "raw": "{\n    \"to\": \"+1234567890\",\n    \"template_name\": \"welcome_message\",\n    \"template_language\": \"en\",\n    \"variables\": {\n        \"name\": \"John Doe\"\n    }\n}",
                                    "options": {
                                        "raw": {
                                            "language": "json"
                                        }
                                    }
                                },
                                "url": {
                                    "raw": "{{base_url}}/messages/send",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "messages",
                                        "send"
                                    ]
                                }
                            },
                            "status": "OK",
                            "code": 200,
                            "_postman_previewlanguage": "json",
                            "header": [
                                {
                                    "key": "Content-Type",
                                    "value": "application/json"
                                }
                            ],
                            "cookie": [],
                            "body": "{\n    \"success\": true,\n    \"message\": \"Template message sent successfully\",\n    \"data\": {\n        \"message_id\": \"wamid.HBgLMTIzNDU2Nzg5MAVCABEYEjQzRjA0QjBDOTREQTk0MkYwNwA=\",\n        \"to\": \"+1234567890\",\n        \"template_name\": \"welcome_message\",\n        \"status\": \"sent\",\n        \"timestamp\": \"2024-01-15T10:30:00.000Z\"\n    }\n}"
                        }
                    ]
                },
                {
                    "name": "Get Message Status",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "X-App-Key",
                                "value": "{{app_key}}",
                                "type": "text"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{app_secret}}",
                                "type": "text"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/messages/status?message_id={{message_id}}",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "messages",
                                "status"
                            ],
                            "query": [
                                {
                                    "key": "message_id",
                                    "value": "{{message_id}}",
                                    "description": "The message ID returned from /messages/send endpoint"
                                }
                            ]
                        },
                        "description": "Check the delivery status of a specific message. Possible statuses:\n- `sent`: Message was sent successfully\n- `delivered`: Message was delivered to recipient\n- `read`: Message was read by recipient\n- `failed`: Message delivery failed"
                    },
                    "response": [
                        {
                            "name": "Success Response",
                            "originalRequest": {
                                "method": "GET",
                                "header": [],
                                "url": {
                                    "raw": "{{base_url}}/messages/status?message_id=wamid.HBgLMTIzNDU2Nzg5MAVCABEYEjQzRjA0QjBDOTREQTk0MkYwNwA=",
                                    "host": [
                                        "{{base_url}}"
                                    ],
                                    "path": [
                                        "messages",
                                        "status"
                                    ],
                                    "query": [
                                        {
                                            "key": "message_id",
                                            "value": "wamid.HBgLMTIzNDU2Nzg5MAVCABEYEjQzRjA0QjBDOTREQTk0MkYwNwA="
                                        }
                                    ]
                                }
                            },
                            "status": "OK",
                            "code": 200,
                            "_postman_previewlanguage": "json",
                            "header": [
                                {
                                    "key": "Content-Type",
                                    "value": "application/json"
                                }
                            ],
                            "cookie": [],
                            "body": "{\n    \"success\": true,\n    \"data\": {\n        \"message_id\": \"wamid.HBgLMTIzNDU2Nzg5MAVCABEYEjQzRjA0QjBDOTREQTk0MkYwNwA=\",\n        \"status\": \"delivered\",\n        \"timestamp\": \"1705315800\",\n        \"message_type\": \"template\",\n        \"created_at\": \"2024-01-15T10:30:00.000Z\",\n        \"updated_at\": \"2024-01-15T10:30:05.000Z\"\n    }\n}"
                        }
                    ]
                }
            ],
            "description": "Endpoints for sending messages and checking their status."
        }
    ],
    "event": [
        {
            "listen": "prerequest",
            "script": {
                "type": "text/javascript",
                "exec": [
                    ""
                ]
            }
        },
        {
            "listen": "test",
            "script": {
                "type": "text/javascript",
                "exec": [
                    ""
                ]
            }
        }
    ],
    "variable": [
        {
            "key": "base_url",
            "value": "https://your-domain.com/api/v1",
            "type": "string"
        },
        {
            "key": "app_key",
            "value": "ak_live_xxxxxxxxxxxxxxxx",
            "type": "string"
        },
        {
            "key": "app_secret",
            "value": "your_secret_key_here",
            "type": "string"
        },
        {
            "key": "message_id",
            "value": "",
            "type": "string"
        }
    ]
}