Skip to content

Server SDKs: quickstart

Everything below uses your secret write key (project settings → API keys). Keep it in an environment variable; it must never ship to a browser.

Terminal window
composer require kilden/kilden-php
$kilden = new Kilden\Client(getenv('KILDEN_SECRET_KEY'));
$kilden->track('user_42', 'order_completed', [
'revenue' => 99.9,
'currency' => 'CLP',
]);

Events are queued in memory and sent in batches. Call close() when your process shuts down (Laravel, FPM and the shutdown hooks handle this for you in PHP; in Go use defer client.Close()); anything still queued past a 10-second deadline is dropped rather than hanging your process.

identify upserts person traits. The distinct_id is explicit on every call — server SDKs hold no identity state.

$kilden->identify('user_42', ['plan' => 'pro', 'email' => '[email protected]']);

Identity verification needs your backend to sign a short-lived JWT for the logged-in user. IdentitySigner does it without a JWT library — and your endpoint is three lines. Only ever sign an id your backend authenticated: signing a user id taken from request input lets anyone impersonate anyone, with a “verified” seal on top.

$signer = new Kilden\IdentitySigner(getenv('KILDEN_IDENTITY_SECRET'), ['kid' => 'k1']);
$token = $signer->sign($user->id, [
'traits' => ['plan' => $user->plan],
]);

Using Laravel? kilden/laravel ships a publishable POST /kilden/identity route behind your auth middleware — no code at all.

The WordPress plugin exposes the same thing at /wp-json/kilden/v1/identity, cache-safe by construction.

isEnabled(flag_key, distinct_id, { person_properties?, default? })
getFeatureFlag(flag_key, distinct_id, { person_properties?, default? })

Evaluated by Kilden server-side, cached in-process for 30 seconds per distinct_id, one attempt with a hard timeout, then your default. Full semantics in the feature flags guide.