Skip to main content
POST
/
forms
JavaScript
import Moonbase from '@moonbaseai/sdk';

const client = new Moonbase({
  apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});

const form = await client.forms.create({
  name: 'Contact Us',
  pages_enabled: true,
  redirect_url: 'https://example.com/thanks',
});

console.log(form.id);
{
  "id": "1CLJt2v5pkpkAnvdgXfEcF",
  "type": "form",
  "name": "Contact Us",
  "redirect_url": "https://example.com/thanks",
  "pages_enabled": true,
  "business_email_required": false,
  "pages_url": "https://moonbase.page/1CLJt2v5pkpkAnvdgXfEcF",
  "collection": {
    "id": "1CLJt2v6592N5WQzNpjpj2",
    "type": "collection",
    "name": "Form: Contact Us",
    "ref": "form_1cljt2v5pkpkanvdgxfecf",
    "kind": "form",
    "fields": [
      {
        "id": "1CLJt2v9J7dQtomdQemUF7",
        "type": "field/geo",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Country",
        "ref": "country",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2vAY2dWSPDQt8AQpz",
        "type": "field/datetime",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Created At",
        "ref": "created_at",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": true,
        "kind": "system"
      },
      {
        "id": "1CLJt2vA3GEGcxEhVY1EbS",
        "type": "field/choice",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "options": [
          {
            "id": "smart-tv",
            "type": "choice_field_option",
            "name": "Smart TV",
            "color": "red"
          },
          {
            "id": "tablet",
            "type": "choice_field_option",
            "name": "Tablet",
            "color": "blue"
          },
          {
            "id": "mobile",
            "type": "choice_field_option",
            "name": "Mobile",
            "color": "green"
          },
          {
            "id": "desktop",
            "type": "choice_field_option",
            "name": "Desktop",
            "color": "orange"
          }
        ],
        "name": "Device Type",
        "ref": "device_type",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v6ZuRbtwPhmQtzxa",
        "type": "field/email",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Email",
        "ref": "email",
        "cardinality": "one",
        "required": true,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v6KXDyzDuM57pQqo",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Name",
        "ref": "name",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v7K42Td5rmrJ8mJu",
        "type": "field/relation",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "relation_type": "two_way",
        "allowed_collections": [
          {
            "id": "1CLJt2uco2zG6pdjxS37sg",
            "type": "collection",
            "ref": "organizations"
          }
        ],
        "reverse_field_name": "Form: Contact Us",
        "reverse_fields": [
          {
            "id": "1CLJt2vBXZRz5FAqfJUmJ6",
            "type": "field",
            "collection": {
              "id": "1CLJt2uco2zG6pdjxS37sg",
              "type": "collection",
              "ref": "organizations"
            },
            "ref": "form_contact_us"
          }
        ],
        "name": "Organization",
        "ref": "organization",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v6pHdDoet4Thyb5M",
        "type": "field/relation",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "relation_type": "two_way",
        "allowed_collections": [
          {
            "id": "1CLJt2ubZ7zAZFBxUxeBHo",
            "type": "collection",
            "ref": "people"
          }
        ],
        "reverse_field_name": "Form: Contact Us",
        "reverse_fields": [
          {
            "id": "1CLJt2vB2o2kFpC8GiKb4Y",
            "type": "field",
            "collection": {
              "id": "1CLJt2ubZ7zAZFBxUxeBHo",
              "type": "collection",
              "ref": "people"
            },
            "ref": "form_contact_us"
          }
        ],
        "name": "Person",
        "ref": "person",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v9YVq2oXFz6wr4Mt",
        "type": "field/geo",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Region",
        "ref": "region",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v9nt2eiEkLoEveUf",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Time Zone",
        "ref": "time_zone",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2vAnQq8M6hmaREzwm",
        "type": "field/datetime",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "Updated At",
        "ref": "updated_at",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": true,
        "kind": "system"
      },
      {
        "id": "1CLJt2v93jRnz6HGiMgt8L",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "User Agent",
        "ref": "user_agent",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v8JapwFwpCdUT7n1",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "UTM Campaign",
        "ref": "utm_campaign",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v8oMEB5Nnv24cJ1Z",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "UTM Content",
        "ref": "utm_content",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v84CdKMEKqwBNXfE",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "UTM Medium",
        "ref": "utm_medium",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v7opRhSWqVEtHwYT",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "UTM Source",
        "ref": "utm_source",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      },
      {
        "id": "1CLJt2v8Yy2ZAfJZKmXhtn",
        "type": "field/text/single_line",
        "created_at": "2025-02-17T16:00:00.000Z",
        "updated_at": "2025-02-17T16:00:00.000Z",
        "default_values": [],
        "name": "UTM Term",
        "ref": "utm_term",
        "cardinality": "one",
        "required": false,
        "unique": false,
        "readonly": false,
        "kind": "system"
      }
    ],
    "created_at": "2025-02-17T16:00:00.000Z",
    "updated_at": "2025-02-17T16:00:00.000Z"
  },
  "created_at": "2025-02-17T16:00:00.000Z",
  "updated_at": "2025-02-17T16:00:00.000Z"
}

Documentation Index

Fetch the complete documentation index at: https://docs.moonbase.ai/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Body

application/json

Parameters for creating a Form.

name
string
required

The name of the form, used as the title on its public page.

redirect_url
string

Optional URL the user is redirected to after a successful submission. Omit to leave submissions without a redirect. Stored as a Liquid template; rendered at submission time with form field values under submission.<key> (keyed by the field's key) plus UTM params (utm_source, utm_medium, utm_campaign, utm_term, utm_content) automatically appended. Use the uri_encode filter for URL-safe values, e.g. https://example.com/thanks?email={{ submission.email | uri_encode }}. The rendered URL must parse as a valid URL or the submission errors.

pages_enabled
boolean

If true, enables a Moonbase Pages hosted page for this form, providing a standalone public URL for sharing. Defaults to false.

business_email_required
boolean

If true, submissions require a business email address. Defaults to false.

Response

Creation succeeded.

A Form provides a way to create Items in a Collection, often via a public URL for external users. Each form submission creates a new item.

type
string
required

String representing the object’s type. Always form for this object.

Allowed value: "form"
id
string
required

Unique identifier for the object.

name
string
required

The name of the form, used as the title on its public page.

pages_enabled
boolean
required

If true, a Moonbase Pages hosted page is enabled for this form, providing a standalone public URL for sharing.

business_email_required
boolean
required

true if submissions require a business email address, blocking free and disposable providers.

collection
Collection · object
required

The Collection that submissions to this form are saved to.

created_at
string<date-time>
required

Time at which the object was created, as an ISO 8601 timestamp in UTC.

updated_at
string<date-time>
required

Time at which the object was last updated, as an ISO 8601 timestamp in UTC.

redirect_url
string

Optional URL the user is redirected to after a successful submission. When unset, no redirect occurs. Stored as a Liquid template; rendered at submission time with form field values under submission.<key> (keyed by the field's key) plus UTM params (utm_source, utm_medium, utm_campaign, utm_term, utm_content) automatically appended. Use the uri_encode filter for URL-safe values, e.g. https://example.com/thanks?email={{ submission.email | uri_encode }}. The rendered URL must parse as a valid URL or the submission errors.

pages_url
string<uri>

The public URL for the form, if pages_enabled is true.