Once you have created a form, you can use the API to submit entries. Here's an example using JavaScript:
const submitFormEntry = async (formId, apiKey, formData) => {
const response = await fetch(`https://4mform.tech/api/forms/${formId}/entries`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify(formData)
});
if (!response.ok) {
throw new Error('Failed to submit form entry');
}
return await response.json();
};
// Example usage
const formId = 'your-form-id';
const apiKey = 'your-api-key';
const formData = {
name: 'John Doe',
email: 'john@example.com',
message: 'Hello, world!'
};
submitFormEntry(formId, apiKey, formData)
.then(result => console.log('Form entry submitted:', result))
.catch(error => console.error('Error:', error));
Remember to replace 'your-form-id' and 'your-api-key' with your actual Form ID and API Key. The formData object should contain the fields specific to your form.