Form definitions, recorded responses and exports
Create a form with mapped field names
/a/Form_createData
Insert a form definition using the mapped field contract rather than the legacy full-editor payload.
When to use this endpoint
Use when working with mapped Form fields. Supply an intentional name, type and complete fieldsData even though this route has no required business-field rules. Read the new ID back before using it for Jobs.
Authentication and permissions
Authenticate with a signed API key (acting as its owner) or a logged-in CRM session on the routed account host. Session calls include the dispatcher’s CSRF value when configured. IDs refer to the authenticated tenant unless an explicit cross-account copy is described.
The handler adds no Forms page/role check. The dispatcher does not add a Form record-scope predicate; a screen’s CRM2 role controls are not evidence of an API restriction or a CRM1 permission requirement.
The account’s features2.disableFormEdits setting blocks this mutation with form edits are disabled for this account. A temporary user marked meta.is_tmp=1 bypasses that setting only.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name, template, replyTo | Text | No | Display name, legacy template and reply-to address. These mapped names differ from the snake_case/full-editor inputs; replyTo is not normalized to the legacy editor’s fallback address. |
fieldsData | Native array or JSON array text | No | Complete field definitions stored as fields. Existing stable IDs must be unique; missing legacy IDs remain accepted. Replacing definitions does not migrate saved answers. |
onComplete, autodocs | Native JSON value or encoded text | No | Legacy On Complete definition and AutoDoc configuration. A saved rule is not executed by this write. |
autodocsDoc | JSON text | No | AutoDoc object with header, body and footer HTML. See each route’s distinct image/HTML processing below. |
type | Integer-compatible value | No | Stored form type: current editors use 0 Job, 3 Job Table, 4 Quote, 5 Purchase Order, 6 Quote Table, 7 Invoice, 8 Invoice Table, 9 Opportunity, 10 Opportunity Table. No type allowlist is enforced by this map. |
ownerID, emailTemplateID, departmentID | Integer-compatible values | No | Mapped IDs saved to owner_id, email_template_id and department_id. This wrapper does not establish that each referenced record exists. |
archived, reportType, portalVisibility, usesStock, isInvoiceable, selectByDefault | Integer-compatible values | No | Stored switches/modes, mapped to archived, report_type, portal_visibility, uses_stock, is_invoiceable and select_by_default. Do not assume a server-side enum allowlist. |
theme, metaTags, metaNotes | Text/serialized metadata value | No | Update meta.theme, meta.tags or meta.notes while retaining sibling metadata. Use these aliases for a targeted metadata edit. |
meta | JSON text | No | Whole metadata document. Replaces the stored document; preserve all unrelated keys when using it. |
cdate, lastEdited | Datetime text | No | Mapped creation/edit timestamps. CreateData overrides cdate; ordinary changed updates set last_edited to server time. These are not incremental-read controls. |
phpdocxVersion | Number | No | Stored phpdocx_version selection. No renderer version allowlist is added here. |
Example request
$form = FM_api('Form_createData', [
'name'=>'Inspection','type'=>'0',
'fieldsData'=>json_encode([['name'=>'Result','type'=>'input','meta'=>json_encode(['id'=>1042001])]]),
]);
Example response
{"ok":1,"id":1088}
Database numeric values can be JSON strings. Examples are representative; legacy application errors can use HTTP 200, so inspect the decoded response.
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"Unable to create record"} | Primary insert failed. |
{"error":"Rule 1 — Set Job Status: select a valid Job Status before saving."} | Representative invalid status error; nested rule paths vary. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Recognized fields are
name, fieldsData, template, ownerID, lastEdited, onComplete, autodocs, type, archived, replyTo, reportType, portalVisibility, usesStock, isInvoiceable, autodocsDoc, theme, meta, emailTemplateID, departmentID, selectByDefault, cdate, phpdocxVersion, metaTags, metaNotes. Input id is ignored for insertion; unknown fields and authentication metadata are not stored. Omitted or null fields are skipped and database defaults apply. Blank text and explicit zero are supplied values, not omission. - Forces cdate to server time and normally supplies last_edited. Duplicate stable field IDs and invalid nested setJobStatus indexes are rejected. The map does not require a nonempty name or a usable form type, so an empty payload can create a mostly blank record.
- AutoDoc documents use the same uploaded-image policy and HTML normalization as mapped edits. Image-policy preflight precedes insertion; normalization runs after the actual new Form ID exists so stored assets belong to that form. Linked-table form_parents is synchronized before SQL commit.
Side effects
- Inserts the form, invalidates cache, saves Undo/history and synchronizes supported linked-table parents in one SQL transaction. Embedded image storage is outside SQL rollback and may retain assets after a later failure. This creation route does not dispatch mention notices.
See it in Fieldmotion
CRM1
No direct CRM1 production caller found. The form editor and imported-definition flow call Form_edit instead.
CRM2
No direct production caller found for Form_createData. The current Add Form and AI-create flows call Form_edit; existing mapped edits use Form_updateData. Filter those routes when reproducing the editor workflow.
Related endpoints
Form_edit— create through the full editor contract.Form_updateData— patch an existing mapped form.