Skip to content
Start here

Create email scanner rule

client.zeroTrust.dlp.email.rules.create(RuleCreateParams { account_id, action, conditions, 3 more } params, RequestOptionsoptions?): RuleCreateResponse { action, conditions, created_at, 6 more }
POST/accounts/{account_id}/dlp/email/rules

Creates a new DLP email scanning rule that defines what content patterns to detect in email messages and what actions to take.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
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)
Zero Trust Write
ParametersExpand Collapse
params: RuleCreateParams { account_id, action, conditions, 3 more }
account_id: string

Path param

action: Action

Body param

action: "Block"
message?: string | null
conditions: Array<Condition>

Body param: Triggered if all conditions match.

operator: "InList" | "NotInList" | "MatchRegex" | "NotMatchRegex"
One of the following:
"InList"
"NotInList"
"MatchRegex"
"NotMatchRegex"
selector: "Recipients" | "Sender" | "DLPProfiles"
One of the following:
"Recipients"
"Sender"
"DLPProfiles"
value: Array<string> | string
One of the following:
Array<string>
string
enabled: boolean

Body param

name: string

Body param

description?: string | null

Body param

ReturnsExpand Collapse
RuleCreateResponse { action, conditions, created_at, 6 more }
action: Action { action, message }
action: "Block"
message?: string | null
conditions: Array<Condition>

Triggered if all conditions match.

operator: "InList" | "NotInList" | "MatchRegex" | "NotMatchRegex"
One of the following:
"InList"
"NotInList"
"MatchRegex"
"NotMatchRegex"
selector: "Recipients" | "Sender" | "DLPProfiles"
One of the following:
"Recipients"
"Sender"
"DLPProfiles"
value: Array<string> | string
One of the following:
Array<string>
string
created_at: string
formatdate-time
enabled: boolean
name: string
priority: number
formatint32
minimum0
rule_id: string
formatuuid
updated_at: string
formatdate-time
description?: string | null

Create email scanner rule

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const rule = await client.zeroTrust.dlp.email.rules.create({
  account_id: 'account_id',
  action: { action: 'Block' },
  conditions: [
    {
      operator: 'InList',
      selector: 'Recipients',
      value: ['string'],
    },
  ],
  enabled: true,
  name: 'name',
});

console.log(rule.rule_id);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "action": {
      "action": "Block",
      "message": "message"
    },
    "conditions": [
      {
        "operator": "InList",
        "selector": "Recipients",
        "value": [
          "string"
        ]
      }
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "enabled": true,
    "name": "name",
    "priority": 0,
    "rule_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "description": "description"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "action": {
      "action": "Block",
      "message": "message"
    },
    "conditions": [
      {
        "operator": "InList",
        "selector": "Recipients",
        "value": [
          "string"
        ]
      }
    ],
    "created_at": "2019-12-27T18:11:19.117Z",
    "enabled": true,
    "name": "name",
    "priority": 0,
    "rule_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "description": "description"
  }
}