Developers
Form API for website enquiries
Save form submissions from any website or system as contacts in Miaalo. Two endpoints, two keys.
API access is switched on by request through [email protected]. Phone numbers must be Indian mobile numbers.
Basics
Base URL:
https://miaalo.com/api
- Send
POSTrequests with a JSON body (Content-Type: application/json) or as normal form fields. - Every response is JSON with a
statusfield:1means success,-1means failure. - Cross-origin requests are allowed, so a browser on your own website can call the API directly.
Concepts. A contact is a person who contacted your business. A source is a list of contacts from one place (a website form, a batch, an event). A contact is identified by phone number and can belong to several sources.
API keys
Log in and open the API keys page to see both kinds of key.
| User key (private) | Source API key (public) | |
|---|---|---|
| Belongs to | Your account | One or more of your sources |
| Can do | Create sources and get their keys | Add contacts to its sources only |
| Where to use | Your server only | Website forms, browser code, apps |
| Request field | user_key | api_key |
| How you get it | Created with your account | From the API keys page, or returned by create-group |
Keep the user key secret. Anyone who has it can create sources in your account. Never put it in HTML, JavaScript or a mobile app. The source API key is safe to publish, because it can only add contacts to its own sources.
POST /api/save-number
Saves a contact and adds it to every source linked to the source API key.
Fields
| Field | Required | Notes |
|---|---|---|
api_key | Yes | Your public source API key |
name | Yes | Contact's name |
phone | Yes | 10-digit Indian mobile number. A +91, 91 or 0 prefix and spaces are accepted. |
email | No | Contact's email address |
Example
curl -X POST https://miaalo.com/api/save-number \
-H "Content-Type: application/json" \
-d '{"api_key":"YOUR_GROUP_KEY","name":"Aarav Sharma","phone":"9876543210","email":"[email protected]"}'
{ "status": 1, "data": { "message": "Success" } }
If a contact with the same phone number already exists in your account, no duplicate is created. The existing contact is added to the key's sources.
Website form example
Paste this into any page. Replace YOUR_GROUP_KEY with the source API key for this form.
<form id="enquiry">
<input name="name" placeholder="Your name" required>
<input name="phone" placeholder="Mobile number" required>
<input name="email" type="email" placeholder="Email (optional)">
<button>Send enquiry</button>
<p id="enquiry-msg"></p>
</form>
<script>
document.getElementById("enquiry").addEventListener("submit", async (e) => {
e.preventDefault();
const data = Object.fromEntries(new FormData(e.target));
data.api_key = "YOUR_GROUP_KEY";
const res = await fetch("https://miaalo.com/api/save-number", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
}).then(r => r.json());
document.getElementById("enquiry-msg").textContent =
res.status === 1 ? "Thanks! We will get back to you." : res.data.message;
if (res.status === 1) e.target.reset();
});
</script>
Each submission appears in Contacts and in the source's contact list right away.
POST /api/create-group
Creates a source in your account and returns its source API key. Call it from your server, because it needs your private user key.
Paid plans only. On the free plan this endpoint returns an error. Create sources in Miaalo instead, or upgrade and the Miaalo team will set up your user key.
Fields
| Field | Required | Notes |
|---|---|---|
user_key | Yes | Your private user key |
group_name | Yes | Name of the source, for example Website enquiry |
group_type | No | P for a private source (default). Any other value makes the source public, so people can join it from your sign-up page. |
Example
curl -X POST https://miaalo.com/api/create-group \
-H "Content-Type: application/json" \
-d '{"user_key":"YOUR_USER_KEY","group_name":"Website enquiry"}'
{ "status": 1, "key": "aB3dE5fG7h", "data": { "message": "Success" } }
The key is the source API key. Use it as api_key in
save-number. Calling create-group again with the same name returns the
same source and key, so it is safe to retry.
Responses and errors
Check the status field, not the HTTP code. On failure, data.message says why:
| Endpoint | Message | Fix |
|---|---|---|
| save-number | Name is required filed | Send name |
| save-number | Phone number is required filed | Send phone |
| save-number | Invalid phone number | Use a 10-digit Indian mobile number |
| save-number | api_key is required filed | Send api_key |
| save-number | invalid api_key | Check the key on the API keys page |
| save-number | Group not found | Link the key to at least one source |
| create-group | User Key is missing / Invalid User Key | Send your correct private user key |
| create-group | Group name is missing | Send group_name |
| create-group | Creating sources with the user key is a paid feature… | Upgrade your plan |
Verified leads (optional)
Set it up in 3 steps
- Turn the setting on for the source: Accept only verified leads (optional) on the source's Create or Edit page.
- Add a code step to your form: a Send code button that calls
send-otp, then a 6-digit code box and a Verify and send button. - Send
otpwithsave-number: the code the lead typed.
The setting has three choices:
- WhatsApp: the lead proves the phone number with a code sent on WhatsApp.
- Email: the lead proves the email address with a code sent by email.
- Both: the lead proves both.
When any source behind the API key has this on, the form needs two steps. Sources without the option don't change: otp is ignored.
Step 1: send the code POST
POST https://miaalo.com/api/send-otp with api_key, phone and email. email is required when the source needs email verification.
Sends a 6-digit code to the lead on WhatsApp and/or email. Success:
{ "status": 1, "data": { "message": "Code sent", "channels": ["whatsapp"] } }
| HTTP | Meaning |
|---|---|
422 | Invalid api_key or phone number, missing or invalid email, or the form does not need a code |
429 | Too many codes. Limit is 1 per minute and 5 per hour for each number. |
502 | The WhatsApp message could not be sent. Check the phone number. |
503 | Verification is not available right now. |
Errors use the body {"status":-1,"data":{"message":"..."}}.
Step 2: save the lead with the code POST
Send POST https://miaalo.com/api/save-number as before, and add otp (the 6-digit code). If email verification is on, send the same email you sent in step 1.
- The code is valid for 10 minutes, works once, and allows 5 wrong tries.
- A missing or wrong code returns 422. The lead is not saved.
Error messages
Every error uses the body {"status":-1,"data":{"message":"..."}}. Show data.message to the lead.
A number that is already in the source returns {"status":1,"data":{"message":"Updated"}}. The saved name, email and message are replaced with the new ones. No second contact is made and no lead alert is sent.
| HTTP | Message | What to do |
|---|---|---|
422 | This form does not need a verification code. | Send send-otp only for sources with this setting on. Or turn the setting on. |
422 | A valid email is required for this form | The source checks email. Send a valid email in both steps. |
422 | Invalid phone number | Check the number. It must be an Indian mobile number. |
422 | invalid api_key | Check that you copied the source key correctly. |
422 | Group not found | The key has no source to save the lead to. Check the source in Miaalo. |
422 | Verification code is required. Send the code with send-otp first. | Call send-otp first, then send otp with save-number. |
422 | Wrong code. N tries left. | The lead is not saved. Ask the lead to check the code and try again. |
422 | Too many wrong codes. Ask for a new code. | Call send-otp again for a new code. |
422 | This code has expired or was never sent. Ask for a new code. | Codes last 10 minutes and work once. Call send-otp again. |
422 | This code was sent to a different address. Ask for a new code. | The email changed after the code was sent. Send the same email in both steps, or ask for a new code. |
429 | Too many codes requested. Try again in N minute(s). | Wait for the time shown, then try again. |
429 | Too many codes requested from your network. Try again later. | Limit is 5 codes per hour for each IP address, across all forms. Wait, then try again. |
429 | Too many codes were sent to this number or email. Try again later. | Limit is 5 codes per hour for each phone number or email, across all forms. Wait, then try again. |
502 | We could not send the code on WhatsApp. Check the phone number. | Check the phone number, then try again. |
503 | Verification is not available right now. | Try again later. |
Sending limit: 1 code per minute and 5 codes per hour for each phone number.
JavaScript (browser)
// Step 1: send the code, then show a code input to the lead
async function sendCode(apiKey, phone, email) {
const res = await fetch("https://miaalo.com/api/send-otp", {
method: "POST",
headers: { "Content-Type": "application/json", "Accept": "application/json" },
body: JSON.stringify({ api_key: apiKey, phone: phone, email: email })
}).then(r => r.json());
if (res.status !== 1) console.error(res.data.message);
return res.status === 1;
}
// Step 2: save the lead with the code the lead typed in
async function saveLead(apiKey, lead, code) {
const res = await fetch("https://miaalo.com/api/save-number", {
method: "POST",
headers: { "Content-Type": "application/json", "Accept": "application/json" },
body: JSON.stringify({ api_key: apiKey, name: lead.name, phone: lead.phone, email: lead.email, otp: code })
}).then(r => r.json());
if (res.status !== 1) console.error(res.data.message);
return res.status === 1;
}
Full example: two-step form (HTML + JavaScript)
Use this on a page of your website. Replace YOUR_API_KEY with your source key. Keep the field names.
<form id="enquiry">
<input name="name" required placeholder="Your name">
<input name="phone" required inputmode="numeric" placeholder="10-digit mobile number">
<input name="email" type="email" placeholder="Email">
<textarea name="message" placeholder="Message (optional)"></textarea>
<button type="button" id="send-code">Send code</button>
</form>
<div id="code-step" hidden>
<p>Enter the 6-digit code we sent to you.</p>
<input id="code" inputmode="numeric" maxlength="6" placeholder="6-digit code">
<button type="button" id="verify">Verify and send</button>
</div>
<p id="result" role="status"></p>
<script>
const API_KEY = "YOUR_API_KEY";
const API_BASE = "https://miaalo.com/api";
const form = document.getElementById("enquiry");
const codeStep = document.getElementById("code-step");
const result = document.getElementById("result");
// Read the visitor's fields from the form
function getLead() {
const data = Object.fromEntries(new FormData(form));
return { name: data.name, phone: data.phone, email: data.email || "", message: data.message || "" };
}
// POST JSON to the API and return the parsed reply
async function post(path, body) {
const res = await fetch(API_BASE + path, {
method: "POST",
headers: { "Content-Type": "application/json", "Accept": "application/json" },
body: JSON.stringify({ api_key: API_KEY, ...body })
});
return res.json();
}
// Step 1: send the code. If the lead changes the phone or email, send a new code.
document.getElementById("send-code").addEventListener("click", async () => {
if (!form.reportValidity()) return; // name and phone are required
const lead = getLead();
const res = await post("/send-otp", { phone: lead.phone, email: lead.email });
if (res.status !== 1) {
result.textContent = res.data.message;
return;
}
codeStep.hidden = false;
result.textContent = "Code sent. Enter it below.";
});
// Step 2: save the lead with the code the lead typed
document.getElementById("verify").addEventListener("click", async () => {
const lead = getLead();
const res = await post("/save-number", {
name: lead.name,
phone: lead.phone,
email: lead.email,
message: lead.message,
otp: document.getElementById("code").value.trim()
});
if (res.status !== 1) {
result.textContent = res.data.message;
return;
}
form.hidden = true;
codeStep.hidden = true;
result.textContent = "Thanks. We will call you soon.";
});
</script>
WordPress
Easiest: Miaalo Connector plugin (no code)
Install the free Miaalo Connector plugin and connect your forms in a few clicks.
- In WordPress, go to Plugins > Add New Plugin, search for Miaalo Connector, click Install Now, then Activate.
- Go to Settings > Miaalo Connector.
- In URL Endpoint, paste
https://miaalo.com/api/save-number. In API Key, paste your source key (copy it from API Keys in Miaalo). - Choose All Forms (sends name, phone, email and message from every form), or pick one form. Click Fetch & Auto-Map, check the mapping, then click Save All Settings.
- Test it: open the Activity Log & Test tab and click Send Test Submission. The test lead appears in your source in Miaalo.
Works with WPForms, Contact Form 7, Elementor Pro Forms, Gravity Forms, Fluent Forms, Forminator and Divi Contact Form.
View the Miaalo Connector plugin page · Read the full guide
Prefer code, or use the WPForms webhook addon? Use the options below. Download the step-by-step PDF guide to share with your web developer.
Option A: code snippet for developers (free WPForms Lite)
The API key stays on your server and never shows in the page source.
- Install the free Code Snippets plugin (or use your child theme's
functions.php). - Add a new snippet, paste the code below and set it to Run everywhere.
- Replace
123with your WPForms form ID,1–4with the field IDs of Name, Phone, Email and Message (form builder > field > Advanced > ID), andYOUR_API_KEYwith your key. - Save and activate, then submit a test enquiry.
add_action( 'wpforms_process_complete', function (
$fields, $entry, $form_data, $entry_id
) {
if ( (int) $form_data['id'] !== 123 ) { // your WPForms form ID
return;
}
$name = $fields[1]['value'] ?? '';
$phone = preg_replace( '/\D/', '', $fields[2]['value'] ?? '' );
$email = $fields[3]['value'] ?? '';
$msg = $fields[4]['value'] ?? ''; // optional message field
wp_remote_post( 'https://miaalo.com/api/save-number', [
'headers' => [ 'Content-Type' => 'application/json' ],
'body' => wp_json_encode( [
'api_key' => 'YOUR_API_KEY',
'name' => $name,
'phone' => $phone,
'email' => $email,
'message' => $msg,
] ),
'timeout' => 10,
] );
}, 10, 4 );
Option B: WPForms Webhooks addon (Elite plan)
- Open your form > Settings > Webhooks and add a webhook.
- Request URL:
https://miaalo.com/api/save-number. Method POST, format JSON. - Request body: map
name,phone,email(and optionallymessage) to your form fields, and addapi_keywith your key.
Sources set to Accept only verified leads need the two-step code flow above, which WPForms can't do. Use a source without that setting for WPForms.
Public vs private sources
Every source is either private (only you add contacts, by hand, import or website form) or public (people can also join it themselves from your join link). This video shows the difference and when to use each.