Form definitions, recorded responses and exports
Save a full form editor definition
/a/Form_edit
Create or replace a Form editor definition, including fields, legacy automation and report settings.
When to use this endpoint
Use with a full editor payload. For a small change that must preserve omitted values, use Form_updateData instead. Save existing values for fields and report settings before assembling this request.
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.
Existing positive-ID saves require Forms Edit with no legacy role-less allowance. Creation with id=0 does not invoke that settings permission guard.
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 |
|---|---|---|---|
id | Nonnegative integer-compatible ID | No | Defaults 0 to create. A positive ID edits; negative is rejected. Existing edits require Forms Edit. |
name | Truthy text without | | Yes | Display name; blank and "0" fail. Pipe characters are rejected. |
type, report_type | Integer-compatible modes | No | Both default 0. Current type codes: 0 Job, 3 Job Table, 4 Quote, 5 Purchase Order, 6 Quote Table, 7 Invoice, 8 Invoice Table, 9 Opportunity, 10 Opportunity Table. This handler does not enforce that list. |
fields | Native array or JSON array text | No | Full field list. Omitted/malformed/empty input becomes an empty list. Nameless definitions are removed; duplicate nonempty stable meta.id values are rejected. |
replyto | Email text | No | Invalid or omitted address becomes no-reply@fieldmotion.com. |
template, theme | Text | No | Both default empty. theme is stored in meta. |
email_template_id | Integer-compatible ID | No | Defaults 0; unlike the mapped route, this name is snake_case. |
onComplete | Serialized JSON text | No | Whole legacy automation definition; defaults empty when saved. Ignored while Workflows is enabled, and skipped by onlyField. |
autodocs | Serialized JSON text | No | Whole AutoDoc configuration; defaults empty, unless onlyField skips it. |
report_doc | JSON text | No | AutoDoc header/body/footer HTML. Defaults to an empty normalized document, unless onlyField. Uploaded image policy and normalization apply. |
disable_pdf_conversion, disable_doc_export, send_notification, do_not_update_stock_levels, do_not_add_stock_to_job_costs | Integer-compatible switches | No | Stored metadata toggles; omission resets each to 0. These configure later workflows; the save does not execute them. |
docx_export | Flag | No | When present, 1/"1"/true enables meta.docx-export; other values disable it. Omission preserves saved state; new forms default off. |
hide_from_job_history | 0/1, string 0/1 or boolean | No | When provided, saves 0/1; omission preserves. Other values, including null, are rejected. |
slots | Stored value | No | If set, replaces meta.slots; omission/null preserves. |
required_skills | JSON text | No | If set, JSON-decoded into meta.required_skills; omission/null preserves. |
attach_reports_inline_on_emails | Empty, link or attach | No | If set, empty removes this metadata override, link/attach save it; other values fail. Omission preserves. |
phpdocx_version | Number | No | If set, float-converted and saved; omission preserves. |
onlyField | Integer-compatible legacy flag | No | Nonzero skips only automation/AutoDoc report assignments. It still overwrites other full-editor values and fields; avoid using it as a generic patch control. |
Example request
$form = FM_api('Form_edit', [
'id'=>'0','name'=>'Inspection','type'=>'0','report_type'=>'1',
'fields'=>[['name'=>'Result','type'=>'input','meta'=>json_encode(['id'=>1042001])]],
'onComplete'=>'[]','autodocs'=>'[]',
'report_doc'=>json_encode(['header'=>'','body'=>'<p>Inspection</p>','footer'=>'']),
]);
Example response
{"id":1088,"ok":1}
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":"missing or invalid parameter: name"} | Name absent, blank or falsey. |
{"error":"you cannot use the | symbol in your form name"} | Name contains a pipe. |
{"error":"form does not exist"} | Positive ID does not match a form. |
{"error":"permission denied"} | Existing form edit lacks Forms Edit. |
{"error":"invalid parameter: hide_from_job_history"} | Unsupported history flag. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Omission semantics are destructive for full lists and defaulted settings. onlyField does not preserve name/type/template/fields/replyto/report_type or the always-written metadata toggles.
- Existing metadata is retained before explicitly overwritten keys are applied. Optional docx_export and hide_from_job_history preserve omitted values. New rows are initially inserted with portal_visibility=1 and server cdate.
- When Workflows is off, validates nested setJobStatus values before saving on_complete. When Workflows is enabled, skips both that legacy automation assignment and its validation, preserving the existing stored definition.
- AutoDoc image policy runs before normalization. Scripts/iframes, meta tags and event attributes are removed/disabled; embedded images can be resized and stored as form assets. Unsupported remote image references are rejected, while ordinary hyperlinks remain permitted.
- Normalizes Asset field filter metadata, saves last_edited, synchronizes linked-table form_parents and records history. It does not rename/migrate historical Job answers. No list filtering or pagination applies.
Side effects
- Validates attach_reports_inline_on_emails before inserting a new row or normalizing images. The definition, supported parent links, Undo baseline/snapshot and history are saved inside the checked SQL transaction; failed primary writes do not continue or claim success. Normalized image assets are external and can remain after SQL rollback.
See it in Fieldmotion
CRM1
Open Forms → edit a Form, change its fields or report configuration and Save. Filter Form_edit; the editor sends the full field array and snake_case settings. Imported definition creation also uses this route.
CRM2
The Form editor’s Save and AI-create flow call Form_edit. AutoDoc partial saves instead use Form_updateData. Compare report_doc here with autodocsDoc in that mapped route.
Related endpoints
Form_updateData— patch supplied fields while retaining omissions.Form_copy— duplicate a saved definition.