How to insert events via the API

Every data event can be send to the Events API to be processed within CM Data. This is the preferred way to insert data. In this help article we'll go through the steps to set this up.

1. Set up the EventType

To make sure the data can be received and viewed within CM Data ask your CM representative to configure the event as defined in the previous step in your CM Data instance.

To do this we will create an EventType to sent this data to. In our example the event will receive three values:

Field Type Optional?
Email email no
NPS string no
Feedback number yes

If there is no EventType defined the Events will not show in either the Events Insights, or Profile Insights.

2. Post the Event

Using the CM Data Events API is really simple. You only need to post an array of events of the same EventType to the following url:

https://api.cmtelecom.com/events/v1.0/tenants/[TenantID]/events/[EventTypeID]

To authenticate you need to specify your Data publisher token as Product token in the header of the request.

X-CM-PRODUCTTOKEN: [DataPublisherToken]

The body of the post is application/json formatted, and will e.g. look like this (in case of an NPS example):

[{
        "Email": "test@domain.com",
        "NPS": 7,
        "Feedback": "The support team was really friendly"
    },
    {
        "Email": "tryout@domain.com",
        "NPS": 9,
        "Feedback": "Awesome, best software tool ever!!"
    }
]

2a. cURL Example of Posting an Event

In cURL this would look like:

curl -X POST \
  'https://api.cmtelecom.com/events/v1.0/tenants/[TenantID]/events/[EventTypeID]' \
  -H 'Content-Type: application/json' \
  -H 'X-CM-PRODUCTTOKEN: [DataPublisherToken]' \
  -H 'cache-control: no-cache' \
  -d '[{
        "Email": "test@domain.com",
        "NPS": 7,
        "Feedback": "The support team was really friendly"
    },
    {
        "Email": "tryout@domain.com",
        "NPS": 9,
        "Feedback": "Awesome, best software tool ever!!"
    }
]'
Last modified on :17/12/2018
Was this article helpful?