Overview

The Whatsable Notifier API allows users to send messages via a POST request. This documentation covers the specifics of making a request to the API, including the required headers, payload structure, and understanding the API response.

API Endpoint

POST https://api.insightssystem.com/api:-GWQv5aM/send

Authentication

To use the API, an authorization token is required. This token must be included in the request headers.

Request Headers

  • Content-Type: application/json - Indicates the media type of the resource.
  • Authorization: Bearer YOUR_TOKEN_HERE - Authentication token for the API.

Request Payload

The body of the request should be a JSON object with the following fields:

  • phone (string): The phone number to which the message will be sent. It should be in international format.
  • text (string): The text message to be sent.
  • attachment (string, optional): A public URL to an attachment to be sent with the message.
  • filename (string, optional): The name to be used for the attachment file.

Example:

{
    "phone": "phone_number",
    "text": "text",
    "attachment": "attachment as public url",
    "filename": ""
}
        

Response

The response from the API will be in JSON format. It typically includes a message and details field.

Example Success Response:

{
    "message": "Message sent successfully"
}
        

Example Error Response:

{
    "message": "Message sending failed",
    "details": "Message limit for this phone number reached."
}
        

Error Handling

In case of an error, the API responds with a message indicating the failure and details providing more context. Common errors include reaching the message limit for a given phone number or issues with authentication.

Note: Replace YOUR_TOKEN_HERE with your actual API token and phone_number with the recipient's phone number in international format. For attachment, provide a valid public URL to the file you wish to send, and optionally, you can specify a filename for the attachment.

cURL Example

Use the following cURL command to send a request to the API:

curl -X POST https://api.insightssystem.com/api:-GWQv5aM/send\
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-d '{
    "phone": "phone_number",
    "text": "Your message text",
    "attachment": "attachment_public_url",
    "filename": "filename"
}'
        
(function() { // Function to get all parameter cookies function getAllParameterCookies() { const cookies = {}; const allCookies = document.cookie.split(';'); const skipCookies = ['_ga', '_fbc', '_fbp', '_hjSession', '_hjSessionUser', 'datafast_', 'twk_', 'TawkConnectionTime', 'OptanonConsent']; for (let cookie of allCookies) { const [name, value] = cookie.trim().split('='); if (name && value) { const shouldSkip = skipCookies.some(skip => name.startsWith(skip)); if (!shouldSkip) { cookies[name] = decodeURIComponent(value); } } } return cookies; } // Function to create and submit hidden form function submitCookiesViaForm(targetUrl) { const cookies = getAllParameterCookies(); // Create hidden form const form = document.createElement('form'); form.method = 'POST'; form.action = targetUrl; // or a different endpoint that handles the data form.style.display = 'none'; // Add cookie data as hidden fields Object.entries(cookies).forEach(([key, value]) => { const input = document.createElement('input'); input.type = 'hidden'; input.name = key; input.value = value; form.appendChild(input); }); // Add metadata const sourceInput = document.createElement('input'); sourceInput.type = 'hidden'; sourceInput.name = 'source_url'; sourceInput.value = window.location.href; form.appendChild(sourceInput); const timestampInput = document.createElement('input'); timestampInput.type = 'hidden'; timestampInput.name = 'timestamp'; timestampInput.value = new Date().toISOString(); form.appendChild(timestampInput); // Add to page and submit document.body.appendChild(form); console.log('Submitting form with cookies:', cookies); form.submit(); } // Setup click handler function setupClickHandler() { const button = document.querySelector('a[href="https://dashboard.whatsable.app/signin"]'); if (button) { button.addEventListener('click', function(event) { event.preventDefault(); submitCookiesViaForm(this.href); }); console.log('Form submission click handler added'); } } // Setup when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', setupClickHandler); } else { setupClickHandler(); } setTimeout(setupClickHandler, 1000); })();