> This page is for Developers.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.emnify.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emnify.com/_mcp/server.

# Create an automation

POST https://cdn.emnify.net/api/v1/automation
Content-Type: application/json

Creates an automation with the configured event and selected actions, respecting the configured targets.


Reference: https://docs.emnify.com/developers/api/automations/create-automation

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an AutomationCreateDto.

- `name` (string, required)
- `description` (string, required)
- `status` (string, required)
- `actionable_event` (ActionableEventCreateDto, required)
- `configured_actions` (list of ConfiguredActionCreateDto, required)
- `targeting_properties` (list of ConfigurationInputPropertiesDto, required)

## Response

### 201

- `id` (string, required)
- `name` (string, required)
- `description` (string, required)
- `status` (string, required)
- `organisation` (WithIdInputDto, required)
- `number_of_executions` (double, required)
- `last_execution` (string, required)
- `created_at` (string, required)
- `modified_at` (string, required)
- `actionable_event` (ActionableEventOutputDto, required)
- `configured_actions` (list of ConfiguredActionOutputDto, required)
- `targeting_properties` (list of ConfigurationInputPropertiesDto, required)

## Errors

### 400 Bad Request Error

The request body is invalid, or the request breaks one of the API's limits or rules. For example, the organization already has the maximum of 50 automations. The API also rejects a request that configures more than four actions or the same action twice, uses an action or targeting property the event doesn't support, schedules an automation without targeting properties, or sets an invalid action or event configuration property.

- `status_code` (integer, required) — HTTP status code of the response
- `message` (ErrorResponseMessage, required) — A human-readable reason for the error. Request-body validation failures list one entry per violated constraint.

### 403 Forbidden Error

You don't have permission to create automations.

- `status_code` (integer, required) — HTTP status code of the response
- `message` (ErrorResponseMessage, required) — A human-readable reason for the error. Request-body validation failures list one entry per violated constraint.

### 404 Not Found Error

The system event, custom event, or action doesn't exist, or isn't available to your organization.

- `status_code` (integer, required) — HTTP status code of the response
- `message` (ErrorResponseMessage, required) — A human-readable reason for the error. Request-body validation failures list one entry per violated constraint.

## Types

### ActionableEventCreateDto

- `custom_event` (WithUuidInputDto, required)
- `system_event` (WithUuidInputDto, required)

### ConfiguredActionCreateDto

- `action` (ConfiguredActionReferenceDto, required)
- `properties` (list of ConfigurationInputPropertiesDto, required)

### ConfigurationInputPropertiesDto

- `property` (string, required)
- `value` (string, required)
- `value_array` (list of string, required)

### WithIdInputDto

- `id` (double, required)

### ActionableEventOutputDto

- `custom_event` (CustomEventOutputDto, required)
- `system_event` (SystemEventOutputDto, required)

### ConfiguredActionOutputDto

- `action` (WithUuidInputDto, required)
- `properties` (list of ConfigurationInputPropertiesDto, required)
- `recipients` (ConfiguredActionRecipientOutputDto, required) — Details of the email notification recipients configured for the action.

### ErrorResponseMessage

A human-readable reason for the error. Request-body validation failures list one entry per violated constraint.

- string
- list of string

### WithUuidInputDto

- `id` (string, required)

### ConfiguredActionReferenceDto

- `id` (string, required)
- `type` (string, optional)

### CustomEventOutputDto

- `organisation` (WithIdInputDto, required)
- `template` (WithIdInputDto, required)
- `configuration_properties` (list of ConfigurationInputPropertiesDto, required)
- `name` (string, required)
- `id` (string, required)
- `supportedTargetingParameters` (list of string, required)
- `supportedActions` (list of string, required)
- `supported_action_ids` (list of string, optional) — Action IDs this event declares support for, used to decide which actions are offered for it. - Field absent: no restriction is declared, so every action whose `required_event_output_parameters` the event emits is offered. - Empty array: a declaration in its own right, so no actions are offered. - Non-empty list: intersected with the parameter check, so a listed action is offered only if the event also emits every parameter that action requires. The list can only narrow what's offered, never widen it.

