This example sends one event to LogZuno's ingestion API from C. It is the exact file our snippet tests send to the API before the docs are published.
Requirements
A C compiler and libcurl with its headers (libcurl4-openssl-dev on Debian and Ubuntu; included on macOS).
Send an event
/* C with libcurl. Build: cc logzuno.c -lcurl -o logzuno */
#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const char *endpoint = getenv("LOGZUNO_ENDPOINT") ? getenv("LOGZUNO_ENDPOINT") : "https://api.logzuno.app/v1";
char url[512], auth[512];
snprintf(url, sizeof url, "%s/log", endpoint);
snprintf(auth, sizeof auth, "Authorization: Bearer %s", getenv("LOGZUNO_API_KEY") ? getenv("LOGZUNO_API_KEY") : "");
const char *body =
"{\"channel\":\"signups\",\"event\":\"User signed up\",\"user_id\":\"user-123\","
"\"icon\":\"\xF0\x9F\x8E\x89\",\"notify\":true,\"tags\":{\"plan\":\"growth\",\"source\":\"website\"}}";
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
CURLcode result = curl_easy_perform(curl);
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
printf("\n%ld\n", status);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return result == CURLE_OK ? 0 : 1;
}Build with cc logzuno.c -lcurl -o logzuno, export LOGZUNO_API_KEY, and run ./logzuno. LogZuno answers 202 and the event appears in your project's live feed within seconds. Keep the key in an environment variable or your secrets manager, not in source control.
Notes for C
Escape your JSON. The example uses a fixed string. When values come from variables, use a JSON library (such as cJSON or jansson) so quotes and newlines are escaped.
Initialise once. Call curl_global_init once at start-up in a long-running program, and reuse the easy handle for each event.
Timeouts. CURLOPT_TIMEOUT keeps a network problem from hanging your daemon.
What the request contains
The body is the same in every language: a channel and an event, and optionally user_id, group_id, description, icon, notify and tags. All fields, limits and response codes are in sending events and the ingestion API reference.