Skip to main content

Server-to-Server (S2S) 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.

Cloud only

The S2S 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.

S2S keys​

S2S events use their own keys, separate from API keys.

  • Admins and owners create them under Settings → S2S events.
  • A key looks like lf_sk_live_ or lf_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.

FieldTypeRequiredRules
eventIdstringYesYour unique id for this event, 1–191 characters. See Retries and duplicates.
eventNamestringYes1–255 characters: letters, digits, spaces and _ . : -. Use the same names as your app, such as purchase.
occurredAtstringYesISO 8601 with a time zone, such as 2026-11-29T14:03:12Z or …+02:00. See Timestamps.
installIdUUIDOne of these twoThe app install, from the SDK's getInstallId(). Save it with your user when the app signs in.
clickIdUUIDOne of these twoThe web click, the lf_click value the web pixel keeps. Valid for 7 days after the click.
revenuenumberNoThe amount. Requires currency. Negative for a refund.
currencystringWith revenueA three-letter ISO 4217 code, such as USD.
transactionIdstringNoYour payment provider's id, 1–191 characters. Stored with the event.
refundOfstringNoThe eventId of the purchase this refunds. See Refunds.
propertiesobjectNoAnything 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.

S2S events appear in event analytics, funnels, the Event Library and Results next to SDK and pixel events. An S2S 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." }
]
}
StatusCodeMeaning
400VALIDATION_FAILEDA missing, malformed or unknown field, or text containing the NUL character (\u0000). One entry per problem, with its field.
401AUTH_HEADER_MISSINGNo Authorization: Bearer lf_sk_… header.
401INVALID_SERVER_KEYThe key is wrong or revoked.
401STANDARD_KEY_NOT_ALLOWEDA standard API key was sent. Use an S2S key.
403WORKSPACE_RESTRICTEDThe workspace is restricted under review, so it can't record events.
409EVENT_IN_PROGRESSAnother request with this eventId is still being processed. Retry a moment later.
409ROLLUP_BUSYDaily totals were being rebuilt and the event, dated before today, was not stored. Retry a few seconds later.
422TIMESTAMP_TOO_OLDoccurredAt is more than 30 days ago.
422TIMESTAMP_IN_FUTUREoccurredAt is more than 5 minutes ahead of our clock.
422UNKNOWN_INSTALLNo install with this installId in this workspace.
422UNKNOWN_CLICKNo click with this clickId in this workspace in the last 7 days.
422UNKNOWN_ORIGINAL_EVENTrefundOf names no accepted event in this workspace and environment.
422REFUND_OF_REFUNDrefundOf names an event that is itself a refund.
422REFUND_EXCEEDS_ORIGINALThe refund is more than what's left of the original.
422CURRENCY_MISMATCHThe refund's currency isn't the original's.
429RATE_LIMITEDOver 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 index and the totals.
  • A repeated eventId within one batch is refused for every copy after the first, with DUPLICATE_IN_BATCH.
  • A repeat of an eventId accepted before reads as the single endpoint answers it: "status": "accepted" with "duplicate": true. It's counted under duplicates.
  • An event we fail to record on our side is "status": "failed" with INTERNAL_ERROR (or ROLLUP_BUSY), and the rest of the batch is still recorded. Send that event again.
  • An empty events array is VALIDATION_FAILED; more than 100 is BATCH_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 eventId is recorded. Any later request with the same eventId in 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 own eventId, 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 named purchase would add a purchase, and a conversion if purchase is a goal, while subtracting its revenue.
  • refundOf is the eventId of an accepted purchase, sent with a key of the same environment, up to 400 days old.
  • Omit installId and clickId: the refund is credited where the purchase was, to the same install or click and link.
  • revenue is 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 → S2S 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​