Contract types
Create a contract type through the field map
/a/ContractType_createData
Create a contract classification through CRM2’s named field map, including its invoicing rule and low-level metadata.
When to use this endpoint
Use ContractType_createData for CRM2’s Contract Types create dialog. For the older name-only CRM1 workflow, use ContractTypes_new.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler has no page, role, or feature-bit check.
CRM1 and CRM2 show contract management only when tenant feature bit 64 is enabled, but this API does not enforce that setting.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | No | Type name, limited to 64 Unicode characters. The map does not require a nonblank name and does not check uniqueness. |
disableInvoicing | Integer string | No | Stored disable_invoicing value after integer conversion; defaults to 0. CRM2 labels 0 Invoiceable Yes and 1 Invoiceable No. Other integers are accepted. |
lastEdited | Datetime string | No | Stored timestamp. The endpoint supplies current server time when omitted; the string is not date-validated. |
meta | String or JSON-compatible value | No | Complete raw metadata text. Arrays/objects are JSON-encoded by the shared helper; strings are stored verbatim. |
id | Any | No | Ignored during creation even though it exists in the read/update map. |
Example request
$created = FM_api('ContractType_createData', [
'name' => 'Planned maintenance',
'disableInvoicing' => '0',
]);
Example response
{
"ok": 1,
"id": 31
}
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":"name is too long."} | name exceeds 64 Unicode characters. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Unknown request keys and
idare ignored. Integer input is coerced with PHP integer conversion. - The table has no deleted/status column. This operation performs one insert and has no filtering or pagination.
Side effects
- Inserts the tenant row, invalidates the contract-type cache, and writes generic audit entries for accepted/defaulted fields.
- It does not create contracts, change existing contracts, or send notifications.
See it in Fieldmotion
CRM1
No production CRM1 caller was found. CRM1’s Contract Types Create dialog calls ContractTypes_new.
CRM2
Open Contracts → Types with Contracts enabled and create a row. The shared display widget derives ContractType_createData from its API prefix.
Related endpoints
ContractType_updateDataupdates the same mapped fields.ContractTypes_getDataTablesupplies CRM2’s list.