Skip to main content
POST
/
v1
/
events
Track Event
curl --request POST \
  --url https://api.migma.ai/v1/events \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "projectId": "PROJECT_ID",
  "name": "purchase.completed",
  "identifiers": {
    "email": "ada@example.com",
    "externalOrderId": "order_8891"
  },
  "properties": {
    "value": 49.99,
    "currency": "USD"
  }
}
'
import requests

url = "https://api.migma.ai/v1/events"

payload = {
"projectId": "PROJECT_ID",
"name": "purchase.completed",
"identifiers": {
"email": "ada@example.com",
"externalOrderId": "order_8891"
},
"properties": {
"value": 49.99,
"currency": "USD"
}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
projectId: 'PROJECT_ID',
name: 'purchase.completed',
identifiers: {email: 'ada@example.com', externalOrderId: 'order_8891'},
properties: {value: 49.99, currency: 'USD'}
})
};

fetch('https://api.migma.ai/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.migma.ai/v1/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => 'PROJECT_ID',
'name' => 'purchase.completed',
'identifiers' => [
'email' => 'ada@example.com',
'externalOrderId' => 'order_8891'
],
'properties' => [
'value' => 49.99,
'currency' => 'USD'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.migma.ai/v1/events"

payload := strings.NewReader("{\n \"projectId\": \"PROJECT_ID\",\n \"name\": \"purchase.completed\",\n \"identifiers\": {\n \"email\": \"ada@example.com\",\n \"externalOrderId\": \"order_8891\"\n },\n \"properties\": {\n \"value\": 49.99,\n \"currency\": \"USD\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.migma.ai/v1/events")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"PROJECT_ID\",\n \"name\": \"purchase.completed\",\n \"identifiers\": {\n \"email\": \"ada@example.com\",\n \"externalOrderId\": \"order_8891\"\n },\n \"properties\": {\n \"value\": 49.99,\n \"currency\": \"USD\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.migma.ai/v1/events")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"PROJECT_ID\",\n \"name\": \"purchase.completed\",\n \"identifiers\": {\n \"email\": \"ada@example.com\",\n \"externalOrderId\": \"order_8891\"\n },\n \"properties\": {\n \"value\": 49.99,\n \"currency\": \"USD\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "data": {
    "stored": true,
    "eventId": "<string>",
    "dedupeKey": "<string>"
  },
  "error": "<string>"
}
{
"success": true,
"data": null,
"error": "<string>"
}
{
"success": true,
"data": null,
"error": "<string>"
}
{
"success": true,
"data": null,
"error": "<string>"
}
{
"success": true,
"data": null,
"error": "<string>"
}

Authorizations

Authorization
string
header
required

API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where YOUR_API_KEY is obtained from the Migma dashboard under Settings → Developers → API Keys.

Headers

Idempotency-Key
string

Replay-safe key. Takes precedence over the body dedupeKey.

Maximum string length: 200

Body

application/json
projectId
string
required
name
string
required

Event name, e.g. purchase.completed. Names containing refund or cancelled record negative conversion amounts.

Maximum string length: 120
identifiers
object
required

Contact identity for the event. At least one of email or subscriberId is required. Provider ids (externalCustomerId, externalCheckoutId, externalOrderId) support integrations and conversion attribution.

origin
string
default:api
Maximum string length: 80
eventVersion
string
Maximum string length: 40
profile
object

Contact metadata to update. Profile updates never change subscription status, tags, or consent. Events never opt a contact in.

properties
object

Event facts. Up to 16KB, 50 top-level keys, 4 levels deep. A numeric value (major units, e.g. 49.99) together with identifiers.externalOrderId records a conversion; currency is an ISO code, default USD.

occurredAt
string<date-time>

When the event happened. Defaults to receipt time.

dedupeKey
string

Event-identity dedupe key. Replaying the same key stores nothing and returns the original eventId.

Maximum string length: 200

Response

Event stored (or replayed)

success
boolean
required
data
object
error
string | null