POST2
Search…
Form Setup

Getting Started

The POST2 can be used with any HTML form, to get started you need to sign in into your account and create a handler.
Once the form handler was created, we have an unique ID and ready to implement.

Basic Setup

All you have to do is replace the action attribute of your existing form with the unique POST2 handler URL Example: https://api.post2.io/replace-with-your-id
1
<!-- This is a sample email capture form -->
2
<form method="POST" action="https://api.post2.io/replace-with-your-id">
3
<!-- your form code remains unchanged -->
4
<input type="email" name="email" placeholder="[email protected]" required />
5
</form>
Copied!
NOTE Set the method attribute to POST. If it's not set the default method on HTML forms is GET. POST2 only accepts HTTP POST requests.
NOTE2 Only form elements with a name attribute will have their values passed when submitting a form.

Redirect ("Thank You" page)

Using the basic setup the browser will reload the page on form submit. It display a default POST2 page with a success or error message.
You can customize the success page content in the form handler settings page.
If you want to use your own thank you page you can add the URL in the settings and the browser will redirect to that on successful submit.
NOTE the redirect option can only be used with basic setup.
NOTE 2 If using validation the browser will display the validation errors (if any) in the POST2 default layout.

Advanced Setup

To enhance the UI/UX of your forms you can submit data using AJAX without reloading the page.
1
<!-- This is a sample email capture form -->
2
<form
3
method="POST"
4
action="https://api.post2.io/replace-with-your-id"
5
id="post2-form"
6
>
7
<!-- email field -->
8
<input type="email" name="email" placeholder="[email protected]" required />
9
<!-- submit button -->
10
<button type="submit">Subscribe</button>
11
</form>
Copied!
Now the Javascript code.
1
// get the form
2
const post2Form = document.getElemetById("post2-form");
3
4
// attach the event listener
5
post2Form.addEventListener("submit", (e) => {
6
// prevent the form submission
7
e.preventDefault();
8
// get the email field
9
const emailField = post2Form.querySelector('type="email"');
10
11
// initiate the HTTP request, note we use the form handler as the endpoint
12
fetch(post2Form.getAttribute("action"), {
13
method: "POST",
14
body: JSON.stringify({
15
email: emailField.value,
16
}),
17
headers: {
18
"Content-type": "application/json; charset=UTF-8",
19
},
20
})
21
.then((response) => response.json())
22
.then((res) => {
23
if (res.error) {
24
// there was an error
25
alert(res.error);
26
} else {
27
// successful submit
28
alert("Yay! it worked");
29
}
30
})
31
.catch((err) => {
32
// something went wrong with the request, see console
33
console.error(err);
34
});
35
});
Copied!

Health Dashboard

We provide a simple dashboard to monitor your forms activity for the past 30 days.
The SPAM submissions are not counted into the total.
POST2 doesn't store any submitted data, we log just the timestamp and if it's spam or not
The stats don't include the submissions blocked by the honeypot fields or other restrictions.
Dashboard
Last modified 5mo ago