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
| Prefix | Environment | Endpoint |
|---|---|---|
sk- | Production | yns.store |
sk-s- | Staging | yns.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:
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:
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).