Docs
    GuidesAPI ReferenceBlog
    Sign inCreate account
    Overview

    Getting started

    Sign upAPI keysQuickstartLoad your catalog

    Integration

    Tracking EventsIdentity StitchingPersonalisation

    Production

    Errors & status codesRetries & rate limitsTypeScript SDKTroubleshooting

    Reference

    API ReferenceVersioningChangelog
    HomeDocumentationAPI keys
    Previous
    Sign up
    Next
    Quickstart

    Skip the ML, Ship the Revenue

    Product

    • How It Works
    • Features
    • For Startups
    • For Developers

    Developers

    • Documentation

    Company

    • Blog
    • Contact

    © 2026 Lehnz, Inc. All rights reserved.

    Authentication

    API keys

    Every request to the lehnz API is authenticated with an API key. Each organization gets one key pair: a publishable key for client-side code and a secret key for your servers.

    The two key types

    TypePrefixWhere it's safeWhat it can do
    Publishablelehnz_pk_…Browser, mobile apps, client-side codeSend events, fetch recommendations
    Secretlehnz_sk_…Server-side only — never ship to a browserAll publishable scopes, plus any future write-heavy endpoints

    The server enforces key type. Sending a secret key from a public endpoint (or vice versa) returns 403 Forbidden.

    If your secret leaks, rotate — don't verify

    We cannot recover a leaked secret. After any suspected exposure, generate a new pair and revoke the old one rather than attempting to confirm what was leaked.

    Generating your first pair

    1. Sign in to the dashboard.
    2. Open Developer Access.
    3. Click Generate Key Pair. The dashboard shows both keys.
    4. Copy the secret key immediately into your secret manager. The dashboard shows it exactly once. After this dialog closes, only the publishable key remains visible.
    Lost secret = revoke and reissue

    If you lose the secret, you cannot retrieve it. Revoke the existing pair and generate a new one.

    Sending the key

    Pass the key in the X-API-KEY header on every request. There is no Bearer prefix.

    request-header.txt
    X-API-KEY: lehnz_pk_…

    Which key for which endpoint

    EndpointAccepted auth
    POST /api/v1/events/ingestPublishable (lehnz_pk_*)
    POST /api/v1/items/upsertSecret (lehnz_sk_*)
    POST /api/v1/users/upsertSecret (lehnz_sk_*)
    POST /api/v1/upload/itemsDeveloper JWT (dashboard only)
    POST /api/v1/upload/usersDeveloper JWT (dashboard only)
    POST /api/v1/recommendPublishable (lehnz_pk_*)

    Bulk file imports happen from the dashboard rather than the public API — see Load your catalog.

    Rotating keys

    Rotate immediately if a key is committed to a public repo, leaks via a log, or any other suspected exposure. Plan a rotation at least once a year for healthy hygiene.

    1. From Developer Access, click Generate Key Pair. This creates a new pair without revoking the old one — you have a brief overlap window to deploy.
    2. Update your secret manager and redeploy your services with the new keys.
    3. Once you've confirmed the new keys are live, revoke the old pair from the dashboard. Subsequent requests with the old keys will return 401 Unauthorized.

    Only members with OWNER or ADMIN role can generate or revoke keys.

    Permissions

    RoleView keysGenerate / revoke
    OWNERYesYes
    ADMINYesYes
    DEVELOPERYes (masked)No
    MEMBERNoNo

    Every generation, view, and revocation is recorded in the org's audit log.

    Errors

    StatusCauseFix
    401Missing or malformed X-API-KEY headerConfirm the header is set and starts with lehnz_pk_ or lehnz_sk_.
    401Key was revoked or never existedCheck the dashboard. If the key shows as revoked, generate a new pair.
    403Wrong key type — e.g. publishable on a secret-only endpointCheck the table above.
    403Caller's role lacks permission to manage keysAsk an OWNER or ADMIN to perform the action.
    429Too many requests across this org's keysBack off. See Retries & rate limits.

    What's next

    Quickstart

    Send your first event and fetch your first recommendation.

    Load your catalog

    Bulk-upload your items and users.