How can I use the Events API?

In your mobile or web application, you can use the MoonMail Events API to report usage data, or events, to MoonMail. You can report events to capture information such as session times, users' purchasing behavior, sign-in attempts, or any custom event type that you need.

Events API Endpoint

https://contacts.moonmail.io/<YOUR_ACCOUNT_ID>/events

You can find your Account ID in the settings section of your MoonMail account.
HTTP Method
POST
Example request to trigger event
{
  "Contact": {
    "Address": "email@example.com"
  },
  "Events": [
    {
      "EventType": "Customer.Purchase",
      "Attributes": {
        "CheckoutId": "12345"
      },
      "Metrics": {
        "CartTotal": 1000
      }
    }
  ]
}
You can update a contact and trigger an event in one request
{
  "Contact": {
    "Address": "email@example.com",
    "Attributes": {
      "CustomerGroup": "VIP"
    },
    "Metrics": {
      "TotalPurchased": 15000
    }
  },
  "Events": [
    {
      "EventType": "Customer.Purchase",
      "Attributes": {
        "CheckoutId": "12345"
      },
      "Metrics": {
        "CartTotal": 1000
      }
    }
  ]
}
If contact does not exist yet it will be created
{
  "Contact": {
    "Address": "email@example.com",
    "Location": {
      "City": "New York",
      "Country": "USA",
      "PostalCode": "10013",
      "Region": "NY"
    },
    "Demographic": {
      "Timezone": "America/New_York",
      "Locale": "en_US"
    },
    "Attributes": {
      "CustomerGroup": "VIP"
    },
    "Metrics": {
      "TotalPurchased": 15000
    }
  },
  "Events": [
    {
      "EventType": "Customer.Purchase",
      "Attributes": {
        "CheckoutId": "12345"
      },
      "Metrics": {
        "CartTotal": 1000
      }
    }
  ]
}
Example response
{
  "Contact": {
    "Id": "5658ffccee7f0ebfda2b226238b1eb6e",
    "ResultStatus": {
      "Message": "Accepted",
      "StatusCode": 202
    }
  },
  "Events": [
    {
      "Id": "3ac0de97-ebd0-4c6e-af73-62a6b6f4b66a",
      "ResultStatus": {
        "Message": "Accepted",
        "StatusCode": 202
      }
    }
  ]
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us