The payload schema is at the core of your trigger. It determines what data is passed to Wix when your event is reported, what actions your trigger can be used with, and how much control your users have over their automations. This article will go over all the annotations you can add to the schema, and give you examples that you can copy and work off to build your own effective schema.
Before you start creating the schema, here’s a few important things to note:
When you create your trigger in the app dashboard, the best way to start building your payload schema is to use the Generate from Sample Data button and enter a sample payload. This automatically creates a JSON schema for you, with the correct formatting and annotations.
If you already have your own sample data, feel free to enter that (note that it must be in JSON format). Otherwise, press the tab key to use the data that already appears in the modal:
Once you add sample data, click Convert to schema. The generator creates a schema that looks like this:
If you used your own sample payload, you’ll have different key-object pairs inside the properties object. But for now, let’s ignore the nested objects and look only at the top-level.
Every payload schema that you generate will have three top-level keys:
type: This designates the type of the overall schema object, and always has a value of ”object”. This key is required, so don’t remove it and don’t change its value.properties: This object contains a set of nested objects that define the fields in your payload. This is the most significant part of your schema, and we review it in detail in the properties section. Properties is a required top-level key.required: This is an optional, but recommended array that lists the properties that must be passed to Wix when your app reports the event. If the payload passed to Report Event is missing any of the fields listed in the array, the trigger won’t activate its automation. If any of your properties are necessary for actions that follow the trigger, add them to required.The table below summarizes these top-level keys:
| Property | Data type | Description |
|---|---|---|
type | string | Required. Must be "object". |
properties | object | Required. Object containing payload property metadata as key-object pairs. See the properties object below for details. |
required | array | List of property keys that are required to be present in the reported event payload. |
properties objectThe properties object is responsible for defining the fields in your trigger payload. The object contains one or more key-object pairs, each of which corresponds to a field in the payload. For example, if you have the following key-object pairs in properties:
Your payload will contain the following 2 properties:
Key names can include only alphanumeric characters or underscores (A-Z, a-z, 0-9, _). They cannot start with underscores.The table below lists the possible keys that the paired object may contain. Some of the keys may vary depending on the object’s data type. However, every paired object must contain the following 4 keys:
type: Defines the field data type. Accepted values include standard JSON types or Wix custom types. The table below summarizes these types and we discuss them in detail in the following section.title: Sets the field title. Users will see this title when they set up your trigger in the Automations Builder.examples: Gives examples of valid values for the field. Users will see these examples when they set up your trigger in the Builder.description: Gives users a brief explanation of the payload field. Though a schema property is valid without this key, we require it for user experience purposes. The description is visible to users in the Builder, and having an explanation of the field helps them better understand how to configure and use your trigger.The simple payload schema above shows some basic examples of properties. Each property contains type, title, examples and description. However, most properties you add to your schema include more annotations than just these four. In the next section, we discuss each data type and its possible annotations. Understanding these annotations will help you create a richer payload schema.
| Property | Data type | Description |
type | string | Supported values: Required. Expected data type of the payload property. Note: Only the 1st-level |
title | string | Required. Display name for the property. Shown to users when they create or edit an automation. |
examples | array | Example values, displayed as placeholders when users test certain automation actions. Must be the same data type defined in Required in the 1st-level |
description | string | Required. A short description of the property that is displayed to users in the site dashboard. |
format | string | Validated string format. Used only when If set to If set to |
identityType | string | Supported value: If the property is specified with Connect a property to a contactId, Limited to 1 payload property. |
futureDate | boolean | If the property is specified with Allow scheduled events with predefined date & time, Limited to 1 payload property. A property annotated with |
items | object | Object that contains a list of array items. Required if |
oneOf | array | Creates a field that lets a user select one from multiple options. See the |
properties | object | Object containing 2nd-level payload property metadata as key-object pairs. Accepts the same data as the 1st-level Required if |
required | array | List of property keys that are required to be present in the reported event payload. Used only when |
items objectThe items object is a special object only required for properties with data type “array”. The table below gives the keys items must contain when defined in the payload schema:
| Property | Data type | Description |
|---|---|---|
type | string | Required. Must be set to "object". |
properties | object | Required. Object containing 2nd-level payload property metadata as key-object pairs. Accepts the same data as the 1st-level properties object. See the properties object above for details. |
required | array | List of property keys that are required to be present in the reported event payload. |
oneOf objectoneOf is an array of objects. It defines a field in which a user can choose one of multiple options.
| Property | Data Type | Description |
|---|---|---|
type | string | Required. Defines the expected data type of the option. Must match the parent type defined for the entire field. |
title | string | Required. The option value displayed to users. This value can be translated into another language. |
const | varies | Required if type is "string". Strings must be in English. The option value that is sent to the backend for validation. |
description | string | Provides more information about an option. This value can be translated into another language. |
This section details each of the possible data types you can assign to properties, how to define each one, and the available annotations for each type.
To define a string property in the payload, set type to ”string”.
For a string type, you can also define specific formats. To do so, add the format key to the object and give it one of the following values:
date-time
date
time
email
uuid
uri
regex
number (Note: You can use this format to pass a string-type number, or just use the number type.)
There are also several special keys that are added to the property if you decide to enrich your trigger:
Strings with format uuid may contain the identityType key. This key is added automatically if you connect contact ID data to the property when you configure your trigger.
Strings with format date-time may contain the futureDate key. This is a required key that is added automatically if the date-time field is configured to allow scheduled triggers.
Here’s an example of a string property with date-time format:
To define a number property, set type to ”number”.
Here’s an example:
Note that you can also pass a number as a string type, using the number or DECIMAL_VALUE formats.
To define an integer property, set type to ”integer”.
Here’s an example:
To define a boolean property, set type to ”boolean”.
Here’s an example:
To define an array property, set type to ”array”.
In addition to type, title, and examples, an array property requires the items key. items is an object that defines the data type of the elements in the array. If the elements are objects, it also defines the following:
A nested properties object. This defines the properties of the objects in the array and is mandatory.
An nested required array. This defines the properties that each element in the array must contain. At this level, required is optional.
Here’s a very simple example:
In this case the array elements are strings, so items only needs to define the type key. Here’s a more complex example that uses objects as array elements:
Here items defines the expected properties of each object in the array. It also defines the required key, indicating that any objects in the logins array must contain both of the properties that were defined.
To define an object property, set type to ”object”.
In addition to type, title, and example, you’re required to define a properties object for this type of property. This nested properties object defines the fields inside your object property.
Optionally, you can define a required array to indicate which nested object properties are mandatory.
Here’s an example of an object property:
Note that this particular example doesn’t define a required array.
To define a oneof, set type to “string” and add a oneOf annotation. A oneOf defines a dropdown field in which a user can choose one of multiple options.
Here’s an example:
While the payload schema accepts the standard JSON annotations, there are also a number of custom annotations made by Wix that you can apply to your schema. We’ll go over these special annotations here and how you can apply them.
futureDateThis annotation is added automatically to a property if the property is configured for scheduled triggers. The property must also be added to the required array.
The property must be of type ”string” and format “date-time”. futureDate is a boolean that is always marked true.
Here’s an example usage of the annotation:
identityTypeThis annotation is added automatically to a property that is connected to a contact ID. The connected property must be of type ”string” and format ”uuid”. identityType is a string with value contact. Don’t change this value if you have selected the property to connect to a contact ID, or it may not work properly when you report the event.
Here’s an example usage:
MONEYThis annotation is used to represent a price. It combines the numeric value with its currency symbol (e.g., $15).
Here’s an example usage:
ORDER_IDThis annotation is used to link a trigger to an action that requires an order ID to function. For example, if the trigger schema includes the ORDER_ID annotation, the "Payment Request" action will be available for users to select when building an automation. Without this annotation, actions that depend on an order reference, like "Payment Request," will not appear as options.
Here’s an example usage:
IMAGE_URLThis annotation detects dynamic variables containing an image URL in the email content, and displays the URL as an actual image.
Here’s an example usage:
ATTACHMENTThis annotation enables users to add attachments to their emails by specifying a downloadable URL. The attachment requires both a file name and a valid download URL.
numberThis format is used to represent a string as a numerical value. It allows users to set conditions with numeric operators, even when the property type is defined as a string.
Here’s an example usage:
Below is an example of a complete payload schema:
The payload schema above tells Wix to expect, at a minimum, the following 5 fields:
id with format uuid.contactId with format uuid.totalAmount with format DECIMAL_VALUE.orderDate with format date-time.products containing object values.All the above properties are listed in the required array, so Wix expects all of them every time the event is reported. The automation won’t run if any of these properties are missing from the payload. Other non-required properties like isShippable and invoiceUrl may also appear in the payload, but the automation still runs if they don’t.
You can use this example to get started as you create your trigger in the app dashboard.