---
title: Create rules
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[Magic Network Monitoring](https://developers.cloudflare.com/api/go/resources/magic_network_monitoring)

[Rules](https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Create rules

client.MagicNetworkMonitoring.Rules.New(ctx, params) (\*[MagicNetworkMonitoringRule](<https://developers.cloudflare.com/api/go/resources/magic_network_monitoring#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/mnm/rules

Create network monitoring rules for account. Currently only supports creating a single rule per API request.

##### Security

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**`X-Auth-Email: user@example.com`

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**`X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194`

##### Accepted Permissions (at least one required)

`Magic Network Monitoring Admin`

##### ParametersExpand Collapse

<details>

<summary>

params RuleNewParams

</summary>

AccountID param.Field\[string]

Path param

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

AutomaticAdvertisement param.Field\[bool]

Body param: Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit.

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20automatic_advertisement">Link to this property</a>

Name param.Field\[string]

Body param: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\_), dash (-), period (.), and tilde (\~). You can’t have a space in the rule name. Max 256 characters.

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20name">Link to this property</a>

Prefixes param.Field\[\[]string]

Body param

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefixes">Link to this property</a>

<details>

<summary>

Type param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">RuleNewParamsType</a>]

Body param: MNM rule type.

</summary>

const RuleNewParamsTypeThreshold <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">RuleNewParamsType</a> = "threshold"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const RuleNewParamsTypeZscore <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">RuleNewParamsType</a> = "zscore"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const RuleNewParamsTypeAdvancedDDoS <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">RuleNewParamsType</a> = "advanced\_ddos"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type">Link to this property</a>

BandwidthThreshold param.Field\[float64]Optional

Body param: The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum.

minimum1

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20bandwidth_threshold">Link to this property</a>

<details>

<summary>

Duration param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a>]Optional

Body param: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values \[“1m”,“5m”,“10m”,“15m”,“20m”,“30m”,“45m”,“60m”].

</summary>

const RuleNewParamsDuration1m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "1m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const RuleNewParamsDuration5m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "5m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const RuleNewParamsDuration10m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "10m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const RuleNewParamsDuration15m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "15m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

const RuleNewParamsDuration20m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "20m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%204">Link to this property</a>

const RuleNewParamsDuration30m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "30m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%205">Link to this property</a>

const RuleNewParamsDuration45m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "45m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%206">Link to this property</a>

const RuleNewParamsDuration60m <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)">RuleNewParamsDuration</a> = "60m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration%20%3E%20(schema)%20%3E%20(member)%207">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20duration">Link to this property</a>

PacketThreshold param.Field\[float64]Optional

Body param: The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum.

minimum1

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20packet_threshold">Link to this property</a>

<details>

<summary>

PrefixMatch param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)">RuleNewParamsPrefixMatch</a>]Optional

Body param: Prefix match type to be applied for a prefix auto advertisement when using an advanced\_ddos rule.

</summary>

const RuleNewParamsPrefixMatchExact <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)">RuleNewParamsPrefixMatch</a> = "exact"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const RuleNewParamsPrefixMatchSubnet <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)">RuleNewParamsPrefixMatch</a> = "subnet"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const RuleNewParamsPrefixMatchSupernet <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)">RuleNewParamsPrefixMatch</a> = "supernet"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20prefix_match">Link to this property</a>

<details>

<summary>

ZscoreSensitivity param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)">RuleNewParamsZscoreSensitivity</a>]Optional

Body param: Level of sensitivity set for zscore rules.

</summary>

const RuleNewParamsZscoreSensitivityLow <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)">RuleNewParamsZscoreSensitivity</a> = "low"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const RuleNewParamsZscoreSensitivityMedium <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)">RuleNewParamsZscoreSensitivity</a> = "medium"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const RuleNewParamsZscoreSensitivityHigh <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)">RuleNewParamsZscoreSensitivity</a> = "high"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_sensitivity">Link to this property</a>

<details>

<summary>

ZscoreTarget param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_target%20%3E%20(schema)">RuleNewParamsZscoreTarget</a>]Optional

Body param: Target of the zscore rule analysis.

</summary>

const RuleNewParamsZscoreTargetBits <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_target%20%3E%20(schema)">RuleNewParamsZscoreTarget</a> = "bits"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_target%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const RuleNewParamsZscoreTargetPackets <a href="https://developers.cloudflare.com/api/go/resources/magic_network_monitoring/subresources/rules/methods/create#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_target%20%3E%20(schema)">RuleNewParamsZscoreTarget</a> = "packets"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_target%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20zscore_target">Link to this property</a>

