Marketing
Create a mapped lead source
/a/MarketingSource_createData
Create a lead-source option through the mapped CRM2 writer, including timestamps and field-level history.
When to use this endpoint
Use MarketingSource_createData for CRM2’s create workflow or when the new row ID is required. The legacy MarketingSource_new route returns success without the ID.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login but performs no additional Marketing-page, create, edit, delete, or role-permission check.
All reads and writes use the authenticated tenant’s tables. CRM1 and CRM2 hide some controls through client-side permissions; these routes do not repeat those UI checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible or native array | No | Ignored for creation; the database assigns the ID. |
name | String | Yes | Lead-source name, maximum 100 characters. It must be nonempty during mapped creation. |
createDate | Unix timestamp or date string | No | Mapped creation time stored as a Unix timestamp. Creation defaults to the current server time; nonnumeric strings are parsed with strtotime(). |
lastEdited | Unix timestamp or date string | No | Mapped edit time stored as a Unix timestamp. Creation defaults to now and ordinary updates advance it automatically. |
Example request
$source = FM_api('MarketingSource_createData', [
'name' => 'Trade show',
]);
Example response
{"ok":1,"id":30124}
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 is absent or blank. |
{"error":"name is too long."} | The name exceeds 100 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
- No duplicate-name check is performed. Names that differ only by case, or exact duplicates, can coexist.
createDateandlastEditeddefault to the current server Unix timestamp when omitted.- Marketing-source rows have no active or soft-delete flag.
Side effects
- Inserts the tenant row, invalidates the marketing-source cache, and writes Core history entries for supplied/defaulted fields.
See it in Fieldmotion
CRM1
CRM1’s Source Create dialog calls MarketingSource_new, not this mapped route.
CRM2
Open Marketing → Marketing Lead Source in CRM2 and filter browser developer tools for the exact function name. Choose Create; the shared display widget derives MarketingSource_createData from the page API prefix.
Related endpoints
MarketingSource_getRequestedDetailsreads the stored mapped row.MarketingSource_newis the legacy create alternative.