Track order transaction
curl --request POST \
--url http://localhost:3001/api/v1/events/order-transactions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"type": "order",
"source": "<string>",
"orderId": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"currency": "<string>",
"totals": {
"total": 500000000000,
"subtotal": 500000000000,
"tax": 500000000000,
"shipping": 500000000000,
"discount": 500000000000
},
"customer": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"lineItems": [],
"historical": false
}
'import requests
url = "http://localhost:3001/api/v1/events/order-transactions"
payload = {
"type": "order",
"source": "<string>",
"orderId": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"currency": "<string>",
"totals": {
"total": 500000000000,
"subtotal": 500000000000,
"tax": 500000000000,
"shipping": 500000000000,
"discount": 500000000000
},
"customer": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"lineItems": [],
"historical": False
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'order',
source: '<string>',
orderId: '<string>',
occurredAt: '2023-11-07T05:31:56Z',
currency: '<string>',
totals: {
total: 500000000000,
subtotal: 500000000000,
tax: 500000000000,
shipping: 500000000000,
discount: 500000000000
},
customer: {email: 'jsmith@example.com', externalCustomerId: '<string>'},
lineItems: [],
historical: false
})
};
fetch('http://localhost:3001/api/v1/events/order-transactions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3001",
CURLOPT_URL => "http://localhost:3001/api/v1/events/order-transactions",
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([
'type' => 'order',
'source' => '<string>',
'orderId' => '<string>',
'occurredAt' => '2023-11-07T05:31:56Z',
'currency' => '<string>',
'totals' => [
'total' => 500000000000,
'subtotal' => 500000000000,
'tax' => 500000000000,
'shipping' => 500000000000,
'discount' => 500000000000
],
'customer' => [
'email' => 'jsmith@example.com',
'externalCustomerId' => '<string>'
],
'lineItems' => [
],
'historical' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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 := "http://localhost:3001/api/v1/events/order-transactions"
payload := strings.NewReader("{\n \"type\": \"order\",\n \"source\": \"<string>\",\n \"orderId\": \"<string>\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"currency\": \"<string>\",\n \"totals\": {\n \"total\": 500000000000,\n \"subtotal\": 500000000000,\n \"tax\": 500000000000,\n \"shipping\": 500000000000,\n \"discount\": 500000000000\n },\n \"customer\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"lineItems\": [],\n \"historical\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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("http://localhost:3001/api/v1/events/order-transactions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"order\",\n \"source\": \"<string>\",\n \"orderId\": \"<string>\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"currency\": \"<string>\",\n \"totals\": {\n \"total\": 500000000000,\n \"subtotal\": 500000000000,\n \"tax\": 500000000000,\n \"shipping\": 500000000000,\n \"discount\": 500000000000\n },\n \"customer\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"lineItems\": [],\n \"historical\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3001/api/v1/events/order-transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"order\",\n \"source\": \"<string>\",\n \"orderId\": \"<string>\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"currency\": \"<string>\",\n \"totals\": {\n \"total\": 500000000000,\n \"subtotal\": 500000000000,\n \"tax\": 500000000000,\n \"shipping\": 500000000000,\n \"discount\": 500000000000\n },\n \"customer\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"lineItems\": [],\n \"historical\": false\n}"
response = http.request(request)
puts response.read_body{
"eventId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"outcome": "created",
"matchedJourneys": 4503599627370495,
"enrolledJourneys": 4503599627370495,
"skippedJourneys": 4503599627370495
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "RATE_LIMITED",
"message": "Rate limit exceeded. Retry after 12 seconds.",
"details": {
"retryAfterSeconds": 12
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}Events
Track order transaction
Accept one order-transaction.v2 Order Transaction: a paid order with its products, or a refund of one. The source and orderId (plus refundId for a refund) identify it, so sending it again updates it instead of adding another. Orders marked historical never start a Journey.
POST
/
api
/
v1
/
events
/
order-transactions
Track order transaction
curl --request POST \
--url http://localhost:3001/api/v1/events/order-transactions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"type": "order",
"source": "<string>",
"orderId": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"currency": "<string>",
"totals": {
"total": 500000000000,
"subtotal": 500000000000,
"tax": 500000000000,
"shipping": 500000000000,
"discount": 500000000000
},
"customer": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"lineItems": [],
"historical": false
}
'import requests
url = "http://localhost:3001/api/v1/events/order-transactions"
payload = {
"type": "order",
"source": "<string>",
"orderId": "<string>",
"occurredAt": "2023-11-07T05:31:56Z",
"currency": "<string>",
"totals": {
"total": 500000000000,
"subtotal": 500000000000,
"tax": 500000000000,
"shipping": 500000000000,
"discount": 500000000000
},
"customer": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"lineItems": [],
"historical": False
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
type: 'order',
source: '<string>',
orderId: '<string>',
occurredAt: '2023-11-07T05:31:56Z',
currency: '<string>',
totals: {
total: 500000000000,
subtotal: 500000000000,
tax: 500000000000,
shipping: 500000000000,
discount: 500000000000
},
customer: {email: 'jsmith@example.com', externalCustomerId: '<string>'},
lineItems: [],
historical: false
})
};
fetch('http://localhost:3001/api/v1/events/order-transactions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3001",
CURLOPT_URL => "http://localhost:3001/api/v1/events/order-transactions",
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([
'type' => 'order',
'source' => '<string>',
'orderId' => '<string>',
'occurredAt' => '2023-11-07T05:31:56Z',
'currency' => '<string>',
'totals' => [
'total' => 500000000000,
'subtotal' => 500000000000,
'tax' => 500000000000,
'shipping' => 500000000000,
'discount' => 500000000000
],
'customer' => [
'email' => 'jsmith@example.com',
'externalCustomerId' => '<string>'
],
'lineItems' => [
],
'historical' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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 := "http://localhost:3001/api/v1/events/order-transactions"
payload := strings.NewReader("{\n \"type\": \"order\",\n \"source\": \"<string>\",\n \"orderId\": \"<string>\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"currency\": \"<string>\",\n \"totals\": {\n \"total\": 500000000000,\n \"subtotal\": 500000000000,\n \"tax\": 500000000000,\n \"shipping\": 500000000000,\n \"discount\": 500000000000\n },\n \"customer\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"lineItems\": [],\n \"historical\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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("http://localhost:3001/api/v1/events/order-transactions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"order\",\n \"source\": \"<string>\",\n \"orderId\": \"<string>\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"currency\": \"<string>\",\n \"totals\": {\n \"total\": 500000000000,\n \"subtotal\": 500000000000,\n \"tax\": 500000000000,\n \"shipping\": 500000000000,\n \"discount\": 500000000000\n },\n \"customer\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"lineItems\": [],\n \"historical\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3001/api/v1/events/order-transactions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"order\",\n \"source\": \"<string>\",\n \"orderId\": \"<string>\",\n \"occurredAt\": \"2023-11-07T05:31:56Z\",\n \"currency\": \"<string>\",\n \"totals\": {\n \"total\": 500000000000,\n \"subtotal\": 500000000000,\n \"tax\": 500000000000,\n \"shipping\": 500000000000,\n \"discount\": 500000000000\n },\n \"customer\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"lineItems\": [],\n \"historical\": false\n}"
response = http.request(request)
puts response.read_body{
"eventId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"outcome": "created",
"matchedJourneys": 4503599627370495,
"enrolledJourneys": 4503599627370495,
"skippedJourneys": 4503599627370495
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "RATE_LIMITED",
"message": "Rate limit exceeded. Retry after 12 seconds.",
"details": {
"retryAfterSeconds": 12
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}Body
application/json
One order-transaction.v2 Order Transaction: a paid order with its products, or a refund of one.
- Option 1
- Option 2
One order-transaction.v2 Order Transaction: a paid order with its products, or a refund of one.
When the order was paid.
Pattern:
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$Response
Default Response

