Contract types
Create a contract type
POST
/a/ContractTypes_new
Create the name-only contract type used by CRM1’s Contract Types dialog.
When to use this endpoint
Use ContractTypes_new when reproducing CRM1’s simple create flow. CRM2 uses ContractType_createData.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. No role, page, or Contracts feature-bit check is performed.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Trimmed nonblank name, maximum 64 Unicode characters. HTML is not stripped and duplicate names are accepted. |
Example request
$created = FM_api('ContractTypes_new', [
'name' => 'Warranty',
]);
Example response
{
"ret": [
{"ok": 1, "id": 32}
]
}
The singular insert is wrapped in the legacy ret array; callers must read ret[0].id.
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"} | The name key is absent or trims to blank. |
{"error":"parameter too long: name. max length 64 characters"} | The trimmed 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
disable_invoicingis set to0andlast_editedto current server time. Metadata is left null/default.- The route does not check duplicate names. There is no filtering or pagination.
Side effects
- Inserts one tenant row. Unlike the mapped create helper, this legacy route does not request cache invalidation or write a generic audit entry.
See it in Fieldmotion
CRM1
Open Contracts → Contract Types, choose Create, enter a name, and inspect ContractTypes_new.
CRM2
A production-source search found no normal CRM2 caller. CRM2’s shared display uses ContractType_createData.
Related endpoints
ContractType_createDataalso accepts invoicing behavior and metadata.ContractType_editis CRM1’s rename counterpart.