Batch multiple events
curl --request POST \
--url https://core.nozle.app/api/v1/events/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
{
"transaction_id": "transaction_1234567890",
"external_subscription_id": "sub_1234567890",
"code": "storage",
"timestamp": "1651240791.123",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
}
}
]
}
'import requests
url = "https://core.nozle.app/api/v1/events/batch"
payload = { "events": [
{
"transaction_id": "transaction_1234567890",
"external_subscription_id": "sub_1234567890",
"code": "storage",
"timestamp": "1651240791.123",
"precise_total_amount_cents": "1234.56",
"properties": { "gb": 10 }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
events: [
{
transaction_id: 'transaction_1234567890',
external_subscription_id: 'sub_1234567890',
code: 'storage',
timestamp: '1651240791.123',
precise_total_amount_cents: '1234.56',
properties: {gb: 10}
}
]
})
};
fetch('https://core.nozle.app/api/v1/events/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://core.nozle.app/api/v1/events/batch"
payload := strings.NewReader("{\n \"events\": [\n {\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"code\": \"storage\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}require 'uri'
require 'net/http'
url = URI("https://core.nozle.app/api/v1/events/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"events\": [\n {\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"code\": \"storage\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://core.nozle.app/api/v1/events/batch",
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([
'events' => [
[
'transaction_id' => 'transaction_1234567890',
'external_subscription_id' => 'sub_1234567890',
'code' => 'storage',
'timestamp' => '1651240791.123',
'precise_total_amount_cents' => '1234.56',
'properties' => [
'gb' => 10
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://core.nozle.app/api/v1/events/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"events\": [\n {\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"code\": \"storage\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n }\n }\n ]\n}")
.asString();{
"events": [
{
"transaction_id": "transaction_1234567890",
"lago_customer_id": null,
"code": "storage",
"timestamp": "2022-04-29T08:59:51.123Z",
"lago_subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_subscription_id": "sub_1234567890",
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
},
"created_at": "2022-04-29T08:59:51Z"
}
]
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 403,
"error": "Forbidden",
"code": "feature_unavailable"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}Usage Events
Batch multiple events
This endpoint can be used to send a batch of usage records. Each request may include up to 100 events.
POST
/
events
/
batch
Batch multiple events
curl --request POST \
--url https://core.nozle.app/api/v1/events/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"events": [
{
"transaction_id": "transaction_1234567890",
"external_subscription_id": "sub_1234567890",
"code": "storage",
"timestamp": "1651240791.123",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
}
}
]
}
'import requests
url = "https://core.nozle.app/api/v1/events/batch"
payload = { "events": [
{
"transaction_id": "transaction_1234567890",
"external_subscription_id": "sub_1234567890",
"code": "storage",
"timestamp": "1651240791.123",
"precise_total_amount_cents": "1234.56",
"properties": { "gb": 10 }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
events: [
{
transaction_id: 'transaction_1234567890',
external_subscription_id: 'sub_1234567890',
code: 'storage',
timestamp: '1651240791.123',
precise_total_amount_cents: '1234.56',
properties: {gb: 10}
}
]
})
};
fetch('https://core.nozle.app/api/v1/events/batch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://core.nozle.app/api/v1/events/batch"
payload := strings.NewReader("{\n \"events\": [\n {\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"code\": \"storage\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}require 'uri'
require 'net/http'
url = URI("https://core.nozle.app/api/v1/events/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"events\": [\n {\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"code\": \"storage\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://core.nozle.app/api/v1/events/batch",
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([
'events' => [
[
'transaction_id' => 'transaction_1234567890',
'external_subscription_id' => 'sub_1234567890',
'code' => 'storage',
'timestamp' => '1651240791.123',
'precise_total_amount_cents' => '1234.56',
'properties' => [
'gb' => 10
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://core.nozle.app/api/v1/events/batch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"events\": [\n {\n \"transaction_id\": \"transaction_1234567890\",\n \"external_subscription_id\": \"sub_1234567890\",\n \"code\": \"storage\",\n \"timestamp\": \"1651240791.123\",\n \"precise_total_amount_cents\": \"1234.56\",\n \"properties\": {\n \"gb\": 10\n }\n }\n ]\n}")
.asString();{
"events": [
{
"transaction_id": "transaction_1234567890",
"lago_customer_id": null,
"code": "storage",
"timestamp": "2022-04-29T08:59:51.123Z",
"lago_subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_subscription_id": "sub_1234567890",
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"precise_total_amount_cents": "1234.56",
"properties": {
"gb": 10
},
"created_at": "2022-04-29T08:59:51Z"
}
]
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 403,
"error": "Forbidden",
"code": "feature_unavailable"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}