> For the complete documentation index, see [llms.txt](https://docs.fieldmotion.com/fieldmotion-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fieldmotion.com/fieldmotion-api-docs/notificationtype/_createdata.md).

# \_createData

Creates a new Notification Type.

### Parameter

#### name

The name for the created Notification Type.

#### type

The action which will cause a Notification to be sent:

* 0 = create
* 1 = update
* 2 = time

#### tableName

The area in relation to the created Notification Type, can be set to one of the following:

* asset
* contract
* customer
* file
* invoice
* job
* jobRecurring
* opportunity
* purchaseOrder
* quote
* requisitionOrder
* task

#### recipient

An array which sets who will receive the Notification, can be set to the assigned User, Creator, and the previous User in relation to what the notification is about in the "tableName" parameter.\
e.g \['user'=>'1','creator'=>'1','other'=>'1']

#### replyTo

An email for recipients to send replies to. Only used in Email Notifications specifically.

#### subject

What the subject header of the Notification will be.

#### body

A message field for the Notification to include under the Subject heading.

#### format

An integer parameter related to the channel of which this Notification is being made for.\
0 = Email Notification\
3 = Push Notification

#### meta

An array which can include other potential values depending on the sort of Notification being created, see Examples section below.

#### status

Sets whether the Notification will already be Enabled upon creation or disabled. (0 = Disabled, 1 = Enabled)

### Examples

An example of an Email Notification.

```
FM_api('NotificationType_createData',[
      'name' => 'Test Email Notification',
      'type' => '0',
      'tableName' => 'job',
      'recipient' => ['other'=>'','user'=>'1','creator'=>'1'],
      'replyTo' => 'questions_test@gmail.com',
      'subject' => 'Created Job',
      'body' => 'A new job has been created.',
      'format' => '0',
      'meta' => [
                  'when' => [
                              'hours' => [''],
                              'source' => ''
                            ],
                  'platform' => 'app',
                  'template_formbased' => '0',
                  'job_type' => ['150001'],
                  'template_formbased_setup' => ['template'],
                  'body' => ''
      ],
      'status' => '0'
    ]
);
```

A Push Notification for when a Job is created, to be sent to the User assigned and also the creator of the Job.

```
FM_api('NotificationType_createData',[
      'name' => 'Test Job Notification',
      'type' => '0',
      'tableName' => 'job',
      'recipient' => ['other'=>'','user'=>'1','creator'=>'1'],
      'subject' => 'Created Job',
      'body' => 'A new job has been created.',
      'format' => '3',
      'meta' => [
                  'when' => [
                              'hours' => [''],
                              'source' => ''
                            ],
                  'platform' => 'app'
      ],
      'status' => '1'
    ]
);
```

An example of a Push Notification to be sent when a Job Recurrence receives an update, sent to the assigned User and the creator of the Recurrence.

```
FM_api('NotificationType_createData',[
      'name' => 'Test Job Recurrence Notification',
      'type' => '1',
      'tableName' => 'jobRecurring',
      'recipient' => ['user'=>'1','creator'=>'1'],
      'subject' => 'Update to Recurrence',
      'body' => 'test message.',
      'format' => '3',
      'meta' => [
                  'when' => [
                              'hours' => [''],
                              'source' => 'UserID',
                              'from' => [
                                        'id' => '113747',
                                        'name' => 'UserName',
                                        'department' => [],
                                        'roleID' => '30001',
                                        'email' => 'test_useremail@gmail.com',
                                        'gpsCreateDate' => '2026-06-16 10:28:51',
                                        'gpsLatitude' => '54.3721',
                                        'gpsLongitude' => '-4.7292',
                                        'type' => '0',
                                        'typeName' => 'user'
                              ],
                              'to' => [
                                        'id' => '113763',
                                        'name' => 'UserName 2',
                                        'department' => [],
                                        'roleID' => '30001',
                                        'email' => 'test_useremail@gmail.com',
                                        'gpsCreateDate' => '2026-06-23 07:47:39',
                                        'gpsLatitude' => '54.3721',
                                        'gpsLongitude' => '-4.7292',
                                        'type' => '0',
                                        'typeName' => 'user'
                              ],
                            ],
                  'platform' => 'web',
                  'job_type' => ['150002']
      ],
      'status' => '0'
    ]
);
```

### Results

#### On Success

```
{"ok":1,"id":360006}
```

#### On Failure

If the "name" parameter is not set:

```
{"error":"missing or invalid parameter: name"}
```

If the "subject" parameter is not set:

```
{"error":"missing or invalid parameter: subject"}
```
