Headers
Either application/json, application/msgpack, or application/x-ndjson
Bearer $SOURCE_TOKEN
Body parameters
An array of events encoded in JSON or MessagePack, or newline-delimited JSONs of events
A single event encoded in JSON or MessagePack
Sending data to Better Stack Warehouse is as easy as sending an HTTP request.
This endpoint allows you to ingest a single event or a list of events. The events can be encoded in JSON or preferably in a more efficient MessagePack.
Start by creating a Warehouse source in the data region of your choice.
Headers
Either application/json, application/msgpack, or application/x-ndjson
Bearer $SOURCE_TOKEN
Body parameters
An array of events encoded in JSON or MessagePack, or newline-delimited JSONs of events
A single event encoded in JSON or MessagePack
The events were successfully ingested.
You provided an invalid source token.
Response body
Unauthorized
The body is not a valid JSON or MessagePack.
Response body
Couldn't parse JSON content.
The body is too large (over 20 MiB).
Response body
payload reached size limit
Send a single event using cURL:
curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"message":"My first event","nested":{"values":123}}'
curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/x-ndjson" \
-d '{"message":"My first event","nested":{"values":123}}'
# Python is required to prepare the binary data in this example
python3 -c 'import msgpack; \
print(msgpack.packb( \
{"message":"My first event","nested":{"values":123}} \
).hex())' \
| xxd -r -p \
| curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/msgpack" \
--data-binary @-
fetch('https://$INGESTING_HOST', {
method: 'POST',
headers: {
'Authorization': 'Bearer $SOURCE_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify(
{"message": "My first event", "nested": {"values": 123}}
),
})
.then(res => { if (!res.ok) console.error('Err:', res.status) })
.catch(error => console.error('Err:', error.message));
Send multiple events using cURL:
curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/json" \
-d '[{"message":"A"},{"message":"B"}]'
curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/x-ndjson" \
-d $'{"message":"A"}\n{"message":"B"}'
# Python is required to prepare the binary data
python3 -c 'import msgpack; \
print(msgpack.packb( \
[{"message":"A"},{"message":"B"}] \
).hex())' \
| xxd -r -p \
| curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/msgpack" \
--data-binary @-
fetch('https://$INGESTING_HOST', {
method: 'POST',
headers: {
'Authorization': 'Bearer $SOURCE_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify(
[{"message": "A"}, {"message": "B"}]
),
})
.then(res => { if (!res.ok) console.error('Err:', res.status) })
.catch(error => console.error('Err:', error.message));
By default, the time of the event will be the time of receiving it. You can override this by including a field dt containing the event time either as:
1672490759, 1672490759123, 16724907591234560002022-12-31T13:45:59.123456Z, 2022-12-31 13:45:59.123456+02:00Alternatively, you can use ISO 8601, as it will most likely use a format compatible with RFC 3339. In MessagePack, you can also use the timestamp extension type.
In case the timestamp can't be parsed, we save it as a string, but revert to using the reception time as the event time.
curl -X POST https://$INGESTING_HOST \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"message":"I have arrived on time","dt":"2023-08-09 07:03:30+00:00"}'
The maximum allowed size of a single request that might contain many events is 10 MiB of compressed data.
Each event is limited to 1 MiB maximum size, but we recommend keeping a single event under 100 KiB for the best experience.
There is no limit to the number of requests you can send.
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.