iMessagePlex

Getting Started

Welcome to the iMessagePlex documentation! Follow these steps to set up and manage your contact form.

1. Set Up a Form

This is the most basic way to create a contact form for sending messages.

    
      
<!-- index.html -->
<div class="contact-form">
    <form id="contact-form" onsubmit="">
      <input id="name" name="name" type="text" placeholder="Enter Your Name" required>
      <input id="email" name="email" type="email" placeholder="Enter Your Email" required>
      <textarea id="message" name="message" cols="40" rows="5" placeholder="Enter Your Message" required></textarea>
      <input  type="submit" value="Submit" class="send">
    </form>
</div>
     
  

2. Handle the Form with JavaScript

Handle form data using JavaScript to send an HTTP POST request to the server.

Required Body JSON

POST: https://imessageplex.com/en/user/message/{YOUR_USERNAME}

"apiKey": string
"name": string (3-100 characters)
"email": string (3-100 characters)
"message": string (3-3000 characters)

Obtain your API key from your account dashboard. If forgotten, you must generate a new key, which will revoke the previous one, so proceed with caution.

Responses

200: Successfully sent the message
400: Bad request (Received incorrect request body)
401: Incorrect API Key

Example

    
      
// main.js
const form = document.getElementById('contact-form');

form.addEventListener('submit', async (event) => {
  event.preventDefault();

  const name = document.getElementById('name').value;
  const email = document.getElementById('email').value;
  const message = document.getElementById('message').value;

  const url = 'https://imessageplex.com/en/user/message/{YOUR_USERNAME}';

  const response = await fetch(url, {
    method: 'POST',
    body: JSON.stringify({
      name,
      email,
      message,
      apiKey: {YOUR_API_KEY (Make sure to hide this with ENV)},
    }),
  });

  if (response.ok) {
    alert('Message was sent successfully!');
  }
});