> This page is for Developers.

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

# Create a notification definition

POST https://rest.test.zuora.com/notifications/notification-definitions
Content-Type: application/json

Creates a notification definition. If a filter rule is specified, it will be evaluated to see if the notification definition is qualified to handle the incoming events during runtime. If the notification is qualified, it will send the email and invoke the callout if it has an email template or a callout.

This operation supports creating notification definitions for all event types:

* To create a notification definition for a standard event, you must specify the `eventCategory` field. For more information about standard event category codes, see Standard event category code for events and notifications.
* To create a notification definition for a Zuora custom event, custom event, or custom scheduled event, you must specify the `eventTypeName` field. For more information, see Zuora custom events, [Custom event triggers](https://developer.zuora.com/api-references/api/tag/Custom-Event-Triggers/), and [Custom scheduled events](https://developer.zuora.com/api-references/api/tag/Custom-Scheduled-Events/).

You must specify either `eventCategory` or `eventTypeName`, but not both at the same time.

Reference: https://zuora.ferndocs.com/developers/api-reference/zuora-api/events-and-notifications/notifications/post-create-notification-definition

## Authentication

- `Authorization` header (bearer token, required) — Use `Bearer {{token}}` in the `Authorization` header for authentication.

## Servers

- `https://rest.test.zuora.com` (US Developer & Central Sandbox (incl. Test Drive), default)
- `https://rest.sandbox.na.zuora.com` (US API Sandbox Cloud 1)
- `https://rest.apisandbox.zuora.com` (US API Sandbox Cloud 2)
- `https://rest.na.zuora.com` (US Production Cloud 1)
- `https://rest.zuora.com` (US Production Cloud 2)
- `https://rest.test.eu.zuora.com` (EU Developer & Central Sandbox)
- `https://rest.sandbox.eu.zuora.com` (EU API Sandbox)
- `https://rest.eu.zuora.com` (EU Production)
- `https://rest.test.ap.zuora.com` (APAC Developer & Central Sandbox)
- `https://rest.ap.zuora.com` (APAC Production)

## Request

### Headers

- `Idempotency-Key` (string, optional) — Specify a unique idempotency key if you want to perform an idempotent POST or PATCH request. Do not use this header in other request types. With this header specified, the Zuora server can identify subsequent retries of the same request using this value, which prevents the same operation from being performed multiple times by accident.
- `Accept-Encoding` (string, optional) — Include the `Accept-Encoding: gzip` header to compress responses as a gzipped file. It can significantly reduce the bandwidth required for a response. If specified, Zuora automatically compresses responses that contain over 1000 bytes of data, and the response contains a `Content-Encoding` header with the compression algorithm so that your client can decompress it.
- `Content-Encoding` (string, optional) — Include the `Content-Encoding: gzip` header to compress a request. With this header specified, you should upload a gzipped file for the request payload instead of sending the JSON payload.
- `Zuora-Track-Id` (string, optional) — A custom identifier for tracing the API call. If you set a value for this header, Zuora returns the same value in the response headers. This header enables you to associate your system process identifiers with Zuora API calls, to assist with troubleshooting in the event of an issue. The value of this field must use the US-ASCII character set and must not include any of the following characters: colon (`:`), semicolon (`;`), double quote (`"`), and quote (`'`).
- `Zuora-Entity-Ids` (string, optional) — An entity ID. If you have [Zuora Multi-entity](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity) enabled and the OAuth token is valid for more than one entity, you must use this header to specify which entity to perform the operation in. If the OAuth token is only valid for a single entity, or you do not have Zuora Multi-entity enabled, you should not set this header.
- `Zuora-Org-Ids` (string, optional) — Comma separated IDs. If you have Zuora Multi-Org enabled, you can use this header to specify which orgs to perform the operation in. If you do not have Zuora Multi-Org enabled, you should not set this header. The IDs must be a sub-set of the user's accessible orgs. If you specify an org that the user does not have access to, the operation fails. This header is important in Multi-Org (MO) setups because it defines the organization context under which the API should operate—mainly used for read access or data visibility filtering. If the header is not set, the operation is performed in scope of the user's accessible orgs.

### Body (application/json)

This endpoint expects a POSTPublicNotificationDefinitionRequest.

- `name` (string, required) — The name of the notification definition, unique per communication profile.
- `active` (boolean, optional, default: true) — The status of the notification definition. The default value is `true`.
- `associatedAccount` (string, optional) — The account on which the histories of this notification will be displayed. The associated account does not enforce where the merge fields come from. Available values are as follows: * `Account.Id`: ID of the primary customer account related to the notification. It is also the default value. * `ParentAccount.Id`: this option is available only if you have Customer Hierarchy enabled for your tenant. * `SubscriptionOwnerAccount.Id`: this option is available if the base object of the notification is Order Action. **Note:** before specifying this field, we recommend that you use [Data Source](https://knowledgecenter.zuora.com/Billing/Reporting/D_Data_Sources_and_Exports/C_Data_Source_Reference) to check the available types of accounts for the current notification.
- `callout` (PostPublicNotificationDefinitionRequestCallout, optional) — If this field is specified, Zuora will create a new callout template when creating the notification definition and associate the template with the notification definition. You cannot specify the `calloutTemplateIds` and `callout` fields at the same time. For more information about callout templates, see Manage callout templates.
- `calloutActive` (boolean, optional, default: false) — The status of the callout action. The default value is `false`.
- `calloutTemplateIds` (list of string, optional) — List of callout template IDs that the notification definition is associated with. You cannot specify the `calloutTemplateIds` and `callout` fields at the same time. For more information about callout templates, see Manage callout templates.
- `communicationProfileId` (string, optional) — The ID of the communication profile that the notification definition is associated with. You can use the [Query Action](https://developer.zuora.com/api-references/api/operation/Action_POSTquery) to get the communication profile Id. See the following request sample: `{ "queryString": "select Id, ProfileName from CommunicationProfile" }` If you do not pass the communicationProfileId, notification service will be automatically added to the 'Default Profile'. If you want to associate the notification definition with multiple communication profiles, use the `communicationProfileIds` field, which overrides this field.
- `communicationProfileIds` (list of string, optional) — List of communication profile IDs that the notification definition is associated with. This field overrides the `communicationProfileId` field.
- `description` (string, optional) — The description of the notification definition.
- `emailActive` (boolean, optional, default: false) — The status of the email action. The default value is `false`.
- `emailTemplateId` (string, optional) — The ID of the email template. If `emailActive` is `true`, an email template is required. And EventType of the email template MUST be the same as the eventType.
- `eventCategory` (double, optional) — The event category code for a standard event, on which the notification definition is created. This field is required when creating notification definitions for standard events. For the list of supported standard event category codes, see Standard event category code for events and notifications.
- `eventTypeName` (string, optional) — The name of the event that the notification definition is based on. This field is required when creating notification definitions for Zuora custom events, custom events, or custom scheduled events. If this field is provided, you can specify the event namespace in the `eventTypeNamespace` field.
- `eventTypeNamespace` (enum, optional, default: user.notification) — The namespace of the `eventTypeName` field. It indicates who created the event and which namespace the event is assigned to. Supported values are as follows: - `com.zuora.notification`: events that are created by Zuora. This value applies to Zuora custom events. - `user.notification`: events that are created by tenant users. This value applies to custom events and custom scheduled events. This is the default value. For example, if you want to create a notification definition on the `OrderActionProcessed` event, which is a Zuora custom event, you must specify `com.zuora.notification` for this field.
  - Allowed values: `user.notification`, `com.zuora.notification`
- `filterRule` (PostPublicNotificationDefinitionRequestFilterRule, optional)
- `filterRuleParams` (map from string to string, optional) — The parameter values used to configure the filter rule.

## Response

### 200

OK

- `active` (boolean, optional) — The status of the notification definition. The default value is `true`.
- `associatedAccount` (string, optional) — The account on which the histories of this notification will be displayed. The associated account does not enforce where the merge fields come from.
- `callout` (GetPublicNotificationDefinitionResponseCallout, optional)
- `calloutActive` (boolean, optional) — The status of the callout action. The default value is `false`.
- `calloutTemplateIds` (list of string, optional) — List of callout template IDs that the notification definition is associated with.
- `communicationProfileId` (string, optional) — The ID of the communication profile that the notification definition is associated with. If the notification definition is associated with multiple communication profiles, see `communicationProfileIds` for all associated communication profile IDs.
- `communicationProfileIds` (list of string, optional) — List of communication profile IDs that the notification definition is associated with.
- `createdBy` (string, optional) — The ID of the user who created the notification definition.
- `createdOn` (string, optional) — The time when the notification definition was created. Specified in the UTC timezone in the ISO860 format (YYYY-MM-DDThh:mm:ss.sTZD). E.g. 1997-07-16T19:20:30.45+00:00
- `description` (string, optional) — Description of the notification definition
- `emailActive` (boolean, optional) — The status of the email action. The default value is `false`.
- `emailTemplateId` (string, optional) — The ID of the email template. In the request, there should be at least one email template or callout.
- `eventCategory` (double, optional) — The event category code for a standard event, on which the notification definition is created. This field is available only if the notification definition is based on a standard event. For the list of supported standard event category codes, see Standard event category code for events and notifications.
- `eventId` (string, optional) — The ID of the event that the notification definition is based on. This field is available only if the notification definition is based on a standard event.
- `eventTypeName` (string, optional) — The name of the event that the notification definition is based on. This field is available only if the notification definition is based on a Zuora custom event, custom event, or custom scheduled event.
- `eventTypeNamespace` (enum, optional) — The namespace of the `eventTypeName` field. It indicates who created the event and which namespace the event is assigned to. Supported values are as follows: - `com.zuora.notification`: events that are created by Zuora. This value applies to Zuora custom events. - `user.notification`: events that are created by tenant users. This value applies to custom events and custom scheduled events. This field is available only if the notification definition is based on a Zuora custom event, custom event, or custom scheduled event.
  - Allowed values: `user.notification`, `com.zuora.notification`
- `filterRule` (GetPublicNotificationDefinitionResponseFilterRule, optional)
- `filterRuleParams` (map from string to string, optional) — The parameter values used to configure the filter rule.
- `id` (string, optional) — The ID associated with this notification definition.
- `name` (string, optional) — The name of the notification definition.
- `updatedBy` (string, optional) — The ID of the user who updated the notification definition.
- `updatedOn` (string, optional) — The time when the notification was updated. Specified in the UTC timezone in the ISO860 format (YYYY-MM-DDThh:mm:ss.sTZD). E.g. 1997-07-16T19:20:30.45+00:00

## Errors

### 400 Bad Request Error

Bad Request

- `reasons` (list of ErrorResponseReasonsItems, optional)

### 404 Not Found Error

Not Found

- `reasons` (list of ErrorResponseReasonsItems, optional)

### 405 Method Not Allowed Error

Method Not Allowed

- `reasons` (list of ErrorResponseReasonsItems, optional)

### 415 Unsupported Media Type Error

Unsupported Media Type

- `reasons` (list of ErrorResponseReasonsItems, optional)

### 500 Internal Server Error

Internal Server Error

- `reasons` (list of ErrorResponseReasonsItems, optional)

## Types

### PostPublicNotificationDefinitionRequestCallout

If this field is specified, Zuora will create a new callout template when creating the notification definition and associate the template with the notification definition. You cannot specify the `calloutTemplateIds` and `callout` fields at the same time. For more information about callout templates, see Manage callout templates.

### PostPublicNotificationDefinitionRequestFilterRule

- `condition` (string, required) — The filter rule conditions, written in [JEXL](http://commons.apache.org/proper/commons-jexl/). The rule might contain event context merge fields and data source merge fields. Data source merge fields must be from [the base object of the event or from the joined objects of the base object](https://knowledgecenter.zuora.com/DC_Developers/M_Export_ZOQL#Data_Sources_and_Objects). Notifications with invalid merge fields will fail to evaluate, thus will not be invoked. For example, to filter an invoice posted notification to only invoices with an amount over 1000, you would define the following condition: ```Invoice.Amount > 1000.0``` There are conventions and keywords you need to be aware of. For example: * `Invoice.Amount` refers to the `Amount` field of the Zuora object `Invoice`. * Unlike Event Triggers, there is no access to variables with the `_old` suffix. Fields with the `_old` suffix are only available on Event Trigger conditions.
- `parameters` (map from string to FilterRuleParameterDefinition, required) — The parameters of the filter rule and their name must match those in the filter rule. And all parameters must be defined in the event type payload. The name of parameters can't be duplicate. The following reserved keywords should not be used as a parameter name: `AttachmentList`, `RecipientList`, `RecipientType`, `Exceptions`, `OCP_OBJECT_TYPE`, `OCP_OBJECT_ID`, `OCP_TRIGGER_BY`
- `description` (string, optional) — The description of the filter rule.

### GetPublicNotificationDefinitionResponseCallout

- `active` (boolean, optional, default: true) — The status of the callout. The default value is `true`.
- `calloutAuth` (CalloutAuth, optional) — If `requiredAuth` is `true`, this object is required.
- `calloutBaseurl` (string, optional) — The callout URL. It must start with 'https://'
- `calloutParams` (map from string to string, optional) — A key-value map of merge fields of this callout.
- `calloutRetry` (boolean, optional, default: true) — Specified whether to retry the callout when the callout fails. The default value is `true`.
- `description` (string, optional) — Description for the callout.
- `eventTypeName` (string, optional) — The name of the custom event type.
- `httpMethod` (enum, optional) — The HTTP method of the callout.
  - Allowed values: `POST`, `GET`, `PUT`, `PATCH`, `DELETE`
- `id` (string, optional) — The ID of the callout. If `calloutActive` is `true`, a callout is required. The eventTypeName of the callout MUST be the same as the eventTypeName.
- `name` (string, optional) — The name of the created callout.
- `oauth2ProviderId` (string, optional) — The ID of the OAuth 2.0 provider in your tenant that provides access tokens for the callout.
- `requiredAuth` (boolean, optional) — Indicates whether Basic authentication is enabled for the callout.
- `requiredOauth2` (boolean, optional) — Indicates whether OAuth 2.0 authentication is enabled for the callout.

### GetPublicNotificationDefinitionResponseFilterRule

- `condition` (string, optional) — The filter rule conditions, written in [JEXL](http://commons.apache.org/proper/commons-jexl/). The rule might contain event context merge fields and data source merge fields. Data source merge fields must be from [the base object of the event or from the joined objects of the base object](https://knowledgecenter.zuora.com/DC_Developers/M_Export_ZOQL#Data_Sources_and_Objects). Notifications with invalid merge fields will fail to evaluate, thus will not be invoked. For example, to trigger an event when an invoice is posted with the amount over 1000, you would define the following condition on the `Invoice` object: ```changeType == 'UPDATE' && Invoice.Status == 'Posted' && Invoice.Status_old != 'Posted' && Invoice.Amount > 1000.0``` There are conventions and keywords you need to be aware of. For example: * `changeType` is a keyword to specify what kind of change happened to the object. Allowed values are `INSERT`, `UPDATE` or `DELETE`. * `Invoice.Status` refers to field `Status` of the Zuora object `Invoice`. * A variable with the `_old` suffix means it’s a previous value of the corresponding object field. The "_old" fields are only available on the base objects.
- `description` (string, optional) — The description of the filter rule.
- `eventTypeName` (string, optional) — The value is `null`.
- `id` (string, optional) — The ID of the filter rule. If not specified or null, the notification definition is always qualified to process events of "eventType".
- `parameters` (map from string to FilterRuleParameterDefinition, optional) — The parameters of the filter rule and their name must match those in the filter rule. And all parameters must be defined in the event type payload. The name of parameters can't be duplicate. The following reserved keywords should not be used as a parameter name: `AttachmentList`, `RecipientList`, `RecipientType`, `Exceptions`, `OCP_OBJECT_TYPE`, `OCP_OBJECT_ID`, `OCP_TRIGGER_BY`

### ErrorResponseReasonsItems

- `code` (string, optional) — The error code of response.
- `message` (string, optional) — The detail information of the error response

### POSTPublicNotificationDefinitionCalloutCommon

Common information for callout notifications.

- `calloutBaseurl` (string, required) — The callout URL. It must start with 'https\://'. Zuora uses port 443 to send callout notifications by default. If you want to use other ports, submit a request at Zuora Global Support.
- `httpMethod` (enum, required) — The HTTP method of the callout.
  - Allowed values: `POST`, `GET`, `PUT`, `PATCH`, `DELETE`
- `name` (string, required) — The name of the callout template that will be created. It must be unique across all callout templates.
- `active` (boolean, optional, default: true) — The status of the callout. The default is `true`.
- `calloutParams` (map from string to string, optional) — A key-value map of merge fields of this callout.
- `calloutRetry` (boolean, optional, default: true) — Specified whether to retry the callout when the callout fails. The default value is `true`.
- `description` (string, optional) — Description for the callout.
- `eventTypeName` (string, optional) — The name of the event type. The value must be the same as the parent-level `eventTypeName` field.

### POSTPublicNotificationDefinitionCalloutBasicAuthentication

The Basic Authentication information for callout notifications.

- `calloutBaseurl` (string, required) — The callout URL. It must start with 'https\://'. Zuora uses port 443 to send callout notifications by default. If you want to use other ports, submit a request at Zuora Global Support.
- `httpMethod` (enum, required) — The HTTP method of the callout.
  - Allowed values: `POST`, `GET`, `PUT`, `PATCH`, `DELETE`
- `name` (string, required) — The name of the callout template that will be created. It must be unique across all callout templates.
- `requiredAuth` (boolean, required) — Indicates whether Basic authentication is enabled for the callout. When creating callout notifications with Basic authentication enabled, you must set this field to `true` and specify the username and password in `calloutAuth`.
- `active` (boolean, optional, default: true) — The status of the callout. The default is `true`.
- `calloutParams` (map from string to string, optional) — A key-value map of merge fields of this callout.
- `calloutRetry` (boolean, optional, default: true) — Specified whether to retry the callout when the callout fails. The default value is `true`.
- `description` (string, optional) — Description for the callout.
- `eventTypeName` (string, optional) — The name of the event type. The value must be the same as the parent-level `eventTypeName` field.
- `calloutAuth` (CalloutAuth, optional) — If `requiredAuth` is `true`, this object is required.

### POSTPublicNotificationDefinitionCalloutOauth2Authentication

The OAuth 2.0 Authentication information for callout notifications.

- `calloutBaseurl` (string, required) — The callout URL. It must start with 'https\://'. Zuora uses port 443 to send callout notifications by default. If you want to use other ports, submit a request at Zuora Global Support.
- `httpMethod` (enum, required) — The HTTP method of the callout.
  - Allowed values: `POST`, `GET`, `PUT`, `PATCH`, `DELETE`
- `name` (string, required) — The name of the callout template that will be created. It must be unique across all callout templates.
- `requiredOauth2` (boolean, required) — Indicates whether OAuth 2.0 authentication is enabled for the callout. When creating callout notifications with OAuth 2.0 authentication enabled, you must set this field to `true` and specify the OAuth 2.0 provider ID in `oauth2ProviderId`.
- `active` (boolean, optional, default: true) — The status of the callout. The default is `true`.
- `calloutParams` (map from string to string, optional) — A key-value map of merge fields of this callout.
- `calloutRetry` (boolean, optional, default: true) — Specified whether to retry the callout when the callout fails. The default value is `true`.
- `description` (string, optional) — Description for the callout.
- `eventTypeName` (string, optional) — The name of the event type. The value must be the same as the parent-level `eventTypeName` field.
- `oauth2ProviderId` (any, optional) — The ID of the OAuth 2.0 provider in your tenant that provides access tokens for the callout. This field is required if `requiredOauth2` is `true`. For more information about how to get the ID of an OAuth 2.0 provider, see Retrieve the ID of an OAuth 2.0 provider.

### FilterRuleParameterDefinition

Definition of a filter rule parameter.

- `description` (string, optional)
- `displayName` (string, optional) — The display name of the parameter.
- `options` (list of string, optional) — The option values of the parameter.
- `valueType` (enum, optional) — The type of the value.
  - Allowed values: `STRING`, `BYTE`, `SHORT`, `CHARACTER`, `INTEGER`, `LONG`, `FLOAT`, `DOUBLE`, `BOOLEAN`, `BIG_INTEGER`, `BIG_DECIMAL`, `LOCAL_DATE`, `LOCAL_DATE_TIME`, `TIMESTAMP`, `BYTE_ARRAY`, `SHORT_ARRAY`, `CHARACTER_ARRAY`, `INTEGER_ARRAY`, `FLOAT_ARRAY`, `DOUBLE_ARRAY`, `BOOLEAN_ARRAY`, `STRING_ARRAY`, `BIG_INTEGER_ARRAY`, `BIG_DECIMAL_ARRAY`, `LOCAL_DATE_ARRAY`, `LOCAL_DATE_TIME_ARRAY`, `TIMESTAMP_ARRAY`

### CalloutAuth

If `requiredAuth` is `true`, this object is required.

- `domain` (string, optional) — The domain of the callout auth.
- `password` (string, optional) — The field is required when `requiredAuth` is `true`.
- `preemptive` (boolean, optional) — Set this field to `true` if you want to enable the preemptive authentication.
- `username` (string, optional) — The field is required when `requiredAuth` is `true`.

## Examples

### Create a notification definition

**Request**

```json
{
  "name": "Account Edit Notification",
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit"
}
```

**Response**

```json
{
  "active": true,
  "calloutActive": false,
  "calloutTemplateIds": [],
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "communicationProfileIds": [
    "2c92c0f9446cd49501447539d6a72815"
  ],
  "createdBy": "8ad084a67f9c7138017fab8a8b511b5a",
  "createdOn": "2024-11-11T03:00:03.000 UTC",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit",
  "eventTypeNamespace": "user.notification",
  "filterRule": {
    "condition": "Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS",
    "description": "Filter rule to test if an account is a VIP account",
    "id": "a1efc8cc717e48208b9f0fd5d7bf2a58",
    "parameters": {
      "_ACCOUNT_STATUS": {
        "description": "The status of the VIP Account",
        "displayName": "VIP Account Status",
        "options": [
          "Draft",
          "Active",
          "Canceled"
        ],
        "valueType": "STRING"
      },
      "_VIP_BALANCE_AMOUNT": {
        "description": "The minimum account balance",
        "displayName": "VIP Account Balance",
        "options": null,
        "valueType": "BIG_DECIMAL"
      }
    },
    "createdBy": "8ad084a67f9c7138017fab8a8b511b5a",
    "createdOn": "2024-11-11T03:00:04.000 UTC",
    "scheduled": false,
    "updatedBy": null,
    "updatedOn": null
  },
  "filterRuleParams": {
    "_ACCOUNT_STATUS": "Active",
    "_VIP_BALANCE_AMOUNT": "100000.0"
  },
  "id": "838bfafa9b224408809f8ecbdae198ef",
  "name": "Account Edit Notification",
  "updatedBy": "8ad084a67f9c7138017fab8a8b511b5a",
  "updatedOn": "2024-11-11T03:00:03.000 UTC"
}
```

**SDK Code**

```python Create a notification definition
import requests

url = "https://rest.test.zuora.com/notifications/notification-definitions"

payload = {
    "name": "Account Edit Notification",
    "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
    "emailActive": True,
    "emailTemplateId": "f11e498862584a10a05b83ea70119659",
    "eventTypeName": "AccountEdit"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create a notification definition
const url = 'https://rest.test.zuora.com/notifications/notification-definitions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Account Edit Notification","communicationProfileId":"2c92c0f9446cd49501447539d6a72815","emailActive":true,"emailTemplateId":"f11e498862584a10a05b83ea70119659","eventTypeName":"AccountEdit"}'
};

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

```go Create a notification definition
package main

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

func main() {

	url := "https://rest.test.zuora.com/notifications/notification-definitions"

	payload := strings.NewReader("{\n  \"name\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\"\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 Create a notification definition
require 'uri'
require 'net/http'

url = URI("https://rest.test.zuora.com/notifications/notification-definitions")

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\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\"\n}"

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

```java Create a notification definition
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://rest.test.zuora.com/notifications/notification-definitions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\"\n}")
  .asString();
```

```php Create a notification definition
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://rest.test.zuora.com/notifications/notification-definitions', [
  'body' => '{
  "name": "Account Edit Notification",
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Create a notification definition
using RestSharp;

var client = new RestClient("https://rest.test.zuora.com/notifications/notification-definitions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a notification definition
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Account Edit Notification",
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://rest.test.zuora.com/notifications/notification-definitions")! 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()
```

### Create a notification definition with filter rules

**Request**

```json
{
  "name": "Account Edit Notification",
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit",
  "filterRule": {
    "condition": "Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS",
    "parameters": {
      "_ACCOUNT_STATUS": {
        "description": "The status of the VIP Account",
        "displayName": "VIP Account Status",
        "options": [
          "Draft",
          "Active",
          "Canceled"
        ],
        "valueType": "STRING"
      },
      "_VIP_BALANCE_AMOUNT": {
        "description": "The minimum account balance",
        "displayName": "VIP Account Balance",
        "options": [],
        "valueType": "BIG_DECIMAL"
      }
    },
    "description": "Filter rule to test if an account is a VIP account"
  },
  "filterRuleParams": {
    "_ACCOUNT_STATUS": "Active",
    "_VIP_BALANCE_AMOUNT": "100000.0"
  }
}
```

**Response**

```json
{
  "active": true,
  "calloutActive": false,
  "calloutTemplateIds": [],
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "communicationProfileIds": [
    "2c92c0f9446cd49501447539d6a72815"
  ],
  "createdBy": "8ad084a67f9c7138017fab8a8b511b5a",
  "createdOn": "2024-11-11T03:00:03.000 UTC",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit",
  "eventTypeNamespace": "user.notification",
  "filterRule": {
    "condition": "Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS",
    "description": "Filter rule to test if an account is a VIP account",
    "id": "a1efc8cc717e48208b9f0fd5d7bf2a58",
    "parameters": {
      "_ACCOUNT_STATUS": {
        "description": "The status of the VIP Account",
        "displayName": "VIP Account Status",
        "options": [
          "Draft",
          "Active",
          "Canceled"
        ],
        "valueType": "STRING"
      },
      "_VIP_BALANCE_AMOUNT": {
        "description": "The minimum account balance",
        "displayName": "VIP Account Balance",
        "options": null,
        "valueType": "BIG_DECIMAL"
      }
    },
    "createdBy": "8ad084a67f9c7138017fab8a8b511b5a",
    "createdOn": "2024-11-11T03:00:04.000 UTC",
    "scheduled": false,
    "updatedBy": null,
    "updatedOn": null
  },
  "filterRuleParams": {
    "_ACCOUNT_STATUS": "Active",
    "_VIP_BALANCE_AMOUNT": "100000.0"
  },
  "id": "838bfafa9b224408809f8ecbdae198ef",
  "name": "Account Edit Notification",
  "updatedBy": "8ad084a67f9c7138017fab8a8b511b5a",
  "updatedOn": "2024-11-11T03:00:03.000 UTC"
}
```

**SDK Code**

```python Create a notification definition with filter rules
import requests

url = "https://rest.test.zuora.com/notifications/notification-definitions"

payload = {
    "name": "Account Edit Notification",
    "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
    "emailActive": True,
    "emailTemplateId": "f11e498862584a10a05b83ea70119659",
    "eventTypeName": "AccountEdit",
    "filterRule": {
        "condition": "Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS",
        "parameters": {
            "_ACCOUNT_STATUS": {
                "description": "The status of the VIP Account",
                "displayName": "VIP Account Status",
                "options": ["Draft", "Active", "Canceled"],
                "valueType": "STRING"
            },
            "_VIP_BALANCE_AMOUNT": {
                "description": "The minimum account balance",
                "displayName": "VIP Account Balance",
                "options": [],
                "valueType": "BIG_DECIMAL"
            }
        },
        "description": "Filter rule to test if an account is a VIP account"
    },
    "filterRuleParams": {
        "_ACCOUNT_STATUS": "Active",
        "_VIP_BALANCE_AMOUNT": "100000.0"
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create a notification definition with filter rules
const url = 'https://rest.test.zuora.com/notifications/notification-definitions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Account Edit Notification","communicationProfileId":"2c92c0f9446cd49501447539d6a72815","emailActive":true,"emailTemplateId":"f11e498862584a10a05b83ea70119659","eventTypeName":"AccountEdit","filterRule":{"condition":"Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS","parameters":{"_ACCOUNT_STATUS":{"description":"The status of the VIP Account","displayName":"VIP Account Status","options":["Draft","Active","Canceled"],"valueType":"STRING"},"_VIP_BALANCE_AMOUNT":{"description":"The minimum account balance","displayName":"VIP Account Balance","options":[],"valueType":"BIG_DECIMAL"}},"description":"Filter rule to test if an account is a VIP account"},"filterRuleParams":{"_ACCOUNT_STATUS":"Active","_VIP_BALANCE_AMOUNT":"100000.0"}}'
};

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

```go Create a notification definition with filter rules
package main

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

func main() {

	url := "https://rest.test.zuora.com/notifications/notification-definitions"

	payload := strings.NewReader("{\n  \"name\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\",\n  \"filterRule\": {\n    \"condition\": \"Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS\",\n    \"parameters\": {\n      \"_ACCOUNT_STATUS\": {\n        \"description\": \"The status of the VIP Account\",\n        \"displayName\": \"VIP Account Status\",\n        \"options\": [\n          \"Draft\",\n          \"Active\",\n          \"Canceled\"\n        ],\n        \"valueType\": \"STRING\"\n      },\n      \"_VIP_BALANCE_AMOUNT\": {\n        \"description\": \"The minimum account balance\",\n        \"displayName\": \"VIP Account Balance\",\n        \"options\": [],\n        \"valueType\": \"BIG_DECIMAL\"\n      }\n    },\n    \"description\": \"Filter rule to test if an account is a VIP account\"\n  },\n  \"filterRuleParams\": {\n    \"_ACCOUNT_STATUS\": \"Active\",\n    \"_VIP_BALANCE_AMOUNT\": \"100000.0\"\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 Create a notification definition with filter rules
require 'uri'
require 'net/http'

url = URI("https://rest.test.zuora.com/notifications/notification-definitions")

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\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\",\n  \"filterRule\": {\n    \"condition\": \"Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS\",\n    \"parameters\": {\n      \"_ACCOUNT_STATUS\": {\n        \"description\": \"The status of the VIP Account\",\n        \"displayName\": \"VIP Account Status\",\n        \"options\": [\n          \"Draft\",\n          \"Active\",\n          \"Canceled\"\n        ],\n        \"valueType\": \"STRING\"\n      },\n      \"_VIP_BALANCE_AMOUNT\": {\n        \"description\": \"The minimum account balance\",\n        \"displayName\": \"VIP Account Balance\",\n        \"options\": [],\n        \"valueType\": \"BIG_DECIMAL\"\n      }\n    },\n    \"description\": \"Filter rule to test if an account is a VIP account\"\n  },\n  \"filterRuleParams\": {\n    \"_ACCOUNT_STATUS\": \"Active\",\n    \"_VIP_BALANCE_AMOUNT\": \"100000.0\"\n  }\n}"

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

```java Create a notification definition with filter rules
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://rest.test.zuora.com/notifications/notification-definitions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\",\n  \"filterRule\": {\n    \"condition\": \"Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS\",\n    \"parameters\": {\n      \"_ACCOUNT_STATUS\": {\n        \"description\": \"The status of the VIP Account\",\n        \"displayName\": \"VIP Account Status\",\n        \"options\": [\n          \"Draft\",\n          \"Active\",\n          \"Canceled\"\n        ],\n        \"valueType\": \"STRING\"\n      },\n      \"_VIP_BALANCE_AMOUNT\": {\n        \"description\": \"The minimum account balance\",\n        \"displayName\": \"VIP Account Balance\",\n        \"options\": [],\n        \"valueType\": \"BIG_DECIMAL\"\n      }\n    },\n    \"description\": \"Filter rule to test if an account is a VIP account\"\n  },\n  \"filterRuleParams\": {\n    \"_ACCOUNT_STATUS\": \"Active\",\n    \"_VIP_BALANCE_AMOUNT\": \"100000.0\"\n  }\n}")
  .asString();
```

```php Create a notification definition with filter rules
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://rest.test.zuora.com/notifications/notification-definitions', [
  'body' => '{
  "name": "Account Edit Notification",
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit",
  "filterRule": {
    "condition": "Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS",
    "parameters": {
      "_ACCOUNT_STATUS": {
        "description": "The status of the VIP Account",
        "displayName": "VIP Account Status",
        "options": [
          "Draft",
          "Active",
          "Canceled"
        ],
        "valueType": "STRING"
      },
      "_VIP_BALANCE_AMOUNT": {
        "description": "The minimum account balance",
        "displayName": "VIP Account Balance",
        "options": [],
        "valueType": "BIG_DECIMAL"
      }
    },
    "description": "Filter rule to test if an account is a VIP account"
  },
  "filterRuleParams": {
    "_ACCOUNT_STATUS": "Active",
    "_VIP_BALANCE_AMOUNT": "100000.0"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Create a notification definition with filter rules
using RestSharp;

var client = new RestClient("https://rest.test.zuora.com/notifications/notification-definitions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Account Edit Notification\",\n  \"communicationProfileId\": \"2c92c0f9446cd49501447539d6a72815\",\n  \"emailActive\": true,\n  \"emailTemplateId\": \"f11e498862584a10a05b83ea70119659\",\n  \"eventTypeName\": \"AccountEdit\",\n  \"filterRule\": {\n    \"condition\": \"Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS\",\n    \"parameters\": {\n      \"_ACCOUNT_STATUS\": {\n        \"description\": \"The status of the VIP Account\",\n        \"displayName\": \"VIP Account Status\",\n        \"options\": [\n          \"Draft\",\n          \"Active\",\n          \"Canceled\"\n        ],\n        \"valueType\": \"STRING\"\n      },\n      \"_VIP_BALANCE_AMOUNT\": {\n        \"description\": \"The minimum account balance\",\n        \"displayName\": \"VIP Account Balance\",\n        \"options\": [],\n        \"valueType\": \"BIG_DECIMAL\"\n      }\n    },\n    \"description\": \"Filter rule to test if an account is a VIP account\"\n  },\n  \"filterRuleParams\": {\n    \"_ACCOUNT_STATUS\": \"Active\",\n    \"_VIP_BALANCE_AMOUNT\": \"100000.0\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a notification definition with filter rules
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Account Edit Notification",
  "communicationProfileId": "2c92c0f9446cd49501447539d6a72815",
  "emailActive": true,
  "emailTemplateId": "f11e498862584a10a05b83ea70119659",
  "eventTypeName": "AccountEdit",
  "filterRule": [
    "condition": "Account.Balance >= _VIP_BALANCE_AMOUNT && Account.Status == _ACCOUNT_STATUS",
    "parameters": [
      "_ACCOUNT_STATUS": [
        "description": "The status of the VIP Account",
        "displayName": "VIP Account Status",
        "options": ["Draft", "Active", "Canceled"],
        "valueType": "STRING"
      ],
      "_VIP_BALANCE_AMOUNT": [
        "description": "The minimum account balance",
        "displayName": "VIP Account Balance",
        "options": [],
        "valueType": "BIG_DECIMAL"
      ]
    ],
    "description": "Filter rule to test if an account is a VIP account"
  ],
  "filterRuleParams": [
    "_ACCOUNT_STATUS": "Active",
    "_VIP_BALANCE_AMOUNT": "100000.0"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://rest.test.zuora.com/notifications/notification-definitions")! 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()
```