Forms
使用此端点来操作并获取有关 Mautic 表单的详细信息。
使用 Mautic API 库
您可以使用以下 :xref:`Mautic API 库 与此 API 进行交互,或者使用本文档中描述的各种 HTTP 端点。
<?php
use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
// ...
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = "https://example.com";
$api = new MauticApi();
$formApi = $api->newApi("forms", $auth, $apiUrl);
获取表单
检索单个表单。
<?php
//...
$form = $formApi->get($id);
HTTP 请求
GET /forms/ID
响应
当请求成功检索到表单时,返回
200 OK。
- {
- “form”: {
“isPublished”: true, “dateAdded”: “2026-02-19T07:06:12+00:00”, “dateModified”: “2026-02-19T07:10:06+00:00”, “createdBy”: 1, “createdByUser”: “Admin Mautic”, “modifiedBy”: 1, “modifiedByUser”: “Admin Mautic”, “id”: 2, “name”: “Acme Global Conference Registration”, “alias”: “acme_globa”, “category”: {
“createdByUser”: “Admin Mautic”, “modifiedByUser”: null, “id”: 1, “title”: “Company attendees”, “alias”: “company-attendees”, “description”: null, “color”: null, “bundle”: “form”
}, “description”: “<p><span style="color:rgb(186,33,33);"><span class="s2" style="box-sizing:border-box;">Acme Global Conference registration.</span></span></p>”, “cachedHtml”: “n<style type="text/css" scoped>n .mauticform_wrapper { max-width: 600px; margin: 10px auto; }n .mauticform-innerform {}n .mauticform-post-success {}n .mauticform-name { font-weight: bold; font-size: 1.5em; margin-bottom: 3px; }n .mauticform-description { margin-top: 2px; margin-bottom: 10px; }n .mauticform-error { margin-bottom: 10px; color: red; }n .mauticform-message { margin-bottom: 10px; color: green; }n .mauticform-row { display: block; margin-bottom: 20px; }n .mauticform-label { font-size: 1.1em; display: block; font-weight: bold; margin-bottom: 5px; }n .mauticform-row.mauticform-required .mauticform-label:after { color: #e32; content: " "; display: inline; }n .mauticform-helpmessage { display: block; font-size: 0.9em; margin-bottom: 3px; }n .mauticform-errormsg { display: block; color: red; margin-top: 2px; }n .mauticform-selectbox, .mauticform-input, .mauticform-textarea { width: 100%; padding: 0.5em 0.5em; border: 1px solid #CCC; background: #fff; box-shadow: 0px 0px 0px #fff inset; border-radius: 4px; box-sizing: border-box; }n .mauticform-checkboxgrp-row {}n .mauticform-checkboxgrp-label { font-weight: normal; }n .mauticform-checkboxgrp-checkbox {}n .mauticform-radiogrp-row {}n .mauticform-radiogrp-label { font-weight: normal; }n .mauticform-radiogrp-radio {}n .mauticform-button-wrapper .mauticform-button.btn-ghost, .mauticform-pagebreak-wrapper .mauticform-pagebreak.btn-ghost { color: #5d6c7c;background-color: #ffffff;border-color: #dddddd;}n .mauticform-button-wrapper .mauticform-button, .mauticform-pagebreak-wrapper .mauticform-pagebreak { display: inline-block;margin-bottom: 0;font-weight: 600;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 13px;line-height: 1.3856;border-radius: 3px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}n .mauticform-button-wrapper .mauticform-button.btn-ghost[disabled], .mauticform-pagebreak-wrapper .mauticform-pagebreak.btn-ghost[disabled] { background-color: #ffffff; border-color: #dddddd; opacity: 0.75; cursor: not-allowed; }n .mauticform-pagebreak-wrapper .mauticform-button-wrapper { display: inline; }nn /*n * @see https://github.com/TarekRaafat/autoComplete.js/blob/master/dist/css/autoComplete.02.css.n */n .autoComplete_wrapper {position: relative;}n .autoComplete_wrapper > input::placeholder {transition: all 0.3s ease;}n .autoComplete_wrapper > ul {position: absolute;max-height: 226px;overflow-y: scroll;top: 100%;left: 0;right: 0;padding: 0;margin: 0.5rem 0 0 0;border-radius: 4px;background-color: #fff;border: 1px solid rgba(33, 33, 33, 0.1);z-index: 1000;outline: none;}n .autoComplete_wrapper > ul > li {padding: 10px 20px;list-style: none;text-align: left;font-size: 16px;color: #212121;transition: all 0.1s ease-in-out;border-radius: 3px;background-color: rgba(255, 255, 255, 1);white-space: nowrap;overflow: hidden;text-overflow: ellipsis;transition: all 0.2s ease;}n .autoComplete_wrapper > ul > li > span {float: right;}n .autoComplete_wrapper > ul > li::selection {color: rgba(#ffffff, 0);background-color: rgba(#ffffff, 0);}n .autoComplete_wrapper > ul > li:hover {cursor: pointer;background-color: rgba(123, 123, 123, 0.1);}n .autoComplete_wrapper > ul > li mark {background-color: transparent;font-weight: bold;}n .autoComplete_wrapper > ul > li mark::selection {background-color: rgba(#ffffff, 0);}n .autoComplete_wrapper > ul > li[aria-selected="true"] {background-color: rgba(123, 123, 123, 0.1);}n @media only screen and (max-width: 600px) {n .autoComplete_wrapper > input {width: 18rem;}n }n</style>nn<style type="text/css" scoped>n .mauticform-field-hidden { display:none }n</style>n<div id="mauticform_wrapper_acmeglobalconferenceregistration" class="mauticform_wrapper">n <form autocomplete="false" role="form" method="post" action="https://m5-tester.ddev.site/form/submit?formId=2" id="mauticform_acmeglobalconferenceregistration" data-mautic-form="acmeglobalconferenceregistration" enctype="multipart/form-data" ><div class="mauticform-error" id="mauticform_acmeglobalconferenceregistration_error"></div>n <div class="mauticform-message" id="mauticform_acmeglobalconferenceregistration_message"></div><div class="mauticform-innerform">n <div class="mauticform-page-wrapper mauticform-page-1" data-mautic-form-page="1" >n nnn nn nnn nnn<div id="mauticform_acmeglobalconferenceregistration_topic_preference"class="mauticform-row mauticform-text mauticform-field-1">n <label id="mauticform_label_acmeglobalconferenceregistration_topic_preference"for="mauticform_input_acmeglobalconferenceregistration_topic_preference"class="mauticform-label">Topic preference</label>n <span class="mauticform-helpmessage">The talk that you’re looking forward to</span>n <textarea name="mauticform[topic_preference]"id="mauticform_input_acmeglobalconferenceregistration_topic_preference"class="mauticform-textarea"></textarea>n n <span class="mauticform-errormsg" style="display:none;"></span>n</div>n n n n n n<div id="mauticform_acmeglobalconferenceregistration_submit"class="mauticform-row mauticform-button-wrapper mauticform-field-2">n <button class="btn btn-ghost mauticform-button"name="mauticform[submit]"value="1"id="mauticform_input_acmeglobalconferenceregistration_submit"type="submit">Submit</button>n</div>n </div></div><input type="hidden" name="mauticform[formId]" id="mauticform_acmeglobalconferenceregistration_id" value="2"/>n <input type="hidden" name="mauticform[return]" id="mauticform_acmeglobalconferenceregistration_return" value=""/>n <input type="hidden" name="mauticform[formName]" id="mauticform_acmeglobalconferenceregistration_name" value="acmeglobalconferenceregistration"/>n n </form>n</div>n”, “publishUp”: “2026-02-19T07:00:00+00:00”, “publishDown”: “2026-03-06T08:05:00+00:00”, “fields”: [
- {
“id”: 2, “label”: “Topic preference”, “showLabel”: true, “alias”: “topic_preference”, “type”: “textarea”, “defaultValue”: null, “isRequired”: false, “validationMessage”: null, “helpMessage”: “The talk that you’re looking forward to”, “order”: 1, “properties”: [], “validation”: [], “parent”: null, “conditions”: [], “labelAttributes”: null, “inputAttributes”: null, “containerAttributes”: null, “leadField”: null, “saveResult”: true, “isAutoFill”: true, “mappedObject”: “company”, “mappedField”: null
}, {
“id”: 3, “label”: “Submit”, “showLabel”: true, “alias”: “submit”, “type”: “button”, “defaultValue”: null, “isRequired”: false, “validationMessage”: null, “helpMessage”: null, “order”: 2, “properties”: [], “validation”: [], “parent”: null, “conditions”: [], “labelAttributes”: null, “inputAttributes”: “class="btn btn-ghost"”, “containerAttributes”: null, “leadField”: null, “saveResult”: true, “isAutoFill”: false, “mappedObject”: null, “mappedField”: null
}
], “actions”: [
- {
“id”: 13, “name”: “Add company score”, “description”: null, “type”: “lead.scorecontactscompanies”, “order”: 1, “properties”: {
“score”: 5
}
}
], “template”: “goldstar”, “inKioskMode”: true, “renderStyle”: true, “formType”: “standalone”, “postAction”: “message”, “postActionProperty”: “Thank you for registering and see you there!”, “noIndex”: false, “formAttributes”: null, “language”: “en_US”
}
}
表单属性
- Name
Type
Description
isPublishedboolean
表单的发布状态
dateAddeddatetime
表单记录的创建日期和时间
dateModifieddatetime
表单记录的最后修改日期和时间
createdByinteger
创建表单的用户ID
createdByUserstring
创建表单用户的姓名
modifiedByinteger
最后修改表单的用户ID
modifiedByUserstring
最后修改表单用户的姓名
idinteger
表单的ID
namestring
表单名称
aliasstring
表单自动生成的别名或 slug
categoryobject
赋给表单的类别
descriptionstring
表单描述
cachedHtmlstring
表单自动生成的 HTML 和 CSS 代码
publishUpdatetime
表单的激活日期和时间
publishDowndatetime
表单的停用日期和时间
fieldsassociative array
包含表单字段的关联数组。键必须与 :ref: 中描述的“表单字段属性”<get Form Field properties> 中的字段别名对应
actionsassociative array
包含表单操作的关联数组。键必须与 :ref: 中描述的“表单操作属性”<get Form action properties> 中的操作别名对应
templatestring
用于设置表单样式的主题
inKioskModeboolean
Kiosk 模式状态 - 设置为
1或true可禁用提交的 cookie 跟踪和 IP 关联。如果未设置,则默认情况下会跟踪访问者数据
renderStyleboolean
渲染样式状态 - 设置为
0或false可禁用在表单输出中包含模板 CSS。如果未设置,则默认为启用
formTypestring
表单类型 -
standalone或campaign
postActionstring
提交后执行的操作。必须是以下之一:
return: 不执行任何操作redirect: 重定向到指定的 URLmessage: 显示成功消息
postActionPropertystring
与
postAction相关联的数据。当设置为redirect时,包含重定向的 URL;当设置为message时,包含成功消息
noIndexboolean
搜索索引状态 - 设置为
1或true可发送noindexHTTP 头部。如果未设置,则默认为启用索引
formAttributesstring
添加到 <form> 标签的自定义 HTML 属性
languagestring
表单的语言代码,例如
en_US、fr等
表单字段属性
名称 |
类型 |
描述 |
|---|---|---|
|
integer |
字段的 ID |
|
string |
显示在字段上的标签 |
|
boolean |
标签可见性状态 - |
|
string |
字段的自动生成的别名或 slug |
|
string |
字段类型,例如 |
|
string |
分配给该字段的初始值 |
|
boolean |
必填状态 - |
|
string |
用户在离开必填字段时显示的自定义消息 |
|
string |
帮助用户填写该字段的文本 |
|
integer |
表单中字段的数值位置 |
|
object |
基于字段类型的特定配置选项 |
|
object |
应用于该字段的验证规则列表 |
|
integer |
用于条件逻辑的父字段的 ID |
|
object |
条件逻辑的配置,包含:
|
|
string |
标签元素的 HTML 属性 |
|
string |
输入元素的 HTML 属性 |
|
string |
字段包装器或容器的 HTML 属性 |
|
string |
映射到目标对象的内部引用名称 |
|
boolean |
结果存储状态 - |
|
boolean |
自动填充状态 - |
|
string |
该字段映射到的对象类型 - |
|
string |
表单字段映射到的特定联系人或公司字段 |
Form action properties
Name |
Type |
Description |
|---|---|---|
|
integer |
ID of the action |
|
string |
Name of the action |
|
string |
Description of the action |
|
string |
Type of action, such as |
|
integer |
The numerical position of the action within the Form |
|
object |
The settings for the specific action type |
List Forms
Retrieves a list of Forms.
<?php
//...
$forms = $formApi->getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal);
HTTP request
GET /forms
Query parameters
Name |
Type |
Description |
|---|---|---|
|
string |
String or search command to filter entities |
|
integer |
Starting row for the returned entities - defaults to 0 |
|
integer |
Maximum number of entities to return - defaults to 30 |
|
string |
Column to sort by. Any column in the response is valid. Note: convert |
|
string |
Order direction - |
|
boolean |
Returns only currently published entities |
|
boolean |
Returns only a simple mapped object of entities without additional lists in it |
Response
Returns
200 OKwhen the request successfully retrieves the Forms list.
- {
“total”: 2, “forms”: [
- {
“isPublished”: true, “dateAdded”: “2026-02-19T07:06:12+00:00”, “dateModified”: “2026-02-19T07:10:06+00:00”, “createdBy”: 1, “createdByUser”: “Admin Mautic”, “modifiedBy”: 1, “modifiedByUser”: “Admin Mautic”, “id”: 2, “name”: “Acme Global Conference Registration”, “alias”: “acme_globa”, “category”: {
“createdByUser”: “Admin Mautic”, “modifiedByUser”: null, “id”: 1, “title”: “Company attendees”, “alias”: “company-attendees”, “description”: null, “color”: null, “bundle”: “form”
}, “description”: “<p><span style="color:rgb(186,33,33);"><span class="s2" style="box-sizing:border-box;">Acme Global Conference registration.</span></span></p>”, “cachedHtml”: “n<style type="text/css" scoped>n .mauticform_wrapper { max-width: 600px; margin: 10px auto; }n .mauticform-innerform {}n .mauticform-post-success {}n .mauticform-name { font-weight: bold; font-size: 1.5em; margin-bottom: 3px; }n .mauticform-description { margin-top: 2px; margin-bottom: 10px; }n .mauticform-error { margin-bottom: 10px; color: red; }n .mauticform-message { margin-bottom: 10px; color: green; }n .mauticform-row { display: block; margin-bottom: 20px; }n .mauticform-label { font-size: 1.1em; display: block; font-weight: bold; margin-bottom: 5px; }n .mauticform-row.mauticform-required .mauticform-label:after { color: #e32; content: " "; display: inline; }n .mauticform-helpmessage { display: block; font-size: 0.9em; margin-bottom: 3px; }n .mauticform-errormsg { display: block; color: red; margin-top: 2px; }n .mauticform-selectbox, .mauticform-input, .mauticform-textarea { width: 100%; padding: 0.5em 0.5em; border: 1px solid #CCC; background: #fff; box-shadow: 0px 0px 0px #fff inset; border-radius: 4px; box-sizing: border-box; }n .mauticform-checkboxgrp-row {}n .mauticform-checkboxgrp-label { font-weight: normal; }n .mauticform-checkboxgrp-checkbox {}n .mauticform-radiogrp-row {}n .mauticform-radiogrp-label { font-weight: normal; }n .mauticform-radiogrp-radio {}n .mauticform-button-wrapper .mauticform-button.btn-ghost, .mauticform-pagebreak-wrapper .mauticform-pagebreak.btn-ghost { color: #5d6c7c;background-color: #ffffff;border-color: #dddddd;}n .mauticform-button-wrapper .mauticform-button, .mauticform-pagebreak-wrapper .mauticform-pagebreak { display: inline-block;margin-bottom: 0;font-weight: 600;text-align: center;vertical-align: middle;cursor: pointer;background-image: none;border: 1px solid transparent;white-space: nowrap;padding: 6px 12px;font-size: 13px;line-height: 1.3856;border-radius: 3px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}n .mauticform-button-wrapper .mauticform-button.btn-ghost[disabled], .mauticform-pagebreak-wrapper .mauticform-pagebreak.btn-ghost[disabled] { background-color: #ffffff; border-color: #dddddd; opacity: 0.75; cursor: not-allowed; }n .mauticform-pagebreak-wrapper .mauticform-button-wrapper { display: inline; }nn /*n * @see https://github.com/TarekRaafat/autoComplete.js/blob/master/dist/css/autoComplete.02.css.n */n .autoComplete_wrapper {position: relative;}n .autoComplete_wrapper > input::placeholder {transition: all 0.3s ease;}n .autoComplete_wrapper > ul {position: absolute;max-height: 226px;overflow-y: scroll;top: 100%;left: 0;right: 0;padding: 0;margin: 0.5rem 0 0 0;border-radius: 4px;background-color: #fff;border: 1px solid rgba(33, 33, 33, 0.1);z-index: 1000;outline: none;}n .autoComplete_wrapper > ul > li {padding: 10px 20px;list-style: none;text-align: left;font-size: 16px;color: #212121;transition: all 0.1s ease-in-out;border-radius: 3px;background-color: rgba(255, 255, 255, 1);white-space: nowrap;overflow: hidden;text-overflow: ellipsis;transition: all 0.2s ease;}n .autoComplete_wrapper > ul > li > span {float: right;}n .autoComplete_wrapper > ul > li::selection {color: rgba(#ffffff, 0);background-color: rgba(#ffffff, 0);}n .autoComplete_wrapper > ul > li:hover {cursor: pointer;background-color: rgba(123, 123, 123, 0.1);}n .autoComplete_wrapper > ul > li mark {background-color: transparent;font-weight: bold;}n .autoComplete_wrapper > ul > li mark::selection {background-color: rgba(#ffffff, 0);}n .autoComplete_wrapper > ul > li[aria-selected="true"] {background-color: rgba(123, 123, 123, 0.1);}n @media only screen and (max-width: 600px) {n .autoComplete_wrapper > input {width: 18rem;}n }n</style>nn<style type="text/css" scoped>n .mauticform-field-hidden { display:none }n</style>n<div id="mauticform_wrapper_acmeglobalconferenceregistration" class="mauticform_wrapper">n <form autocomplete="false" role="form" method="post" action="https://m5-tester.ddev.site/form/submit?formId=2" id="mauticform_acmeglobalconferenceregistration" data-mautic-form="acmeglobalconferenceregistration" enctype="multipart/form-data" ><div class="mauticform-error" id="mauticform_acmeglobalconferenceregistration_error"></div>n <div class="mauticform-message" id="mauticform_acmeglobalconferenceregistration_message"></div><div class="mauticform-innerform">n <div class="mauticform-page-wrapper mauticform-page-1" data-mautic-form-page="1" >n nnn nn nnn nnn<div id="mauticform_acmeglobalconferenceregistration_topic_preference"class="mauticform-row mauticform-text mauticform-field-1">n <label id="mauticform_label_acmeglobalconferenceregistration_topic_preference"for="mauticform_input_acmeglobalconferenceregistration_topic_preference"class="mauticform-label">Topic preference</label>n <span class="mauticform-helpmessage">The talk that you’re looking forward to</span>n <textarea name="mauticform[topic_preference]"id="mauticform_input_acmeglobalconferenceregistration_topic_preference"class="mauticform-textarea"></textarea>n n <span class="mauticform-errormsg" style="display:none;"></span>n</div>n n n n n n<div id="mauticform_acmeglobalconferenceregistration_submit"class="mauticform-row mauticform-button-wrapper mauticform-field-2">n <button class="btn btn-ghost mauticform-button"name="mauticform[submit]"value="1"id="mauticform_input_acmeglobalconferenceregistration_submit"type="submit">Submit</button>n</div>n </div></div><input type="hidden" name="mauticform[formId]" id="mauticform_acmeglobalconferenceregistration_id" value="2"/>n <input type="hidden" name="mauticform[return]" id="mauticform_acmeglobalconferenceregistration_return" value=""/>n <input type="hidden" name="mauticform[formName]" id="mauticform_acmeglobalconferenceregistration_name" value="acmeglobalconferenceregistration"/>n n </form>n</div>n”, “publishUp”: “2026-02-19T07:00:00+00:00”, “publishDown”: “2026-03-06T08:05:00+00:00”, “fields”: [
- {
“id”: 2, “label”: “Topic preference”, “showLabel”: true, “alias”: “topic_preference”, “type”: “textarea”, “defaultValue”: null, “isRequired”: false, “validationMessage”: null, “helpMessage”: “The talk that you’re looking forward to”, “order”: 1, “properties”: [], “validation”: [], “parent”: null, “conditions”: [], “labelAttributes”: null, “inputAttributes”: null, “containerAttributes”: null, “leadField”: null, “saveResult”: true, “isAutoFill”: true, “mappedObject”: “company”, “mappedField”: null
}, {
“id”: 3, “label”: “Submit”, “showLabel”: true, “alias”: “submit”, “type”: “button”, “defaultValue”: null, “isRequired”: false, “validationMessage”: null, “helpMessage”: null, “order”: 2, “properties”: [], “validation”: [], “parent”: null, “conditions”: [], “labelAttributes”: null, “inputAttributes”: “class="btn btn-ghost"”, “containerAttributes”: null, “leadField”: null, “saveResult”: true, “isAutoFill”: false, “mappedObject”: null, “mappedField”: null
}
], “actions”: [
- {
“id”: 13, “name”: “Add company score”, “description”: null, “type”: “lead.scorecontactscompanies”, “order”: 1, “properties”: {
“score”: 5
}
}
], “template”: “goldstar”, “inKioskMode”: true, “renderStyle”: true, “formType”: “standalone”, “postAction”: “message”, “postActionProperty”: “Thank you for registering and see you there!”, “noIndex”: false, “formAttributes”: null, “language”: “en_US”
}, // …
]
}
Properties
Name |
Type |
Description |
|---|---|---|
|
integer |
Total count of Forms |
|
array |
Array of Forms |
For the rest of the properties, refer to Form properties.
Create Form
Creates a new Form.
<?php
$data = array(
'name' => 'Form created via API', // Required
'postActionProperty' => 'Thank you for your submission!', // Required
'fields' => array( // Required
array(
'label' => 'Email', // Required
'type' => 'text',
'alias' => 'email',
'mappedObject' => 'contact',
'mappedField' => 'email',
'isRequired' => true,
),
array(
'label' => 'Submit', // Required
'type' => 'button',
),
),
'actions' => array( // Required
array(
'properties' => array( // Required
'subject' => 'New form submission',
'message' => 'A new form submission has been received.',
'email' => 'admin@example.com'
),
'name' => 'Send notification',
'type' => 'email.send.lead',
),
),
'formType' => 'standalone',
'postAction' => 'message',
'description' => 'This is a test form created via API',
);
$form = $formApi->create($data);
HTTP request
POST /forms/new
POST parameters
- Name
Type
Description
namestring
Required.
表单名称
postActionPropertystring
Required.
与
postAction关联的数据。当设置为redirect时,包含重定向 URL;当设置为message时,包含成功消息。
fieldsarray
Required.
表单字段数组。请参阅 字段参数 表格以了解可用选项。
actionsarray
Required.
表单操作数组。请参阅 操作参数 表格以了解可用选项。
formTypestring
表单类型,可以是
standalone或campaign
postActionstring
提交后执行的操作。必须是以下之一:
return: 不执行任何操作redirect: 重定向到指定的 URLmessage: 显示成功消息
isPublishedboolean
表单发布状态
字段参数
这些参数位于 fields 数组中。
Name |
Type |
Description |
|---|---|---|
|
string |
Required. 显示的字段标签 |
|
string |
字段类型,例如 |
|
string |
该字段映射的对象类型,可以是 |
|
string |
表单字段映射到的特定联系人或公司字段 |
|
boolean |
字段的强制性状态 |
操作参数
这些参数位于 actions 数组中。
Name |
Type |
Description |
|---|---|---|
|
array |
Required. 特定操作类型的设置,例如电子邮件 ID 或主题。 |
|
string |
操作名称 |
|
string |
操作类型,例如 |
响应
当请求成功创建表单时,返回
201 Created。
响应是一个类似于 Get Form 的 JSON 对象。
属性
请参阅 Form properties。
编辑表单
编辑一个表单。
此操作支持 PUT 或 PATCH,具体取决于所需的行为:
PUT: 完全替换。如果 ID 缺失,则请求会创建一个新的表单。如果 ID 存在,则请求会清除所有现有数据并用提供的值进行替换。PATCH: 部分更新。该请求仅根据请求数据更新字段值。如果表单 ID 不存在,则请求失败。
$id = 1; $data = array(
‘name’ => ‘更新后的表单名称’, ‘description’ => ‘更新后的描述’, ‘fields’ => array(
- array(
‘id’ => 1, // 现有字段 ‘label’ => ‘更新后的电子邮件标签’, ‘type’ => ‘text’, ‘alias’ => ‘email’, ‘mappedObject’ => ‘contact’, ‘mappedField’ => ‘email’, ‘isRequired’ => true,
), array(
‘label’ => ‘名字’, // 新字段 ‘type’ => ‘text’, ‘alias’ => ‘first_name’, ‘mappedObject’ => ‘contact’, ‘mappedField’ => ‘firstname’,
),
),
);
// 如果 ID 1 未找到,则创建一个新的表单 $createIfNotFound = true;
$form = $formApi->edit($id, $data, $createIfNotFound);
HTTP 请求
PUT /forms/ID/edit: 更新现有的表单,或者当 ID 不存在时创建一个新的表单。PATCH /forms/ID/edit: 更新现有的表单。如果 ID 不存在,则请求失败。
POST 参数
接受与 创建表单 中描述的相同参数。所有参数都是可选的。
响应
PUT: 当请求成功更新表单时返回200 OK,或者当请求创建表单时返回201 Created。PATCH: 当请求成功更新表单时返回200 OK,或者当表单 ID 不存在时返回404 Not Found错误。
响应是一个类似于 获取表单 的 JSON 对象。
属性
请参考 表单属性.
删除表单
删除一个表单。
<?php
$form = $formApi->delete($id);
HTTP 请求
DELETE /forms/ID/delete
响应
当请求成功删除表单时,返回
200 OK。
响应是一个包含已删除表单数据的 JSON 对象,类似于 获取表单。
属性
请参考 表单属性.
删除表单字段
从一个表单中删除特定的字段。
<?php
$formApi->deleteFields($formId, array(1, 2, 3));
HTTP 请求
DELETE /forms/ID/fields/delete
参数
Name |
Type |
Description |
|---|---|---|
|
array |
必需。 要删除的表单字段 ID 的数组。 |
响应
当请求成功删除表单字段时,返回
200 OK。
The response is a JSON object containing the data of the deleted Form Fields, similar to Get Form.
Properties
Refer to Form properties.
Delete Form actions
Deletes specific actions from a Form.
<?php
$formApi->deleteActions($formId, array(1, 2));
HTTP request
DELETE /forms/ID/actions/delete
Parameters
Name |
Type |
Description |
|---|---|---|
|
array |
Required. Array of Form action IDs to delete |
Response
Returns
200 OKwhen the request successfully deletes the Form actions.
The response is a JSON object containing the data of the deleted Form actions, similar to Get Form.
Properties
Refer to Form properties.
Get Form submission
Get an individual submission for a specific Form.
<?php
$submission = $formApi->getSubmission($formId, $submissionId);
HTTP request
GET /forms/FORM_ID/submissions/SUBMISSION_ID
Response
Returns
200 OKwhen the request successfully retrieves the Form submission.
{
"submission": {
"id": 2,
"ipAddress": {
"ipAddress": "127.0.0.1"
},
"form": {
"id": 2,
"name": "Acme Global Conference Registration",
"alias": "acme_globa",
"category": {}
},
"lead": {
"id": 3,
"points": 0,
"color": null,
"title": null,
"firstname": "Jack",
"lastname": "Smith",
"company": "Beta Inc.",
"position": null,
"email": null,
"phone": null,
"mobile": null,
"address1": null,
"address2": null,
"city": null,
"state": null,
"zipcode": null,
"timezone": null,
"country": null
},
"trackingId": null,
"dateSubmitted": "2026-02-19T07:27:18+00:00",
"referer": "https://example.com/forms/2",
"page": null,
"results": {
"form_id": "2",
"topic_preference": "The Rising of Open Source",
"company_name": "Beta Inc.",
"availability": "2026-02-20",
"email": null,
"first_name": "Jack",
"last_name": "Smith"
}
}
}
Form submission properties
Name |
Type |
Description |
|---|---|---|
|
integer |
ID of the Form submission |
|
object |
Information about the IP address used for the submission |
|
object |
Information about the Form that received the submission |
|
object |
The Contact record associated with the submission |
|
string |
ID used for tracking the submission source |
|
datetime |
Date and time of the submission |
|
string |
The URL of the page where the User submitted the Form |
|
object |
The specific Mautic Landing Page where the submission occurred |
|
object |
The values submitted for each Form Field |
List Form submissions
Retrieves a list of submissions for a specific Form.
<?php
$submissions = $formApi->getSubmissions($formId, $searchFilter, $start, $limit, $orderBy, $orderByDir);
HTTP request
GET /forms/ID/submissions
Query parameters
Name |
Type |
Description |
|---|---|---|
|
string |
String or search command to filter entities |
|
integer |
Starting row for the returned entities - defaults to 0 |
|
integer |
Maximum number of entities to return - defaults to 30 |
|
string |
Column to sort by. Any column in the response is valid Note: convert |
|
string |
Order direction - |
Response
Returns
200 OKwhen the request successfully retrieves the Form submissions.
- {
“total”: “4”, “submissions”: [
- {
“id”: 2, “ipAddress”: {
“ipAddress”: “127.0.0.1”
}, “form”: {
“id”: 2, “name”: “Acme Global Conference Registration”, “alias”: “acme_globa”, “category”: {}
}, “lead”: {
“id”: 3, “points”: 0, “color”: null, “title”: null, “firstname”: “Jack”, “lastname”: “Smith”, “company”: “Beta Inc.”, “position”: null, “email”: null, “phone”: null, “mobile”: null, “address1”: null, “address2”: null, “city”: null, “state”: null, “zipcode”: null, “timezone”: null, “country”: null
}, “trackingId”: null, “dateSubmitted”: “2026-02-19T07:27:18+00:00”, “referer”: “https://example.com/forms/2”, “page”: null, “results”: {
“first_name”: “Jack”, “last_name”: “Smith”, “company_name”: “Beta Inc.”, “availability”: “2026-02-20”, “topic_preference”: “The Rising of Open Source”
}
}, // …
]
}
Properties
Name |
Type |
Description |
|---|---|---|
|
integer |
Total count of Form submissions |
|
array |
Array of Form submissions |
For the rest of the Form properties, refer to Form submission properties.
Get Contact Form submissions
Retrieves a Contact from a specific Form submission.
<?php
$submissions = $formApi->getContactSubmissions($formId, $contactId, $searchFilter, $start, $limit, $orderBy, $orderByDir);
HTTP request
GET /forms/FORM_ID/submissions/contact/CONTACT_ID
Query parameters
- Name
Type
Description
searchFilterstring
用于过滤实体的字符串或搜索命令。
startinteger
返回的实体起始行,默认为 0。
limitinteger
要返回的最大实体数量,默认为 30。
orderBystring
用于排序的列。响应中的任何列都有效。
注意: 将 camelCase 属性转换为 snake_case。例如,dateAdded 变为 date_added,webhookUrl 变为 webhook_url,依此类推。
orderByDirstring
排序方向,可以是 asc 或 desc。
Response
当请求成功检索到表单提交的联系人时,返回 200 OK。
{
"total": "1",
"submissions": [
{
"id": 2,
"ipAddress": {
"ipAddress": "127.0.0.1"
},
"form": {
"id": 2,
"name": "Acme Global Conference Registration",
"alias": "acme_globa",
"category": {}
},
"lead": {
"id": 3,
"points": 0,
"color": null,
"title": null,
"firstname": "Jack",
"lastname": "Smith",
"company": "Beta Inc.",
"position": null,
"email": null,
"phone": null,
"mobile": null,
"address1": null,
"address2": null,
"city": null,
"state": null,
"zipcode": null,
"timezone": null,
"country": null
},
"trackingId": null,
"dateSubmitted": "2026-02-19T07:27:18+00:00",
"referer": "https://example.com/forms/2",
"page": null,
"results": {
"first_name": "Jack",
"last_name": "Smith",
"company_name": "Beta Inc.",
"availability": "2026-02-20",
"topic_preference": "The Rising of Open Source"
}
}
]
}
Properties
Name |
Type |
Description |
|---|---|---|
|
integer |
表单提交的总数。 |
|
array |
表单提交的数组。 |
有关其他表单属性,请参阅 Form submission properties。
Form Field types
Mautic 支持各种表单字段类型,用于收集和验证联系人数据。每种字段类型在表单提交过程中都具有特定的用途:
Field type |
Description |
Properties |
|---|---|---|
|
CAPTCHA field |
|
|
Checkbox group |
|
|
Company lookup |
None |
|
Date picker |
|
|
Date and time picker |
|
|
Description area |
|
|
Email input with validation |
|
|
File upload |
|
|
HTML area |
|
|
Hidden field |
None |
|
Number input |
|
|
Page break for multi-page Forms |
|
|
Password |
None |
|
Telephone input |
|
|
Radio group |
|
|
Country selection dropdown |
|
|
Dropdown selection |
|
|
Multi-line text input |
|
|
Single line text input |
|
|
URL input with validation |
|
|
Submit button |
None |
表单操作类型
表单操作在联系人提交表单后立即执行特定任务。Mautic 支持以下操作类型:
- Action type
Description
Properties
lead.scorecontactscompaniesAdd to Company’s score
score
lead.pointschangeAdjust Contact’s Points
operator,points,group
lead.changelistModify Contact’s Segments
addToLists,removeFromLists
lead.changetagsModify Contact’s tags
add_tags,remove_tags
lead.addutmtagsRecord UTM Tags
None
lead.remove_do_not_contactRemove Contact from Do Not Contact list
None
asset.downloadDownload an Asset
asset,category
form.repostForwards submission results to an external URL or Form
post_url,authorization_header,failure_email
plugin.leadpushPush Contact to Integration
integration
email.send.leadSend Email to Contact
email
email.send.userSend Email to User
useremail,user_id
form.emailSend Form results
subject,immediately,set_replyto,message,email_to_owner,copy_lead,templates,to,cc,bcc
分阶段收集信息
分阶段收集信息通过根据之前的提交情况显示不同的字段,从而在一段时间内从联系人那里收集更多信息。 要启用分阶段收集信息:
在表单中设置
progressiveProfilingLimit配置具有
showAfterXSubmissions属性的字段使用
showWhenValueExists来隐藏如果该联系人的某个字段已经存在值时,则隐藏该字段
条件字段
Mautic 会根据其他字段的值有条件地显示字段:
设置
parent字段 ID配置
conditions,使用表达式类型 -eq,neq,in和!in将
isConditionallyHidden设置为 true
映射字段
Mautic 可以将表单字段映射到联系人或公司字段:
使用
mappedObject指定contact或company使用
mappedField指定目标字段名称Mautic 仍然支持用于向后兼容性的已弃用的
leadField属性