### SystemEventOutputDto

- `id` (string, required)
- `parentOrg` (WithIdInputDto, required)
- `eventType` (WithIdInputDto, required)
- `name` (string, required)
- `translationKeyName` (string, required)
- `description` (string, required)
- `translationKeyDescription` (string, required)
- `supportedTargetingParameters` (list of string, required)
- `eventOutputParameters` (list of ConfigurationParameterDto, required)
- `supportedActions` (list of string, required)
- `supported_action_ids` (list of string, optional) — Action IDs this event declares support for, used to decide which actions are offered for it. - Field absent: no restriction is declared, so every action whose `required_event_output_parameters` the event emits is offered. - Empty array: a declaration in its own right, so no actions are offered. - Non-empty list: intersected with the parameter check, so a listed action is offered only if the event also emits every parameter that action requires. The list can only narrow what's offered, never widen it.

### ConfiguredActionRecipientOutputDto

- `email` (list of string, required)

### ConfigurationParameterDto

- `parameter` (string, required)
- `type` (enum, required)
  - Allowed values: `string`, `string[]`, `number`, `number[]`, `boolean`, `boolean[]`, `email`, `email[]`, `severity`, `percentage`, `megabytes`, `megabytes[]`, `tariff_id`, `tariff_id[]`, `ratezone`, `ratezone[]`, `service_profile_id`, `service_profile_id[]`, `tariff_profile_id`, `tariff_profile_id[]`, `tag_id`, `tag_id[]`, `recurrence`, `time`, `date`, `minute`
- `description` (string, required)

## Examples

### Automations_createAutomation_example

**Response**

```json
{
  "id": "56",
  "name": "Endpoint data traffic limit warning email",
  "description": "Sends an email when the endpoint data traffic limit warning is triggered for service profile 3.\n",
  "status": "active",
  "organisation": {
    "id": 1550
  },
  "number_of_executions": 3,
  "last_execution": "2025-01-01T00:00:00.000Z",
  "created_at": "2024-01-01T03:00:00.000Z",
  "modified_at": "2024-05-06T05:00:00.000Z",
  "actionable_event": {
    "custom_event": {
      "organisation": {
        "id": 1.1
      },
      "template": {
        "id": 1.1
      },
      "configuration_properties": [
        {
          "property": "string",
          "value": "string",
          "value_array": [
            "string"
          ]
        }
      ],
      "name": "string",
      "id": "string",
      "supportedTargetingParameters": [
        "string"
      ],
      "supportedActions": [
        "string"
      ]
    },
    "system_event": {
      "id": "605",
      "parentOrg": {
        "id": 1.1
      },
      "eventType": {
        "id": 1.1
      },
      "name": "Endpoint data traffic limit warning",
      "translationKeyName": "string",
      "description": "Endpoint data traffic limit warning",
      "translationKeyDescription": "string",
      "supportedTargetingParameters": [
        "string"
      ],
      "eventOutputParameters": [
        {
          "parameter": "string",
          "type": "string",
          "description": "string"
        }
      ],
      "supportedActions": [
        "string"
      ],
      "event_type": {
        "id": 65
      },
      "parent_organisation": {
        "id": 2
      },
      "supported_actions": [
        {
          "configuration_properties": [
            {
              "default": null,
              "description": "List of email addresses to notify",
              "property": "recipients",
              "required": true,
              "type": "email[]"
            }
          ],
          "description": "Send notification via email",
          "id": "system-send_notification_with_email",
          "name": "Send notification via email",
          "required_event_output_parameters": [
            {
              "description": "Standard description of the event",
              "parameter": "event_description",
              "type": "string"
            }
          ],
          "status": "active",
          "translation_key_description": "Send notification with email D",
          "translation_key_name": "Send notification with email N",
          "type": "system"
        }
      ],
      "supported_targeting_parameters": [
        {
          "description": "Service Policy",
          "parameter": "service_policy",
          "type": "number[]"
        },
        {
          "description": "Endpoint Tag",
          "parameter": "endpoint_tag",
          "type": "string[]",
          "validators": [
            {
              "type": "minCount",
              "value": 1
            }
          ]
        }
      ],
      "translation_key_description": "endpoint_data_traffic_limit_warning_d",
      "translation_key_name": "endpoint_data_traffic_limit_warning_n"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email",
        "configuration_properties": [
          {
            "default": null,
            "description": "List of email addresses to notify",
            "property": "recipients",
            "required": true,
            "type": "email[]"
          }
        ],
        "description": "Send notification with email",
        "name": "Send notification with email",
        "required_event_output_parameters": [
          {
            "description": "Standard description of the event",
            "parameter": "event_description",
            "type": "string"
          }
        ],
        "status": "active",
        "translation_key_description": "Send notification with email D",
        "translation_key_name": "Send notification with email N",
        "type": "system"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ],
      "recipients": {
        "email": [
          "string"
        ]
      }
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "3"
      ]
    }
  ],
  "created_by": {
    "id": 1,
    "name": "John Doe"
  }
}
```

