К сожалению, эта страница еще не переведена. Уже совсем скоро вся документация будет доступна вам на родном языке.
Triggers any named External Event for a specified array of contacts.
Note: For further information about creating emails with transaction-specific content, see Creating Transactional Emails. For the list of possible campaign related placeholders, see Email Personalization Placeholders.
Endpoint
POST https://api.emarsys.net/api/v2/event/<event_id>/trigger
Parameters
Required parameters
Name | Type | Description | Comments |
---|---|---|---|
id | int | ID of the external event, part of the URI. | |
key_id | mixed | Key which identifies the contacts | You can use any field ID, ID or UID here. |
contacts | string | Array of external IDs and data in JSON format. |
Request Example
{ "key_id": "3", "contacts": [ { "external_id": "test@example.com", "data": { "global": { "itemName": "itemPrice" } } }, { "external_id": "iron@man.com", "data": { "global": { "itemName": "itemPrice" } } } ] }
This request example shows that if the email template is prepared properly, the placeholders itemName
and itemPrice
are replaced by the values in the email campaign which is sent to the specified contacts.
Result Example
{ "replyCode": 0, "replyText": "OK", "data": { "ids": [ "875659845" ], "errors": { "iron@man.com": { "2008": "No contact found with the external id: 3 - iron@man.com" } } } }
Result example details
Name | Description |
---|---|
ids | List of the IDs of successfully triggered contacts (returned as an array). |
errors | Indicates that an error occurred during the triggering of a contact, and the error message returns the value of the key_id. |
Errors
HTTP Code | Reply Code | Message | Description |
---|---|---|---|
400 | 1000 | The request exceeded the maximum batch size of 1,000 | Too many contacts were requested. |
400 | 2004 | Invalid key field id: [field_id]. | The field ID does not exist. |
400 | 2005 | No value provided for key field: [field_id]. | The value of the key field was not provided or is empty. |
400 | 2008 | No contact found with the external id: [key_id] – [external_id]. | There is no match for the specified [key_id] – [external_id] pair. |
400 | 2010 | More contacts found with the external id: [key_id] – [external_id]. | More than one contact with the provided key field value exists in the database. A unique external key must be provided. Please note that using multiple identifiers is not possible via the API. If you need multiple identifiers, you need to use the Import page. |
400 | 5001 | Invalid event id for customer. | The customer doesn’t have an external event with the specified ID. |
400 | 2012 | Invalid contact id for customer. | The customer doesn’t have a contact with the specified external ID. |
400 | 5005 | No program or campaign is triggered. | No active Automation Center program or email campaign is assigned for the external event. |