# Create lead form

> Create a hosted lead form.

Source: https://docs.mycrmsim.com/docs/lead-forms/create-lead-form

```http
POST https://backend.mysmsgateway.app/api/v1/ext/lead-forms
```

- Category: myCRMSIM Lead Forms / Lead Forms
- Auth: Bearer access token
- Scope: `lead_forms.write`

Checked with the dashboard's own rules: at least one field, every key a contact column or an existing custom field of the workspace, and an `email` or `phone_number` field so the submitter can be reached. The form is live at its `public_url` at once (`is_active` defaults to true).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | body | number | yes | A workspace of the installer. Example: `7` |
| `name` | body | string | yes | Internal name (up to 191 characters). Example: `Website quote form` |
| `fields` | body | array<object> | yes | 1–30 fields, each { key, type, label, required?, placeholder?, options?, custom_field_id?, consent_text? }. type: text, email, phone, textarea, select, checkbox, url, date, number, sms_consent. key is a contact column (first_name, last_name, email, phone_number, company_name, website, address, city, state, country) or a workspace custom field's key with its custom_field_id; the form needs an email or phone_number field. sms_consent is the opt-in checkbox (key sms_consent, consent_text up to 1000 characters). Example: `[{"key":"first_name","type":"text","label":"First name","required":true},{"key":"email","type":"email","label":"Email","required":true}]` |
| `title` | body | string | no | Heading on the hosted page. Example: `Get a quote` |
| `description` | body | string | no | Text under the heading (up to 5000 characters). |
| `settings` | body | object | no | submit_button_text, thank_you_message, redirect_url (https), tags (added to the contact, up to 20), allowed_domains (where it may be embedded, up to 20), daily_limit, style { primary_color, button_text_color, background_color, page_background, text_color (hex), border_radius 0–32, font_family system\|serif\|mono }. Example: `{"submit_button_text":"Get a quote","tags":["web-lead"]}` |
| `is_active` | body | boolean | no | Default true. An inactive form's page answers 404. |

## Request body

```json
{
  "workspace_id": 7,
  "name": "Website quote form",
  "title": "Get a quote",
  "fields": [
    {
      "key": "first_name",
      "type": "text",
      "label": "First name",
      "required": true
    },
    {
      "key": "email",
      "type": "email",
      "label": "Email",
      "required": true
    },
    {
      "key": "phone_number",
      "type": "phone",
      "label": "Mobile",
      "required": false
    }
  ],
  "settings": {
    "submit_button_text": "Get a quote",
    "tags": [
      "web-lead"
    ]
  }
}
```

## Response 201

Created

```json
{
  "success": true,
  "data": {
    "id": 31,
    "workspace_id": 7,
    "name": "Website quote form",
    "slug": "f3a9c1d2e4b5f607",
    "title": "Get a quote",
    "description": "Tell us about your project.",
    "fields": [
      {
        "key": "first_name",
        "type": "text",
        "label": "First name",
        "required": true
      },
      {
        "key": "email",
        "type": "email",
        "label": "Email",
        "required": true
      },
      {
        "key": "phone_number",
        "type": "phone",
        "label": "Mobile",
        "required": false
      },
      {
        "key": "lead_source",
        "type": "select",
        "label": "How did you hear about us?",
        "options": [
          "Web",
          "Referral",
          "Event"
        ],
        "custom_field_id": 41
      },
      {
        "key": "sms_consent",
        "type": "sms_consent",
        "label": "Text me updates",
        "consent_text": "By ticking this box you agree to receive SMS from Acme. Reply STOP to opt out."
      }
    ],
    "settings": {
      "submit_button_text": "Get a quote",
      "thank_you_message": "Thanks — we will be in touch today.",
      "redirect_url": null,
      "tags": [
        "web-lead"
      ],
      "allowed_domains": [
        "acme.example"
      ],
      "daily_limit": 500,
      "style": {
        "primary_color": "#2563eb",
        "button_text_color": "#ffffff",
        "background_color": "#ffffff",
        "page_background": "#f8fafc",
        "text_color": "#0f172a",
        "border_radius": 8,
        "font_family": "system"
      }
    },
    "is_active": true,
    "submission_count": 0,
    "created_at": "2026-10-01T00:00:00.000Z",
    "updated_at": "2026-11-01T00:00:00.000Z",
    "public_url": "https://api.mycrmsim.com/f/f3a9c1d2e4b5f607",
    "embed_snippet": "<script src=\"https://api.mycrmsim.com/embed/forms.js\" data-form=\"f3a9c1d2e4b5f607\" async></script>"
  }
}
```

## Response 400

A rule failed (Joi message or field rule)

```json
{
  "success": false,
  "message": "Form must include an email or phone number field"
}
```

## Response 401

Missing or invalid token

```json
{
  "success": false,
  "message": "Invalid or expired access token."
}
```

## Response 403

Missing scope

```json
{
  "success": false,
  "message": "Missing scope(s): lead_forms.write. This integration was granted: …"
}
```

## Response 404

Workspace does not exist or is not the installer's (same response for both)

```json
{
  "success": false,
  "message": "Workspace not found or not accessible to this token"
}
```
