Send trigger messages
Triggers collection allows sending previously specified API-triggered message to a list of subscribers, using HTTP POST method. Specifying single message ID is required. At the moment, no other methods can be used on Triggers collection.
Request data format
Request URL parameters:
Element/attribute | Type | Notes |
---|---|---|
ID | integer | Trigger message ID. Required as a part of address (not GET parameter). See example below. |
Example URL:
https://api.esv2.com/v2/Api/Triggers/123
Data part of request for sending trigger message to subscribers.
Data element children:
Element/attribute | Type | Notes |
---|---|---|
xsi:type | – | Describes type of manipulated data. Value should always be “TriggerReceivers” for this request |
Receivers | complex | Collection of subscribers that will receive the trigger message (Receiver elements). |
Receiver element children:
Element/attribute | Type | Notes |
---|---|---|
Id | integer | Subscriber’s identifier. Optional. * |
string | Subscriber’s email. Optional. |
* Note: Either Id or Email field must be specified to identify the subscriber. If Email is specified, subscriber with this email must exist in the database. If both fields are specified, Id takes precedence.
Subscribers that cannot be found in the database are ignored and will not receive the trigger message (no error message is returned).
Examples
Request:
POST https://api.esv2.com/v2/Api/Triggers/123 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml
User-Agent: Jakarta
Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 427
<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<ApiKey>test_api_key1</ApiKey>
<Data xsi:type="TriggerReceivers">
<Receivers>
<Receiver>
<Id>137384</Id>
</Receiver>
<Receiver>
<Email>test@testtest.com</Email>
</Receiver>
</Receivers>
</Data>
</ApiRequest>
OK response:
HTTP/1.1 201 Created
Cache-Control: private
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=oxhfxmvpdfj1gz45mhxgx1jb; path=/; HttpOnly
X-AspNetMvc-Version: 1.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Mon, 19 Jul 2010 17:08:43 GMT
Content-Length: 0
Error response:
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=2xdqfo55sk0k53450qbwzj45; path=/; HttpOnly
X-AspNetMvc-Version: 1.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Wed, 21 Jul 2010 13:10:09 GMT
Content-Length: 247
<ApiResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ErrorMessage>
<Code>400</Code>
<Message>Trigger is inactive or was deleted.</Message>
</ErrorMessage>
</ApiResponse>