Do I need an SDK for server events?
No. Node.js 18 and later has fetch, so one POST request sends a batch of up to 100 events. The Manalens Node SDK adds a queue, retries, and shutdown(). It is not public yet: request it from the contact page. The with-express-server example uses it.
- Create a Secret key in Settings, General, Credentials. It is shown once.
- Store it in an environment variable or a secret store on your server.
- Send events to POST /v0/events with Authorization: Bearer and channel server.
- Set user_id, anonymous_id, or both, and a message_id for each event.
- Check for 202 and the events in the project activity feed.
How do I send a server event?
Send the Secret key as Authorization: Bearer, with no x-publishable-key header. Every event has channel server and type track or identify. A request from a browser with the Secret key gets 403, so this code must run on your server.
Node.js, on your server
await fetch('https://events.manalens.dev/v0/events', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MANALENS_SECRET_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ events: [{
channel: 'server', type: 'track', event: 'match_end',
user_id: 'player_42', message_id: crypto.randomUUID(),
properties: { mode: 'duel', won: true },
}] }),
});
// 202 {"accepted":1}How do I join server events to the player?
Send user_id, anonymous_id, or both. With only user_id, the event joins that player. With the anonymous_id of the game or the browser, it joins that device, even before the player signs in. With both, earlier anonymous activity joins the player profile. To put the event in the player session, also send the session_id of the same client.
| SDK | Anonymous ID | Session ID |
|---|---|---|
| JavaScript web SDK | getAnonymousId() | getSessionId() |
| Godot addon | get_anonymous_id() | get_session_id() |
| Unity package | AnonymousId | SessionId |
How do I handle webhooks and retries?
Make the message_id from the provider event ID, so a webhook that arrives twice counts once. Do not send the IP or the user agent of a webhook request: they belong to the provider, not the player. For a player request, forward the player IP and user agent in context. Manalens uses the IP only for an in-memory country lookup and never stores it.
Stripe and Paddle need no code: connect their webhooks in Settings, Integrations, and put the player ID in the checkout.
How do I check that server events arrive?
A good request returns 202 with {"accepted":N,"rejected":0,"errors":[]}. A refused event is listed in errors with a reason. Then check the events in the project activity feed. Server events appear in every report, and channel reports show them as Direct. A 403 with SECRET_KEY_FROM_BROWSER means the request has an Origin header, so it did not come from your server.
Frequently asked questions
Which key do server events use?
The Secret key, which starts with mana_sk_. Keep it on your backend in an environment variable or a secret store. The Publishable key cannot send server events, and the Secret key cannot send web or app events. A browser request with the Secret key gets 403, so a key in a page fails.
How many events can one request send?
Up to 100 server events and 256 KB in one request. Every event in the batch must have channel server. Old timestamps are allowed, so you can backfill, but a timestamp more than 5 minutes in the future is refused. Server events have their own rate limit, separate from game events.
Is the Node SDK public?
Not yet. The Manalens Node SDK adds a queue, retries, and shutdown(), and it is available on request from the contact page. Without it, Node.js 18 and later can send server events with fetch. The JavaScript, Godot, and Unity SDKs are already open source on GitHub.