Server Events
Send events from your backend instead of, or alongside, your app and website. A purchase your server confirms is credited to the link that brought the install (or the web visitor), exactly as an SDK or pixel event would be.
The server events API is part of LinkForty Cloud, on every plan.
Use it when your server is the source of truth: subscriptions validated server-side, purchases completed by a payment provider's webhook, refunds issued from your back office. Using RevenueCat? Connect it instead and skip the code: see RevenueCat.
To keep a purchase from counting twice when both your app and your server report it, see Revenue from your server.
Server event keys
Server events use their own keys, separate from API keys.
- Admins and owners create them under Settings → Server events.
- A key looks like
lf_sk_live_orlf_sk_test_followed by 64 characters. It is shown once, when you create it. - A workspace can have two active keys per environment, so you can rotate one without downtime.
- Live keys record events. Test keys run every check and match exactly like live ones, and appear in the request log, but store nothing, so you can build and test against real installs safely.
- A key is a secret. Use it only from your servers. Never put it in an app or a web page.
Authorization: Bearer lf_sk_live_…
A standard LinkForty API key (dl_…) is refused with STANDARD_KEY_NOT_ALLOWED.
Send one event
POST https://api.linkforty.com/api/s2s/v1/events
curl -X POST https://api.linkforty.com/api/s2s/v1/events \
-H "Authorization: Bearer lf_sk_live_…" \
-H "Content-Type: application/json" \
-d '{
"eventId": "order-1001",
"eventName": "purchase",
"occurredAt": "2026-11-29T14:03:12Z",
"installId": "8f0c5c8e-5a8e-4a4f-9a51-3a0c1e7b2d10",
"revenue": 39.99,
"currency": "USD",
"transactionId": "pi_3Q1x2y",
"properties": { "plan": "annual" }
}'
// Node 18+
const res = await fetch('https://api.linkforty.com/api/s2s/v1/events', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LINKFORTY_SERVER_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
eventId: order.id, // your own unique id: makes retries safe
eventName: 'purchase',
occurredAt: order.paidAt.toISOString(),
installId: user.linkfortyInstallId, // saved from the app's getInstallId()
revenue: order.total,
currency: order.currency,
}),
});
if (res.status === 429) {
// Wait Retry-After seconds, then send the same body again.
}
Fields
Unknown fields are refused, so a misspelled ocurredAt is an error rather than silently ignored.
| Field | Type | Required | Rules |
|---|---|---|---|
eventId | string | Yes | Your unique id for this event, 1–191 characters. See Retries and duplicates. |
eventName | string | Yes | 1–255 characters: letters, digits, spaces and _ . : -. Use the same names as your app, such as purchase. |
occurredAt | string | Yes | ISO 8601 with a time zone, such as 2026-11-29T14:03:12Z or …+02:00. See Timestamps. |
installId | UUID | One of these two | The app install, from the SDK's getInstallId(). Save it with your user when the app signs in. |
clickId | UUID | One of these two | The web click, the lf_click value the web pixel keeps. Valid for 7 days after the click. |
revenue | number | No | The amount. Requires currency. Negative for a refund. |
currency | string | With revenue | A three-letter ISO 4217 code, such as USD. |
transactionId | string | No | Your payment provider's id, 1–191 characters. Stored with the event. |
refundOf | string | No | The eventId of the purchase this refunds. See Refunds. |
properties | object | No | Anything else, up to 16 KB as JSON. Stored with the event. |
Send exactly one of installId or clickId, except for a refund with refundOf, which takes neither.
installId: the event is an app event of that install, credited to the link that brought the install.clickId: the event is a website conversion, credited to that click and its link.
Server events appear in event analytics, funnels, the Event Library and Results next to SDK and pixel events. A server event counts as a conversion when its name is one of your goals.
Responses
202 Accepted: the event was stored (or, with a test key, checked and matched):
{
"eventId": "order-1001",
"status": "accepted",
"test": false,
"match": {
"matchedBy": "installId",
"installId": "8f0c5c8e-5a8e-4a4f-9a51-3a0c1e7b2d10",
"linkId": "2b1d…",
"clickId": null,
"campaign": "black-friday",
"transactionId": "pi_3Q1x2y"
}
}
linkId is null for an organic install: the event is stored, with no link to credit.
200 OK: a repeat of an eventId already accepted. The original answer, with "duplicate": true. Nothing is stored again.
Errors have one shape:
{
"errors": [
{ "field": "installId", "code": "UNKNOWN_INSTALL", "message": "No install with this ID in this workspace." }
]
}
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_FAILED | A missing, malformed or unknown field, or text containing the NUL character (\u0000). One entry per problem, with its field. |
| 401 | AUTH_HEADER_MISSING | No Authorization: Bearer lf_sk_… header. |
| 401 | INVALID_SERVER_KEY | The key is wrong or revoked. |
| 401 | STANDARD_KEY_NOT_ALLOWED | A standard API key was sent. Use a server event key. |
| 403 | WORKSPACE_RESTRICTED | The workspace is restricted under review, so it can't record events. |
| 409 | EVENT_IN_PROGRESS | Another request with this eventId is still being processed. Retry a moment later. |
| 409 | ROLLUP_BUSY | Daily totals were being rebuilt and the event, dated before today, was not stored. Retry a few seconds later. |
| 422 | TIMESTAMP_TOO_OLD | occurredAt is more than 30 days ago. |
| 422 | TIMESTAMP_IN_FUTURE | occurredAt is more than 5 minutes ahead of our clock. |
| 422 | UNKNOWN_INSTALL | No install with this installId in this workspace. |
| 422 | UNKNOWN_CLICK | No click with this clickId in this workspace in the last 7 days. |
| 422 | UNKNOWN_ORIGINAL_EVENT | refundOf names no accepted event in this workspace and environment. |
| 422 | REFUND_OF_REFUND | refundOf names an event that is itself a refund. |
| 422 | REFUND_EXCEEDS_ORIGINAL | The refund is more than what's left of the original. |
| 422 | CURRENCY_MISMATCH | The refund's currency isn't the original's. |
| 429 | RATE_LIMITED | Over the rate limit. Wait Retry-After seconds. |
A 4xx other than 409 and 429 won't succeed if sent again unchanged. Retry 409, 429 and 5xx responses with the same body.
Send a batch
POST https://api.linkforty.com/api/s2s/v1/events/batch
Up to 100 events in one request. The body can be at most 1 MB, whatever the events add up to, so 100 events with large properties may need splitting:
{ "events": [ { "eventId": "order-1001", "eventName": "purchase", "occurredAt": "…", "installId": "…" }, … ] }
- Each event is recorded exactly as the single endpoint would, on its own, so one bad event never stops the rest.
- The answer is always 207, with a result per event at its
indexand the totals. - A repeated
eventIdwithin one batch is refused for every copy after the first, withDUPLICATE_IN_BATCH. - A repeat of an
eventIdaccepted before reads as the single endpoint answers it:"status": "accepted"with"duplicate": true. It's counted underduplicates. - An event we fail to record on our side is
"status": "failed"withINTERNAL_ERROR(orROLLUP_BUSY), and the rest of the batch is still recorded. Send that event again. - An empty
eventsarray isVALIDATION_FAILED; more than 100 isBATCH_TOO_LARGE. Both return 400 and process nothing.
{
"results": [
{ "index": 0, "eventId": "order-1001", "status": "accepted", "test": false, "match": { … } },
{ "index": 1, "eventId": "order-1001", "status": "rejected",
"errors": [{ "field": "eventId", "code": "DUPLICATE_IN_BATCH", "message": "…", "index": 1 }] },
{ "index": 2, "eventId": "order-0999", "status": "accepted", "test": false, "match": { … }, "duplicate": true },
{ "index": 3, "eventId": "order-1002", "status": "failed",
"errors": [{ "field": "body", "code": "INTERNAL_ERROR", "message": "…", "index": 3 }] }
],
"accepted": 1,
"duplicates": 1,
"rejected": 1,
"failed": 1
}
Retries and duplicates
eventId makes every request safe to retry. Use an id you already have, such as an order or transaction id.
- The first request with an
eventIdis recorded. Any later request with the sameeventIdin the same workspace and environment gets the original answer with"duplicate": true, and nothing is counted twice, even if the body differs. So never reuse an id for a different event: a refund needs its owneventId, not the order id of the purchase. - Duplicates are recognized for as long as the accepted event is kept: 400 days.
- Live and test keys have separate
eventIds, so replaying test fixtures with a live key records them. - A request that was refused is not remembered: fix it and send it again with the same
eventId.
Timestamps
occurredAt is when the event happened, with a time zone. It decides which day the event counts on.
- Up to 30 days late is accepted, so a queue that backs up or a nightly job still lands on the right day. Older events are refused with
TIMESTAMP_TOO_OLD. - Up to 5 minutes ahead of our clock is accepted, to allow for clock drift between servers. More is refused with
TIMESTAMP_IN_FUTURE. A timestamp in the future is almost always a bug: local time sent as if it were UTC, or milliseconds sent where seconds were expected.
Refunds
Send a refund as its own event that names the purchase:
{
"eventId": "refund-1001",
"eventName": "refund",
"occurredAt": "2026-12-02T09:00:00Z",
"refundOf": "order-1001",
"revenue": -39.99,
"currency": "USD"
}
- Name it
refund, not the purchase's own name. A refund counts as one more event under its name, so a refund namedpurchasewould add a purchase, and a conversion ifpurchaseis a goal, while subtracting its revenue. refundOfis theeventIdof an accepted purchase, sent with a key of the same environment, up to 400 days old.- Omit
installIdandclickId: the refund is credited where the purchase was, to the same install or click and link. revenueis zero or negative, in the purchase's currency.- Partial refunds are fine. Together, a purchase's refunds can't exceed it.
You can also send a negative revenue without refundOf, against an install or click. It's subtracted the same way, but isn't tied to a purchase or checked against one.
Rate limits
Each workspace can send 10 requests per second on Free, and 50 per second on paid plans. A batch counts as one request per 10 events it holds, rounded up: a batch of 100 counts as 10.
Over the limit, the answer is 429 RATE_LIMITED with Retry-After: 1. Wait, then send the same request again.
Request log
Settings → Server events shows your requests, refreshed live:
- what was sent;
- whether it was accepted, a duplicate or refused, and why, in plain language;
- which link it was credited to.
Refused and duplicate requests are kept 30 days. Accepted requests are kept 400 days, with their body for the first 30.
Next steps
- Revenue from your server: count each purchase once
- RevenueCat: connect without writing code
- SDK integration: where
getInstallId()comes from