Margin Trend
curl --request GET \
--url https://api.nozle.app/engine/api/v1/margin/trend \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.nozle.app/engine/api/v1/margin/trend"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.nozle.app/engine/api/v1/margin/trend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.nozle.app/engine/api/v1/margin/trend"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://api.nozle.app/engine/api/v1/margin/trend")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nozle.app/engine/api/v1/margin/trend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.nozle.app/engine/api/v1/margin/trend")
.header("Authorization", "Bearer <token>")
.asString();Margin Intelligence
Margin Trend
GET
/
engine
/
api
/
v1
/
margin
/
trend
Margin Trend
curl --request GET \
--url https://api.nozle.app/engine/api/v1/margin/trend \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.nozle.app/engine/api/v1/margin/trend"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.nozle.app/engine/api/v1/margin/trend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.nozle.app/engine/api/v1/margin/trend"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://api.nozle.app/engine/api/v1/margin/trend")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nozle.app/engine/api/v1/margin/trend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.nozle.app/engine/api/v1/margin/trend")
.header("Authorization", "Bearer <token>")
.asString();Base URL:
The endpoint reads only
The API answers
An unparseable value returns
https://api.nozle.app/engine/api/v1.
Get margin trend over time.
Auth: sk_ only. With API key permissions, the key needs analytic:read; without it the call returns 403 with code: permission_denied.
All margin endpoints require a secret key (
sk_). These endpoints expose cost data that should never be visible to your end users.string
Start of the range, inclusive: a date (
YYYY-MM-DD, which starts at 00:00 UTC that day) or an RFC3339 timestamp such as 2026-07-01T09:30:00Z. from_date is accepted as an alias.string
End of the range: a date (
YYYY-MM-DD) includes that whole day, so to=2026-07-31 covers all of July 31. An RFC3339 timestamp is used as given and is exclusive: it is the instant the range stops at. to_date is accepted as an alias.string
Time bucket size:
hour, day, week, or month (default: day). Any other value returns 400 with code invalid_granularity.from, to, from_date, to_date and granularity. Any other query parameter is ignored without an error.
Date range
from and to take a YYYY-MM-DD date or an RFC3339 timestamp, and you can mix the two. The Python and Go SDKs send from_date and to_date, which the API treats the same way. If you send both from and from_date (or to and to_date), from and to win.
When you leave an end out, the API fills it in:
| You send | Range used |
|---|---|
| Neither | The last month, up to now. |
Only to | The month before to. |
Only from | From from until now. If from is not in the past, one month after from. |
400 with code invalid_date_range when a value cannot be parsed, or when the end of the range is not after its start. Equal dates are valid (they cover one day); an RFC3339 to equal to from is not.
{
"code": "invalid_date_range",
"error": "the end of the range must be after its start"
}
"error": "from must be an RFC3339 timestamp or a date (YYYY-MM-DD)" (or to, with the parameter that failed).
Response
{
"granularity": "week",
"trend": [
{
"period": "2026-10-04",
"revenue_cents": 14750,
"cost_cents": 2360,
"margin_cents": 12390,
"margin_percent": 84,
"event_count": 295
}
]
}
period is the start of the bucket: YYYY-MM-DD for week and month, YYYY-MM-DD HH:MM:SS for hour and day. margin_percent is 0 when the bucket has no revenue. When no events fall in the range, trend is an empty array.