**SDK Code**

```python Automations_createAutomation_example
import requests

url = "https://cdn.emnify.net/api/v1/automation"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Automations_createAutomation_example
const url = 'https://cdn.emnify.net/api/v1/automation';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Automations_createAutomation_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://cdn.emnify.net/api/v1/automation"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Automations_createAutomation_example
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/automation")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Automations_createAutomation_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/automation")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Automations_createAutomation_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/automation', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Automations_createAutomation_example
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/automation");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Automations_createAutomation_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://cdn.emnify.net/api/v1/automation")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Custom Event

**Request**

```json
{
  "name": "Send email notification for custom event",
  "description": "Sends a notification via Email for custom event.\n",
  "status": "active",
  "actionable_event": {
    "custom_event": {
      "id": "2"
    },
    "system_event": {
      "id": "string"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ]
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "2"
      ]
    }
  ]
}
```

**Response**

```json
{
  "id": "56",
  "name": "Endpoint data traffic limit warning email",
  "description": "Sends an email when the endpoint data traffic limit warning is triggered for service profile 3.\n",
  "status": "active",
  "organisation": {
    "id": 1550
  },
  "number_of_executions": 3,
  "last_execution": "2025-01-01T00:00:00.000Z",
  "created_at": "2024-01-01T03:00:00.000Z",
  "modified_at": "2024-05-06T05:00:00.000Z",
  "actionable_event": {
    "custom_event": {
      "organisation": {
        "id": 1.1
      },
      "template": {
        "id": 1.1
      },
      "configuration_properties": [
        {
          "property": "string",
          "value": "string",
          "value_array": [
            "string"
          ]
        }
      ],
      "name": "string",
      "id": "string",
      "supportedTargetingParameters": [
        "string"
      ],
      "supportedActions": [
        "string"
      ]
    },
    "system_event": {
      "id": "605",
      "parentOrg": {
        "id": 1.1
      },
      "eventType": {
        "id": 1.1
      },
      "name": "Endpoint data traffic limit warning",
      "translationKeyName": "string",
      "description": "Endpoint data traffic limit warning",
      "translationKeyDescription": "string",
      "supportedTargetingParameters": [
        "string"
      ],
      "eventOutputParameters": [
        {
          "parameter": "string",
          "type": "string",
          "description": "string"
        }
      ],
      "supportedActions": [
        "string"
      ],
      "event_type": {
        "id": 65
      },
      "parent_organisation": {
        "id": 2
      },
      "supported_actions": [
        {
          "configuration_properties": [
            {
              "default": null,
              "description": "List of email addresses to notify",
              "property": "recipients",
              "required": true,
              "type": "email[]"
            }
          ],
          "description": "Send notification via email",
          "id": "system-send_notification_with_email",
          "name": "Send notification via email",
          "required_event_output_parameters": [
            {
              "description": "Standard description of the event",
              "parameter": "event_description",
              "type": "string"
            }
          ],
          "status": "active",
          "translation_key_description": "Send notification with email D",
          "translation_key_name": "Send notification with email N",
          "type": "system"
        }
      ],
      "supported_targeting_parameters": [
        {
          "description": "Service Policy",
          "parameter": "service_policy",
          "type": "number[]"
        },
        {
          "description": "Endpoint Tag",
          "parameter": "endpoint_tag",
          "type": "string[]",
          "validators": [
            {
              "type": "minCount",
              "value": 1
            }
          ]
        }
      ],
      "translation_key_description": "endpoint_data_traffic_limit_warning_d",
      "translation_key_name": "endpoint_data_traffic_limit_warning_n"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email",
        "configuration_properties": [
          {
            "default": null,
            "description": "List of email addresses to notify",
            "property": "recipients",
            "required": true,
            "type": "email[]"
          }
        ],
        "description": "Send notification with email",
        "name": "Send notification with email",
        "required_event_output_parameters": [
          {
            "description": "Standard description of the event",
            "parameter": "event_description",
            "type": "string"
          }
        ],
        "status": "active",
        "translation_key_description": "Send notification with email D",
        "translation_key_name": "Send notification with email N",
        "type": "system"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ],
      "recipients": {
        "email": [
          "string"
        ]
      }
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "3"
      ]
    }
  ],
  "created_by": {
    "id": 1,
    "name": "John Doe"
  }
}
```

**SDK Code**

```python Custom Event
import requests

