Getting Started

Learn how to integrate the Contact Form API into your application in just a few minutes.

Prerequisites

Before you begin, make sure you have:

  • An email address - Used to receive verification keys and form submissions
  • Basic knowledge of HTTP/REST APIs - Understanding of POST requests and JSON
  • A website or application - Where you want to add the contact form

Step 1: Obtain a Verification Key

Every API request requires a verification key for authentication. To get started, send a POST request to the home endpoint:

curl -X POST https://codefreeform.com/ \
  -H "Content-Type: application/json" \
  -d '{"email": "your-email@example.com"}'

Response:

{
  "success": true,
  "message": "New key generated and sent to your-email@example.com.",
  "key": "ABC123",
  "keys_count": 1
}
Your verification key will also be emailed to you. Save it securely!

Step 2: Submit Your First Contact Form

Now that you have a verification key, you can submit contact form data:

curl -X POST https://codefreeform.com/api/contact-api/ \
  -H "Content-Type: application/json" \
  -d '{
    "access_key": "ABC123",
    "email": "sender@example.com",
    "message": "Hello! This is my first submission.",
    "subject": "Test Contact Form"
  }'

Success Response:

{
  "success": true,
  "message": "Your message has been sent successfully.",
  "submission_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "attachments": 0,
  "email_status": "sent"
}
The submission will be emailed to the address associated with your verification key.

Step 3: Integrate with Your Website

Now integrate the API into your website using JavaScript:

HTML Form

<form id="contactForm">
  <input type="email" id="email" placeholder="Your Email" required>
  <input type="text" id="subject" placeholder="Subject">
  <textarea id="message" placeholder="Your Message" required></textarea>
  <button type="submit">Send Message</button>
</form>
<div id="result"></div>

JavaScript (Fetch API)

document.getElementById('contactForm').addEventListener('submit', async (e) => {
  e.preventDefault();
  
  const formData = {
    access_key: 'ABC123', // Your verification key
    email: document.getElementById('email').value,
    subject: document.getElementById('subject').value,
    message: document.getElementById('message').value
  };
  
  try {
    const response = await fetch('https://codefreeform.com/api/contact-api/', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(formData)
    });
    
    const data = await response.json();
    
    if (data.success) {
      document.getElementById('result').innerHTML = 
        '<div class="alert alert-success">' + data.message + '</div>';
      document.getElementById('contactForm').reset();
    } else {
      document.getElementById('result').innerHTML = 
        '<div class="alert alert-danger">' + data.message + '</div>';
    }
  } catch (error) {
    document.getElementById('result').innerHTML = 
      '<div class="alert alert-danger">Network error. Please try again.</div>';
  }
});

Next Steps

Authentication

Learn more about verification keys, domain restrictions, and key management.

Learn More
API Reference

Explore all available parameters, response formats, and advanced features.

View Reference
Code Examples

Browse examples in JavaScript, Python, jQuery, and more programming languages.

View Examples
Error Handling

Understand error responses and how to handle them gracefully in your application.

Learn More