Search Documentation

Search for a documentation page...

Authentication

Authenticate with the YNS API using API keys and the Commerce SDK.

API Keys

All YNS API requests require authentication via an API key. You can create and manage keys in the YNS dashboard under Settings > API Keys.

Key Types

PrefixEnvironmentEndpoint
sk-Productionyns.store
sk-s-Stagingyns.cx

Staging keys connect to a sandbox environment where you can test without affecting real data or processing real payments.

SDK Authentication

The Commerce SDK handles authentication automatically:

import { Commerce } from "commerce-kit";

// Reads YNS_API_KEY from environment
const commerce = Commerce();

// Or pass explicitly
const commerce = Commerce({
token: "sk-your-api-key",
});

The SDK adds the API key to every request as a Bearer token in the Authorization header.

Direct API Authentication

If you're calling the API directly (without the SDK), include the key in the Authorization header:

curl https://yns.store/api/v1/products \
-H "Authorization: Bearer sk-your-api-key"

Security Best Practices

  • Never expose API keys in client-side code. The SDK is designed for server-side use only (Server Components, Server Actions, API routes).
  • Use staging keys for development. Switch to production keys only in your deployed environment.
  • Rotate keys if compromised. You can create new keys and revoke old ones from the dashboard.
  • Use environment variables. Store keys in .env.local (local) or your hosting platform's environment variable settings (production).