Lynkow uses five identifiers and credentials. This page says what each one unlocks, where you find it in the dashboard, how to send it, and which ones must stay secret. Previous: Which API Should I Use? | Next: Errors
Reference - This guide is a tutorial. For exhaustive, always-current signatures and field lists, see the auto-generated reference:
Prerequisites
A Lynkow site (Quick Start, "Use your own site")
Access to Settings > Developers in the dashboard
Summary
Credential | Looks like | Where to find it | Secret | How to send it |
|---|---|---|---|---|
Site ID | A UUID | Settings > Developers > Storefront, Site ID | No | In the URL: |
Publishable key |
| Settings > Developers > Storefront, Storefront keys | No |
|
Server key |
| Settings > Developers > Storefront, Server keys | Yes |
|
API token |
| Settings > Developers > API | Yes |
|
Customer token | Returned when a buyer signs in | Your app receives it from the API | Yes, it belongs to one buyer |
|
The SDK takes the first four in createClient() and sets the customer token for you after a sign-in.
Site ID
The Site ID names your site in every Storefront API request. It is not a secret: it appears in every URL your site calls. Content, pages, search, forms and reviews need nothing else:
import { createClient } from 'lynkow'
export const lynkow = createClient({
siteId: process.env.NEXT_PUBLIC_LYNKOW_SITE_ID!,
})A Site ID that is not a UUID returns 400 TENANT_SITE_ID_INVALID, and an unknown one returns 404 TENANT_SITE_NOT_FOUND.
Publishable key
The publishable key identifies your storefront app. The shop routes require it: products, collections, categories, markets, the cart, checkout and buyer accounts. Other routes accept it and do not need it. It is safe in browser code:
export const lynkow = createClient({
siteId: process.env.NEXT_PUBLIC_LYNKOW_SITE_ID!,
publishableKey: process.env.NEXT_PUBLIC_LYNKOW_PUBLISHABLE_KEY,
})Create one with New key under Storefront keys. A shop route without a key returns 401 STOREFRONT_KEY_REQUIRED, and with a revoked key 401 STOREFRONT_KEY_REVOKED.
Server key
The server key is for a server that calls the Storefront API on behalf of buyers, such as a Next.js Server Action. It vouches for the buyer's IP address your server forwards, so rate limits count each buyer instead of your server. It reads and changes nothing on its own.
Keep it in your server's environment, never in a NEXT_PUBLIC_ variable: the SDK throws when serverKey is set in a browser. Server Key and Buyer IP covers the setup.
API token
An API token authenticates the Admin API, under /v1:
curl "https://api.lynkow.com/v1/contents" \
-H "Authorization: Bearer $LYNKOW_API_TOKEN"Create one under Settings > Developers > API with New token. The dashboard shows the token once: copy it then. Each token has its own permissions, such as contents.view or products.update. Give a token only the permissions its job needs, and an expiration date when the job is temporary.
Status and code | Meaning |
|---|---|
401 | No |
401 | The token is unknown, deleted or regenerated |
401 | The token passed its expiration date |
403 | The token lacks a permission the route needs. The message names it |
A site token acts on its own site. An organization token, which can reach several sites, names the site in the X-Site-Id header.
An API token can change your site's data. Use it from your server only, and never commit it.
Customer token
When a buyer signs in, the API returns a session token for that buyer. Buyer routes, such as the account page and its orders, take it in Authorization: Bearer, together with the publishable key:
const { customer, token } = await lynkow.customers.login({
email: '[email protected]',
password: 'their-password',
})The SDK sends the token on the next buyer calls of the same client. It does not store it: keep it yourself, for example in an HttpOnly cookie, and pass it back as customerToken in createClient(). A missing or invalid token on a buyer route returns 401 CUSTOMER_AUTH_REQUIRED. Customer Accounts covers sign-up, sign-in and sessions.
What is secret
Safe in browser code | Server only |
|---|---|
Site ID, publishable key | Server key, API token |
A customer token belongs to one buyer: keep it in that buyer's session, never in shared code or logs. If a secret leaks, regenerate or revoke it on the page where you created it.
Reference
API: Storefront: Site Access & Spam Protection, Admin API Authentication
SDK:
CustomersService, SDK Types
Next Steps
Errors - the error body, the status codes and the SDK's
LynkowErrorServer Key and Buyer IP - forward each buyer's IP from your server
Customer Accounts - buyer sign-up, sign-in and sessions