JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const response = await client.inbound.trackEvent({
event: 'New Order Placed',
messageId: '4c62c457-b329-4bea-9bfc-17bba86c393f',
properties: {
order_id: 123,
total_orders: 5,
last_order_id: 122,
},
type: 'track',
userId: '1234',
});
console.log(response.messageId);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
response = client.inbound.track_event(
event="New Order Placed",
message_id="4c62c457-b329-4bea-9bfc-17bba86c393f",
properties={
"order_id": 123,
"total_orders": 5,
"last_order_id": 122,
},
type="track",
user_id="1234",
)
print(response.message_id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Inbound.TrackEvent(context.TODO(), courier.InboundTrackEventParams{
Event: "New Order Placed",
MessageID: "4c62c457-b329-4bea-9bfc-17bba86c393f",
Properties: map[string]any{
"order_id": 123,
"total_orders": 5,
"last_order_id": 122,
},
Type: courier.InboundTrackEventParamsTypeTrack,
UserID: courier.String("1234"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.MessageID)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.core.JsonValue;
import com.courier.models.inbound.InboundTrackEventParams;
import com.courier.models.inbound.InboundTrackEventResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
InboundTrackEventParams params = InboundTrackEventParams.builder()
.event("New Order Placed")
.messageId("4c62c457-b329-4bea-9bfc-17bba86c393f")
.properties(InboundTrackEventParams.Properties.builder()
.putAdditionalProperty("order_id", JsonValue.from("bar"))
.putAdditionalProperty("total_orders", JsonValue.from("bar"))
.putAdditionalProperty("last_order_id", JsonValue.from("bar"))
.build())
.type(InboundTrackEventParams.Type.TRACK)
.build();
InboundTrackEventResponse response = client.inbound().trackEvent(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.inbound.track_event(
event: "New Order Placed",
message_id: "4c62c457-b329-4bea-9bfc-17bba86c393f",
properties: {order_id: "bar", total_orders: "bar", last_order_id: "bar"},
type: :track
)
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$response = $client->inbound->trackEvent(
event: 'New Order Placed',
messageID: '4c62c457-b329-4bea-9bfc-17bba86c393f',
properties: [
'order_id' => 'bar', 'total_orders' => 'bar', 'last_order_id' => 'bar'
],
type: 'track',
userID: '1234',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using Inbound = TryCourier.Models.Inbound;
CourierClient client = new();
Inbound::InboundTrackEventParams parameters = new()
{
Event = "New Order Placed",
MessageID = "4c62c457-b329-4bea-9bfc-17bba86c393f",
Properties = new Dictionary<string, JsonElement>()
{
{ "order_id", JsonSerializer.SerializeToElement("bar") },
{ "total_orders", JsonSerializer.SerializeToElement("bar") },
{ "last_order_id", JsonSerializer.SerializeToElement("bar") },
},
Type = Inbound::Type.Track,
};
var response = await client.Inbound.TrackEvent(parameters);
Console.WriteLine(response);courier inbound track-event \
--api-key 'My API Key' \
--event 'New Order Placed' \
--message-id 4c62c457-b329-4bea-9bfc-17bba86c393f \
--properties '{order_id: bar, total_orders: bar, last_order_id: bar}' \
--type trackcurl --request POST \
--url https://api.courier.com/inbound/courier \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "New Order Placed",
"messageId": "4c62c457-b329-4bea-9bfc-17bba86c393f",
"userId": "1234",
"type": "track",
"properties": {
"order_id": 123,
"total_orders": 5,
"last_order_id": 122
}
}
'{
"messageId": "1-6952feeb-7fed6092da5363f2af38eb42"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Inbound
Courier Track Event
POST
/
inbound
/
courier
JavaScript
import Courier from '@trycourier/courier';
const client = new Courier({
apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
});
const response = await client.inbound.trackEvent({
event: 'New Order Placed',
messageId: '4c62c457-b329-4bea-9bfc-17bba86c393f',
properties: {
order_id: 123,
total_orders: 5,
last_order_id: 122,
},
type: 'track',
userId: '1234',
});
console.log(response.messageId);import os
from courier import Courier
client = Courier(
api_key=os.environ.get("COURIER_API_KEY"), # This is the default and can be omitted
)
response = client.inbound.track_event(
event="New Order Placed",
message_id="4c62c457-b329-4bea-9bfc-17bba86c393f",
properties={
"order_id": 123,
"total_orders": 5,
"last_order_id": 122,
},
type="track",
user_id="1234",
)
print(response.message_id)package main
import (
"context"
"fmt"
"github.com/trycourier/courier-go"
"github.com/trycourier/courier-go/option"
)
func main() {
client := courier.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Inbound.TrackEvent(context.TODO(), courier.InboundTrackEventParams{
Event: "New Order Placed",
MessageID: "4c62c457-b329-4bea-9bfc-17bba86c393f",
Properties: map[string]any{
"order_id": 123,
"total_orders": 5,
"last_order_id": 122,
},
Type: courier.InboundTrackEventParamsTypeTrack,
UserID: courier.String("1234"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.MessageID)
}package com.courier.example;
import com.courier.client.CourierClient;
import com.courier.client.okhttp.CourierOkHttpClient;
import com.courier.core.JsonValue;
import com.courier.models.inbound.InboundTrackEventParams;
import com.courier.models.inbound.InboundTrackEventResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
CourierClient client = CourierOkHttpClient.fromEnv();
InboundTrackEventParams params = InboundTrackEventParams.builder()
.event("New Order Placed")
.messageId("4c62c457-b329-4bea-9bfc-17bba86c393f")
.properties(InboundTrackEventParams.Properties.builder()
.putAdditionalProperty("order_id", JsonValue.from("bar"))
.putAdditionalProperty("total_orders", JsonValue.from("bar"))
.putAdditionalProperty("last_order_id", JsonValue.from("bar"))
.build())
.type(InboundTrackEventParams.Type.TRACK)
.build();
InboundTrackEventResponse response = client.inbound().trackEvent(params);
}
}require "courier"
courier = Courier::Client.new(api_key: "My API Key")
response = courier.inbound.track_event(
event: "New Order Placed",
message_id: "4c62c457-b329-4bea-9bfc-17bba86c393f",
properties: {order_id: "bar", total_orders: "bar", last_order_id: "bar"},
type: :track
)
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Courier\Client;
use Courier\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API Key');
try {
$response = $client->inbound->trackEvent(
event: 'New Order Placed',
messageID: '4c62c457-b329-4bea-9bfc-17bba86c393f',
properties: [
'order_id' => 'bar', 'total_orders' => 'bar', 'last_order_id' => 'bar'
],
type: 'track',
userID: '1234',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using System.Collections.Generic;
using System.Text.Json;
using TryCourier;
using Inbound = TryCourier.Models.Inbound;
CourierClient client = new();
Inbound::InboundTrackEventParams parameters = new()
{
Event = "New Order Placed",
MessageID = "4c62c457-b329-4bea-9bfc-17bba86c393f",
Properties = new Dictionary<string, JsonElement>()
{
{ "order_id", JsonSerializer.SerializeToElement("bar") },
{ "total_orders", JsonSerializer.SerializeToElement("bar") },
{ "last_order_id", JsonSerializer.SerializeToElement("bar") },
},
Type = Inbound::Type.Track,
};
var response = await client.Inbound.TrackEvent(parameters);
Console.WriteLine(response);courier inbound track-event \
--api-key 'My API Key' \
--event 'New Order Placed' \
--message-id 4c62c457-b329-4bea-9bfc-17bba86c393f \
--properties '{order_id: bar, total_orders: bar, last_order_id: bar}' \
--type trackcurl --request POST \
--url https://api.courier.com/inbound/courier \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"event": "New Order Placed",
"messageId": "4c62c457-b329-4bea-9bfc-17bba86c393f",
"userId": "1234",
"type": "track",
"properties": {
"order_id": 123,
"total_orders": 5,
"last_order_id": 122
}
}
'{
"messageId": "1-6952feeb-7fed6092da5363f2af38eb42"
}{
"message": "Example message text",
"type": "invalid_request_error"
}{
"message": "Example message text",
"type": "invalid_request_error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node.
Example:
"New Order Placed"
A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status
Example:
"4c62c457-b329-4bea-9bfc-17bba86c393f"
Available options:
track The user id associated with the track
Response
A successful call returns a 202 status code along with a requestId in the response body.
Example:
"1-65f240a0-47a6a120c8374de9bcf9f22c"
⌘I