Forms API

Build and manage custom forms for collecting leads, subscriptions, and customer information. Forms automatically collect submissions and can add contacts to your database.

Create Form

create-form.tsTypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Metigan from 'metigan';

const metigan = new Metigan({
  apiKey: 'your_api_key'
});

// Create a new form
const form = await metigan.forms.create({
  name: 'Newsletter Signup',
  fields: [
    { name: 'email', type: 'email', required: true, label: 'Email Address' },
    { name: 'firstName', type: 'text', required: false, label: 'First Name' },
    { name: 'newsletter', type: 'checkbox', required: false, label: 'Subscribe to newsletter' }
  ],
  settings: {
    autoAddToAudience: 'audience_123', // Automatically add submissions to audience
    sendConfirmationEmail: true,
    confirmationEmailTemplate: 'template_123'
  }
});

console.log('Form created:', form.id);
console.log('Embed code:', form.embedCode);

List Form Submissions

list-submissions.tsTypeScript
1
2
3
4
5
6
7
// Get form submissions
const submissions = await metigan.forms.getSubmissions('form_123', {
  page: 1,
  limit: 50
});

console.log('Submissions:', submissions.items);
Form Builder

Use the visual form builder in your Metigan dashboard to create forms without code, or use the API for programmatic form creation. See the Form Builder guide for more details.