Przejdź do treści

Trigger workflow custom event

WorkflowCustomEvents collection allows triggering workflow custom events. Custom events are a ways to insert subscribers into workflows. Multiple custom events can be defined in any workflow. Subscribers can be added individually or as an entire segment, making it flexible and convenient for various needs.

If a single custom event is used in multiple workflows, triggering it may cause inserting a subscriber or segment into multiple workflows.

A business example could be a custom event called „Completing a sale”. We may want such event cause starting several workflows for a subscriber, e.g. workflow called „Post-purchase communication” or „Special offers for customers”.

Request data format

Data part of request for triggering workflow custom events

Data element children:

Element/attributeTypeNotes
CustomEventIdintID of custom event that will be triggered. Required.
SubscriberIdintID of subscriber that triggers the event. Optional*.
SubscriberSegmentIdintID of Segment that triggers the event. Optional*.
CustomSubscriberIdstringCustom ID of subscriber that triggers the event. Optional*.
CustomChannelIdstringCustom Channel ID of subscriber that triggers the event. Optional*.
SubscriberEmailstringEmail of subscriber that triggers the event. Optional*.
SubscriberEmailMd5stringEmailMd5 of subscriber that triggers the event. Optional*.
SubscriberEmailSha256stringEmailSha256 of subscriber that triggers the event. Optional*.
SubscriberPhonestringPhone number of subscriber that triggers the event. Optional*.
DataFieldscomplexCollection of data fields related to the event (DataField elements). Optional.

*Either SubscriberId, SubscriberSegmentId, CustomSubscriberId, CustomChannelId, SubscriberEmail, SubscriberEmailMd5, SubscriberEmailSha256 or SubscriberPhone has to be specified to identify subscriber or segment. If more than one field is specified, precedence is established by the same order as in table above.

DataFields element children:

Element/attributeTypeNotes
NamestringName of data field. Required.
TypestringType of data field. Required. Following field types are supported:
Text, e.g. foobar
Number, e.g. 123
Date, YYYY-MM-DD format, e.g. 2015-11-26
Datetime, YYYY-MM-DD hh:mm:ss format, e.g. 2015-11-26 12:00:00
Boolean, e.g. true, false, 1, 0
ValuestringData field value. Required.

Response format

On success, this request will return HTTP code „201 Created”. No additional information is returned.

Examples

Request (simple request without data fields):

POST https://api.esv2.com/v2/Api/WorkflowCustomEvents HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml;charset=UTF-8
Content-Length: 258
Host: api.esv2.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <Data>
    <CustomEventId>1</CustomEventId>
    <SubscriberId>1</SubscriberId>
  </Data>
</ApiRequest>

Request (request with data fields):

POST https://api.esv2.com/v2/Api/WorkflowCustomEvents HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml;charset=UTF-8
Content-Length: 1002
Host: api.esv2.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <Data>
    <CustomEventId>1</CustomEventId>
    <SubscriberId>1</SubscriberId>
    <DataFields>
      <DataField>
        <Name>test_text</Name>
        <Type>Text</Type>
        <Value>foobar</Value>
      </DataField>
      <DataField>
        <Name>test_number</Name>
        <Type>Number</Type>
        <Value>123</Value>
      </DataField>
      <DataField>
        <Name>test_date</Name>
        <Type>Date</Type>
        <Value>2015-01-23</Value>
      </DataField>
      <DataField>
        <Name>test_datetime</Name>
        <Type>Datetime</Type>
        <Value>2015-01-23 12:34:56</Value>
      </DataField>
      <DataField>
        <Name>test_boolean</Name>
        <Type>Boolean</Type>
        <Value>false</Value>
      </DataField>
    </DataFields>
  </Data>
</ApiRequest>
Na tej stronie
Do góry