url = "https://cdn.emnify.net/api/v1/automation"

payload = {
    "name": "Send email notification for custom event",
    "description": "Sends a notification via Email for custom event.
",
    "status": "active",
    "actionable_event": {
        "custom_event": { "id": "2" },
        "system_event": { "id": "string" }
    },
    "configured_actions": [
        {
            "action": { "id": "system-send_notification_with_email" },
            "properties": [
                {
                    "property": "recipients",
                    "value": "string",
                    "value_array": ["foo@bar.emnify"]
                }
            ]
        }
    ],
    "targeting_properties": [
        {
            "property": "service_policy",
            "value": "string",
            "value_array": ["2"]
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Custom Event
const url = 'https://cdn.emnify.net/api/v1/automation';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Send email notification for custom event","description":"Sends a notification via Email for custom event.\n","status":"active","actionable_event":{"custom_event":{"id":"2"},"system_event":{"id":"string"}},"configured_actions":[{"action":{"id":"system-send_notification_with_email"},"properties":[{"property":"recipients","value":"string","value_array":["foo@bar.emnify"]}]}],"targeting_properties":[{"property":"service_policy","value":"string","value_array":["2"]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Custom Event
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://cdn.emnify.net/api/v1/automation"

	payload := strings.NewReader("{\n  \"name\": \"Send email notification for custom event\",\n  \"description\": \"Sends a notification via Email for custom event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"2\"\n    },\n    \"system_event\": {\n      \"id\": \"string\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"2\"\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Custom Event
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/automation")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Send email notification for custom event\",\n  \"description\": \"Sends a notification via Email for custom event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"2\"\n    },\n    \"system_event\": {\n      \"id\": \"string\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"2\"\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Custom Event
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/automation")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Send email notification for custom event\",\n  \"description\": \"Sends a notification via Email for custom event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"2\"\n    },\n    \"system_event\": {\n      \"id\": \"string\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"2\"\n      ]\n    }\n  ]\n}")
  .asString();
```

```php Custom Event
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/automation', [
  'body' => '{
  "name": "Send email notification for custom event",
  "description": "Sends a notification via Email for custom event.\\n",
  "status": "active",
  "actionable_event": {
    "custom_event": {
      "id": "2"
    },
    "system_event": {
      "id": "string"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ]
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "2"
      ]
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Custom Event
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/automation");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Send email notification for custom event\",\n  \"description\": \"Sends a notification via Email for custom event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"2\"\n    },\n    \"system_event\": {\n      \"id\": \"string\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"2\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Custom Event
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Send email notification for custom event",
  "description": "Sends a notification via Email for custom event.
",
  "status": "active",
  "actionable_event": [
    "custom_event": ["id": "2"],
    "system_event": ["id": "string"]
  ],
  "configured_actions": [
    [
      "action": ["id": "system-send_notification_with_email"],
      "properties": [
        [
          "property": "recipients",
          "value": "string",
          "value_array": ["foo@bar.emnify"]
        ]
      ]
    ]
  ],
  "targeting_properties": [
    [
      "property": "service_policy",
      "value": "string",
      "value_array": ["2"]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://cdn.emnify.net/api/v1/automation")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### System Event

**Request**

```json
{
  "name": "Send email notification for system event",
  "description": "Sends a notification via email for system event.\n",
  "status": "active",
  "actionable_event": {
    "custom_event": {
      "id": "string"
    },
    "system_event": {
      "id": "69"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ]
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "3"
      ]
    }
  ]
}
```

**Response**

```json
{
  "id": "56",
  "name": "Endpoint data traffic limit warning email",
  "description": "Sends an email when the endpoint data traffic limit warning is triggered for service profile 3.\n",
  "status": "active",
  "organisation": {
    "id": 1550
  },
  "number_of_executions": 3,
  "last_execution": "2025-01-01T00:00:00.000Z",
  "created_at": "2024-01-01T03:00:00.000Z",
  "modified_at": "2024-05-06T05:00:00.000Z",
  "actionable_event": {
    "custom_event": {
      "organisation": {
        "id": 1.1
      },
      "template": {
        "id": 1.1
      },
      "configuration_properties": [
        {
          "property": "string",
          "value": "string",
          "value_array": [
            "string"
          ]
        }
      ],
      "name": "string",
      "id": "string",
      "supportedTargetingParameters": [
        "string"
      ],
      "supportedActions": [
        "string"
      ]
    },
    "system_event": {
      "id": "605",
      "parentOrg": {
        "id": 1.1
      },
      "eventType": {
        "id": 1.1
      },
      "name": "Endpoint data traffic limit warning",
      "translationKeyName": "string",
      "description": "Endpoint data traffic limit warning",
      "translationKeyDescription": "string",
      "supportedTargetingParameters": [
        "string"
      ],
      "eventOutputParameters": [
        {
          "parameter": "string",
          "type": "string",
          "description": "string"
        }
      ],
      "supportedActions": [
        "string"
      ],
      "event_type": {
        "id": 65
      },
      "parent_organisation": {
        "id": 2
      },
      "supported_actions": [
        {
          "configuration_properties": [
            {
              "default": null,
              "description": "List of email addresses to notify",
              "property": "recipients",
              "required": true,
              "type": "email[]"
            }
          ],
          "description": "Send notification via email",
          "id": "system-send_notification_with_email",
          "name": "Send notification via email",
          "required_event_output_parameters": [
            {
              "description": "Standard description of the event",
              "parameter": "event_description",
              "type": "string"
            }
          ],
          "status": "active",
          "translation_key_description": "Send notification with email D",
          "translation_key_name": "Send notification with email N",
          "type": "system"
        }
      ],
      "supported_targeting_parameters": [
        {
          "description": "Service Policy",
          "parameter": "service_policy",
          "type": "number[]"
        },
        {
          "description": "Endpoint Tag",
          "parameter": "endpoint_tag",
          "type": "string[]",
          "validators": [
            {
              "type": "minCount",
              "value": 1
            }
          ]
        }
      ],
      "translation_key_description": "endpoint_data_traffic_limit_warning_d",
      "translation_key_name": "endpoint_data_traffic_limit_warning_n"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email",
        "configuration_properties": [
          {
            "default": null,
            "description": "List of email addresses to notify",
            "property": "recipients",
            "required": true,
            "type": "email[]"
          }
        ],
        "description": "Send notification with email",
        "name": "Send notification with email",
        "required_event_output_parameters": [
          {
            "description": "Standard description of the event",
            "parameter": "event_description",
            "type": "string"
          }
        ],
        "status": "active",
        "translation_key_description": "Send notification with email D",
        "translation_key_name": "Send notification with email N",
        "type": "system"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ],
      "recipients": {
        "email": [
          "string"
        ]
      }
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "3"
      ]
    }
  ],
  "created_by": {
    "id": 1,
    "name": "John Doe"
  }
}
```

**SDK Code**

```python System Event
import requests

url = "https://cdn.emnify.net/api/v1/automation"

payload = {
    "name": "Send email notification for system event",
    "description": "Sends a notification via email for system event.
",
    "status": "active",
    "actionable_event": {
        "custom_event": { "id": "string" },
        "system_event": { "id": "69" }
    },
    "configured_actions": [
        {
            "action": { "id": "system-send_notification_with_email" },
            "properties": [
                {
                    "property": "recipients",
                    "value": "string",
                    "value_array": ["foo@bar.emnify"]
                }
            ]
        }
    ],
    "targeting_properties": [
        {
            "property": "service_policy",
            "value": "string",
            "value_array": ["3"]
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript System Event
const url = 'https://cdn.emnify.net/api/v1/automation';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Send email notification for system event","description":"Sends a notification via email for system event.\n","status":"active","actionable_event":{"custom_event":{"id":"string"},"system_event":{"id":"69"}},"configured_actions":[{"action":{"id":"system-send_notification_with_email"},"properties":[{"property":"recipients","value":"string","value_array":["foo@bar.emnify"]}]}],"targeting_properties":[{"property":"service_policy","value":"string","value_array":["3"]}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go System Event
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://cdn.emnify.net/api/v1/automation"

	payload := strings.NewReader("{\n  \"name\": \"Send email notification for system event\",\n  \"description\": \"Sends a notification via email for system event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"string\"\n    },\n    \"system_event\": {\n      \"id\": \"69\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"3\"\n      ]\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby System Event
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/automation")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Send email notification for system event\",\n  \"description\": \"Sends a notification via email for system event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"string\"\n    },\n    \"system_event\": {\n      \"id\": \"69\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"3\"\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java System Event
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/automation")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Send email notification for system event\",\n  \"description\": \"Sends a notification via email for system event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"string\"\n    },\n    \"system_event\": {\n      \"id\": \"69\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"3\"\n      ]\n    }\n  ]\n}")
  .asString();
```

```php System Event
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/automation', [
  'body' => '{
  "name": "Send email notification for system event",
  "description": "Sends a notification via email for system event.\\n",
  "status": "active",
  "actionable_event": {
    "custom_event": {
      "id": "string"
    },
    "system_event": {
      "id": "69"
    }
  },
  "configured_actions": [
    {
      "action": {
        "id": "system-send_notification_with_email"
      },
      "properties": [
        {
          "property": "recipients",
          "value": "string",
          "value_array": [
            "foo@bar.emnify"
          ]
        }
      ]
    }
  ],
  "targeting_properties": [
    {
      "property": "service_policy",
      "value": "string",
      "value_array": [
        "3"
      ]
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp System Event
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/automation");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Send email notification for system event\",\n  \"description\": \"Sends a notification via email for system event.\\n\",\n  \"status\": \"active\",\n  \"actionable_event\": {\n    \"custom_event\": {\n      \"id\": \"string\"\n    },\n    \"system_event\": {\n      \"id\": \"69\"\n    }\n  },\n  \"configured_actions\": [\n    {\n      \"action\": {\n        \"id\": \"system-send_notification_with_email\"\n      },\n      \"properties\": [\n        {\n          \"property\": \"recipients\",\n          \"value\": \"string\",\n          \"value_array\": [\n            \"foo@bar.emnify\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"targeting_properties\": [\n    {\n      \"property\": \"service_policy\",\n      \"value\": \"string\",\n      \"value_array\": [\n        \"3\"\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift System Event
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Send email notification for system event",
  "description": "Sends a notification via email for system event.
",
  "status": "active",
  "actionable_event": [
    "custom_event": ["id": "string"],
    "system_event": ["id": "69"]
  ],
  "configured_actions": [
    [
      "action": ["id": "system-send_notification_with_email"],
      "properties": [
        [
          "property": "recipients",
          "value": "string",
          "value_array": ["foo@bar.emnify"]
        ]
      ]
    ]
  ],
  "targeting_properties": [
    [
      "property": "service_policy",
      "value": "string",
      "value_array": ["3"]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://cdn.emnify.net/api/v1/automation")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```