ePrivacy and GPDR Cookie Consent by Cookie Consent Skip to main content

How to setup webhooks from external partners with endpoints in Meiro

This document will teach you how to set up webhooks from external partners for event collection in Meiro Events. In this article, we will be using SmartEmailing’s webhook in the examples.

Requirements before starting

  1. Username and Password/API token from the account in partner’s app/website. These credentials are needed for setup and data collection.
  2. External partner’s API endpoint URL and documentation

Learn more: about SmartEmailing API v3 reference

    3. Meiro Events database to be set up for data storage.

Setting up webhook

Open the command prompt and use curl to set up the webhook.

For each event, enter the following command. This will create a webhook for each event type.

>> curl -X POST <source_url> -u "<username>":"<password/api_token>" -d '<json_data_for_event>'

Example: 

>> curl -X POST https://app.smartemailing.cz/api/v3/web-hooks -u 
"megapixel@meiro.io":"XXXXXXX" -d '{"target_url":
"https://me.megapixel.meiro.io/smartemailing?event_name=new_contact",

"event": "new_contact"}'

In <json_data_for_events> of the above example, we have set our endpoint in Meiro Events and included a param with the event name, the events will be automatically parsed by Meiro events.

Check webhook set up

To check if the webhook has been set up, you can either check if events are streaming into the database or run an API call to GET the webhooks being set up by entering the following command.

>> curl -X GET <source_url> -u "<username>":"<password/api_token>"

Example: 

>> curl -X GET https://app.smartemailing.cz/api/v3/web-hooks -u "megapixel@meiro.io":"XXXXX"

Here is an example output. It is important to check that the URL and event match the setup.

{
    "status": "ok",
    "meta": {
        "displayed_count": 8,
        "total_count": 8,
        "limit": 500,
        "offset": 0
    },
    "data": [
    "data": [
            "id": 3,
            "url": "https://me.megapixel.cz/smartemailing?event_name=new_contact",
            "method": "POST",
            "event": "new_contact",
            "active": true,
            "timeout": 30,
            "last_response_code": null,
            "last_call_time": null,
            "errors_in_row": 0
        }
    ]
}