Enhance returning user experience and boost conversions with Klarna Account Linking by securely storing and updating customer tokens for seamless, persistent authentication.
Linking a customer’s Klarna account to their account on your platform helps increase conversion by enabling seamless, non-interactive authentication for future payments.
Many integration strategies rely on browser-side tracking, like cookies or device-based single sign-on, to recognize returning customers. However, these methods are increasingly unreliable:
To avoid these limitations, store Klarna’s long-lived customer_token
securely on your backend. This token lets you reliably recognize returning customers, regardless of browser or device, and trigger a seamless Klarna flow without requiring them to log in again.
buy_and_link
.customer_token
in the request.client_token
returned in the create session response.customer_token
returned in the create order response. Customers can opt out from account linking, so a customer_token
might not be returned in certain sessions.If the provided token is invalid or has been rotated, Klarna will return a new one. Always treat the token from the latest response as the source of truth.
Term | Description |
---|---|
Customer Token | A long-lived credential issued by Klarna that identifies a customer across payment requests. It enables a seamless, non-interactive experience. Format: krn:partner:<region>:<env>:identity:customer-token:<id> |
Intent | A parameter that defines the purpose of the session. Use buy_and_link to both complete a payment and link or refresh the customer token. |
On‑demand Token | One‑time token derived from a Customer Token (via Customer Token API) that authorises a single server‑to‑server capture—ideal for subscriptions or metered billing. |
Send a POST
request without a token to create a Klarna payments session:
Sample request - without customer_token
Including a valid customer_token
, allows Klarna to skip the login step and load the payment form in a ready-to-buy state.
Sample request - with customer_token
curl -X POST https://api.klarna.com/payments/v1/sessions \
-u $KLARNA_USERNAME:$KLARNA_PASSWORD \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: 3bcdc404-9f4c-4cd0-9d63-2d1092f361dd' \
-d '{
"purchase_country": "DE",
"purchase_currency": "EUR",
"locale": "de-DE",
"order_amount": 25900,
"order_tax_amount": 4130,
Once the customer confirms the purchase, create an order using the valid authorization_token
.
Sample response
{
"order_id": "12345678-1234-1234-1234-123456789abc",
"redirect_url": "https://www.mystore.com/confirmation?order_id=12345678-1234…",
"customer_token": "krn:partner:eu1:live:identity:customer-token:AbCdEfGh1234567"
}
Don't forget to store or update the token in your user database:
// pseudo‑code
if (order.customer_token) {
const existing = await db.users.get(userId);
if (existing.klarnaCustomerToken !== order.customer_token) {
await db.users.update(userId, {
klarnaCustomerToken: order.customer_token
});
}
}
Klarna may rotate tokens for security reasons. if a previously stored token is invalid or expired, Klarna will:
Always treat the returned customer_token
as the source of truth and update your records accordingly.