Headers
Either application/json or application/msgpack
Bearer $SOURCE_TOKEN
Body parameters
An array of log events encoded in JSON or MessagePack
A single log event encoded in JSON or MessagePack
You can use Better Stack even if there's no official library for your programming language by sending your logs to our HTTP API.
This endpoint allows you to log a single event or a list of events. The events can be encoded in JSON or preferably in a more efficient MessagePack.
Headers
Either application/json or application/msgpack
Bearer $SOURCE_TOKEN
Body parameters
An array of log events encoded in JSON or MessagePack
A single log event encoded in JSON or MessagePack
The event was, or the events were successfully logged.
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.
Send a single log line using cURL:
curl -X POST https://in.logs.betterstack.com \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"message":"logs is ready","nested":{"values":123}}'
curl -X POST https://in.logs.betterstack.com \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/msgpack" \
-d "\x82\xA7message\xB0logs is ready\xA6nested\x81\xA6values{"
Send multiple log lines using cURL:
curl -X POST https://in.logs.betterstack.com \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/json" \
-d '[{"message":"A"},{"message":"B"}]'
curl -X POST https://in.logs.betterstack.com \
-H "Authorization: Bearer $SOURCE_TOKEN" \
-H "Content-Type: application/msgpack" \
-d "\x92\x81\xA7message\xA1A\x81\xA7message\xA1B"
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
, 1672490759123456000
2022-12-31T13:45:59.123456Z
, 2022-12-31 13:45:59.123456+02:00
Alternatively, 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://in.logs.betterstack.com \
-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"}'