Orders and surveys
All orders
GET
https://thoughtmetric.io/api/v1/all_orders
Individual orders in the reporting window with their attributed channels, so you can join ThoughtMetric attribution onto your own order data.
Example request
curl -G https://thoughtmetric.io/api/v1/all_orders \
-H "Authorization: Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278" \
-d projectId=ID-bcd0aa692ce7e6b2 \
-d startDate=2024-01-01 \
-d endDate=2024-01-31 \
-d interval=day
<?php
$query = http_build_query([
'projectId' => 'ID-bcd0aa692ce7e6b2',
'startDate' => '2024-01-01',
'endDate' => '2024-01-31',
'interval' => 'day',
]);
$ch = curl_init('https://thoughtmetric.io/api/v1/all_orders?' . $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278',
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
const params = new URLSearchParams({
projectId: 'ID-bcd0aa692ce7e6b2',
startDate: '2024-01-01',
endDate: '2024-01-31',
interval: 'day',
});
const response = await fetch(
`https://thoughtmetric.io/api/v1/all_orders?${params}`,
{ headers: { Authorization: 'Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278' } }
);
const data = await response.json();
Query parameters
| projectId string, required | The Project ID of the store you are querying, e.g. ID-bcd0aa692ce7e6b2. Find it under Configure → API in the dashboard. The older numeric project ID is also accepted. |
| startDate string, required | Start of the reporting window, YYYY-MM-DD. Inclusive. |
| endDate string, required | End of the reporting window, YYYY-MM-DD. Inclusive. The window may not exceed six months. |
| interval string, required | Bucket size for the over_time series: day, week, month or year. |
| model string, optional | Attribution model: first, last, position, linearNonDirect or linearPaid. Defaults to the model configured on the project. |
Response
orders
array
One object per order, most recent first. Capped at 10,000 orders per request.
| transaction_id string | Order number from your e-commerce platform, falling back to the internal transaction ID. |
| timestamp string | ISO 8601 time the order was placed. |
| conversion_id string | ThoughtMetric identifier for the conversion. |
| email string | Customer email. Null when PII anonymization is enabled on the project. |
| external_status string | Order status as reported by your platform. Deleted orders are excluded. |
| total_sale number | Order total after refunds. |
| discount_code string | Discount code applied to the order, if any. |
| data_source string | Platform the order came from, e.g. shopify, woo, bigcommerce. |
| subscription boolean | Whether the order is a subscription order. |
| channels array | Attributed channels for this order, with the credit assigned to each under the selected model. |
| items array | Line items on the order. |
| item_quantity number | Total units on the order. |
Example response
200 OK
{
"orders": [
{
"transaction_id": "#1042",
"timestamp": "2024-01-31T18:22:04.000Z",
"conversion_id": "9f2c1180-11d2-4c0e-9f0c-2b1f0f7a41aa",
"email": "customer@example.com",
"external_status": "paid",
"total_sale": 118.50,
"discount_code": "WELCOME10",
"data_source": "shopify",
"subscription": false,
"channels": [
{ "channel": "facebookad", "value": 0.5 },
{ "channel": "organic", "value": 0.5 }
],
"items": [
{ "sku": "MWC-CHR-M", "name": "Merino Wool Crew - Charcoal", "quantity": 1 }
],
"item_quantity": 1.0
}
]
}
Notes
- Results are capped at 10,000 orders. Narrow your date range if you need more.
intervalis required by the API but does not affect the result.