</details>

[Link to this property](<#(resource)%20magic_network_monitoring.rules%20%3E%20(method)%20create%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type MagicNetworkMonitoringRule struct{…}

</summary>

ID string

The id of the rule. Must be unique.

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

AutomaticAdvertisement bool

Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit.

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20automatic_advertisement">Link to this property</a>

Name string

The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\_), dash (-), period (.), and tilde (\~). You can’t have a space in the rule name. Max 256 characters.

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

Prefixes \[]string

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20prefixes">Link to this property</a>

<details>

<summary>

Type MagicNetworkMonitoringRuleType

MNM rule type.

</summary>

One of the following:

const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%200">Link to this property</a>

const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%201">Link to this property</a>

const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced\_ddos"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20type">Link to this property</a>

BandwidthThreshold float64Optional

The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum.

minimum1

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20bandwidth_threshold">Link to this property</a>

<details>

<summary>

Duration MagicNetworkMonitoringRuleDurationOptional

The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values \[“1m”,“5m”,“10m”,“15m”,“20m”,“30m”,“45m”,“60m”].

</summary>

One of the following:

const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%200">Link to this property</a>

const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%201">Link to this property</a>

const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%202">Link to this property</a>

const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%203">Link to this property</a>

const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%204">Link to this property</a>

const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%205">Link to this property</a>

const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%206">Link to this property</a>

const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration%20%3E%20(member)%207">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20duration">Link to this property</a>

PacketThreshold float64Optional

The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum.

minimum1

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20packet_threshold">Link to this property</a>

<details>

<summary>

PrefixMatch MagicNetworkMonitoringRulePrefixMatchOptional

Prefix match type to be applied for a prefix auto advertisement when using an advanced\_ddos rule.

</summary>

One of the following:

const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20prefix_match%20%3E%20(member)%200">Link to this property</a>

const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20prefix_match%20%3E%20(member)%201">Link to this property</a>

const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20prefix_match%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20prefix_match">Link to this property</a>

<details>

<summary>

ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivityOptional

Level of sensitivity set for zscore rules.

</summary>

One of the following:

const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_sensitivity%20%3E%20(member)%200">Link to this property</a>

const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_sensitivity%20%3E%20(member)%201">Link to this property</a>

const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_sensitivity%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_sensitivity">Link to this property</a>

<details>

<summary>

ZscoreTarget MagicNetworkMonitoringRuleZscoreTargetOptional

Target of the zscore rule analysis.

</summary>

One of the following:

const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_target%20%3E%20(member)%200">Link to this property</a>

const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_target%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)%20%3E%20(property)%20zscore_target">Link to this property</a>

</details>

[Link to this property](<#(resource)%20magic_network_monitoring.rules%20%3E%20(model)%20magic_network_monitoring_rule%20%3E%20(schema)>)

### Create rules

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/magic_network_monitoring"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  magicNetworkMonitoringRule, err := client.MagicNetworkMonitoring.Rules.New(context.TODO(), magic_network_monitoring.RuleNewParams{
    AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"),
    AutomaticAdvertisement: cloudflare.F(true),
    Name: cloudflare.F("my_rule_1"),
    Prefixes: cloudflare.F([]string{"203.0.113.1/32"}),
    Type: cloudflare.F(magic_network_monitoring.RuleNewParamsTypeZscore),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", magicNetworkMonitoringRule.ID)
}
```

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "2890e6fa406311ed9b5a23f70f6fb8cf",
    "automatic_advertisement": true,
    "name": "my_rule_1",
    "prefixes": [
      "203.0.113.1/32"
    ],
    "type": "zscore",
    "bandwidth_threshold": 1000,
    "duration": "1m",
    "packet_threshold": 10000,
    "prefix_match": "exact",
    "zscore_sensitivity": "high",
    "zscore_target": "bits"
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "2890e6fa406311ed9b5a23f70f6fb8cf",
    "automatic_advertisement": true,
    "name": "my_rule_1",
    "prefixes": [
      "203.0.113.1/32"
    ],
    "type": "zscore",
    "bandwidth_threshold": 1000,
    "duration": "1m",
    "packet_threshold": 10000,
    "prefix_match": "exact",
    "zscore_sensitivity": "high",
    "zscore_target": "bits"
  },
  "success": true
}
```