Notification rules
Copy a notification rule
/a/NotificationType_copy
Create another rule from an existing rule’s configuration under a new name.
When to use this endpoint
Copy retains enabled status and recipients; disable the source/copy deliberately if duplicate future delivery is not intended.
Authentication and permissions
Use signed API-key authentication or a logged-in CRM session on the account’s routed host. API keys act as their owner; normal session requests need dispatcher CSRF protection where configured. Tenant data is selected from the authenticated account.
The handler has no additional page-action/Role check. A CRM2 screen hiding a control does not add such a server guard, and CRM2 role names must not be assumed to apply to CRM1. The dispatcher has no dedicated object-scope mapping for this namespace.
For tableName=quoteRecurring, create/full/eligible inline updates invoke the recurrence guard: recurringQuotes must be enabled and its existing Quotes View permission helper must pass. That helper is not replaced with a new CRM2-only rule here. Other notification catalogue routes have no comparable capability gate.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Nonzero source ID; missing, zero or no matching row is rejected. This is a rule ID, not a scheduled queue ID. |
name | Text | Yes | Trimmed; missing/blank/PHP-falsy name is rejected. Copy checks for an existing exact saved name; ordinary create does not perform that uniqueness check. |
Example request
$result = FM_api('NotificationType_copy', ['id'=>'18','name'=>'Job assigned copy']);
Example response
{
"ok": 1,
"id": 19
}
Application errors normally remain JSON responses with HTTP 200; inspect error/warning keys. Numeric driver values can be strings.
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 parameter: id"} | id missing/null. |
{"error":"missing parameter: name"} | name missing/null. |
{"error":"A notification - email of that name already exists"} | Saved name already exists. |
{"error":"invalid id parameter: Notification - Email could not be copied"} | Source row missing. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Copies subject, body, recipient, replyTo, tableName, status, type, format and meta through NotificationType_createData. It does not copy the source row ID/timestamps, queue records or delivery history.
- quoteRecurring rules only support format 0, type 2 and when.source nDate/eDate. Filters must be a native list of at most 100 safe mapped rules; hours must be a nonempty list of at most 64 numeric finite offsets with absolute value <=87600. sqlFilter is removed and evaluated safely by its worker. This does not apply the same validation to ordinary rules.
- The create helper’s metadata/filter normalization and configuration-history effects apply. Duplicate-name check and insert are not one transaction; concurrent copies can race.
Side effects
- Changed mapped values stamp last_edited, invalidate the table cache and write field-change history. Primary UPDATE acknowledgement is checked; history and later service calls are not one atomic save. No automatic retry/idempotency token is provided.
- Creates a separate configuration-history create event. Existing enabled status is preserved, so later matching events can schedule both rules; no immediate send occurs in this wrapper.
See it in Fieldmotion
CRM1
Settings > Notifications Email/Push uses mapped notificationType requests; Push requires the UI pushNotifications feature. UI-required names/subjects are stronger than the generic server map.
CRM2
Settings > Notifications, Email/Push: create/edit, inline status, Copy and Delete use the shared notificationType module and these routes. Inspect the request’s tableName/type/format and encoded recipient/meta.
Related endpoints
NotificationType_createData— Continue the related read/write workflow.NotificationTypes_getDataTable— Find rule IDs and configuration.