Skip to main content

Attributes

Attributes are key-value pairs that allow you to store additional information about your subscribers. You can utilize attributes to segment your subscribers and send personalized notifications.

Constraints:

  • The attribute key must be alphanumeric and can also include hyphens (-) and underscores (_).
  • Attribute keys are case sensitive.
  • An attribute key cannot start with a hyphen (-) or an underscore (_).
  • An attribute key can have a maximum length of 255 characters.
  • Attribute values can be of types: number, string, boolean, or ISO8601DateString.
  • Attribute values can have a maximum length of 256 characters.
Example of Attributes
{
"name": "Jon smith",
"score": 500,
"dob": "2019-09-19T05:41:53.150Z",
"isActive": true
}

Add Attributes to Subscriber

Adding attributes to a subscriber is straightforward. Use the following methods to do so:

Using Attributes

Attributes allow for sending targeted notifications to subscribers based on specific criteria.

An attribute filter rule sets these criteria, formed by an array of attribute rule items connected by AND operators. Each item in this rule has properties: key, op, and value. Learn more about sending notifications based on these rules in Sending Notification using Attribute Filter Rules.

Example of Using Attributes
// Filter subscribers aged over 20 with the role of 'editor'.
[
[
{ "key": "age", "op": "gt", "value": 20 },
{ "key": "role", "op": "eq", "value": "editor" }
]
]

Allowed Operators

Operator NameOperatorDescriptionExample
Equal'eq'Matches values that are equal to a specified value.{"key": "name", "op": "eq", "value": "Jon Smith"}
Not Equal'ne'Matches all values that are not equal to a specified value.{"key": "name", "op": "ne", "value": "smith jones"}
Greater Than'gt'Matches values that are greater than a specified value.{"key": "age", "op": "gt", "value": 20}
Greater Than Equal'gte'Matches values that are greater than or equal to a specified value.{"key": "Age", "op": "gte", "value": 20}
Less Than'lt'Matches values that are less than a specified value.{"key": "dob", "op": "lt", "value": "2019-09-19T05:41:53.150Z"},
Less Than Equal'lte'Matches values that are less than or equal to a specified value.{"key": "quantity", "op": "lte", "value": 500}
Exists'exists'Matches all the subscriber that have the specified key.{"key": "name", "op": "exists"}
Not Exists'not_exists'Matches documents that have not the specified field.{"key": "role", "op": "not_exists"}