Creating an API Key
1
Access your dashboard
Log in to your Lightyshare owner dashboard
2
Navigate to API settings
Go to Shop → API
3
Generate a new token
Click “Create New Token” and provide a descriptive name
4
Copy your token
Copy the generated token immediately - it won’t be shown again!
Important: Store your API key securely. Treat it like a password - never commit it to version control or share it publicly.
Using Your API Key
There are two ways to include your API key in requests:Method 1: Authorization Header (Recommended)
Include your token in theAuthorization
header using the Bearer scheme:
Method 2: Query Parameter
For backward compatibility, you can also pass the token as a query parameter:We recommend using the Authorization header method as it’s more secure and follows industry standards.
Token Format
Lightyshare API tokens follow a consistent format:- lsh: Prefix identifying a Lightyshare token
- environment: Either
live
for production ortest
for testing - unique_identifier: A unique string for your token
lsh_live_sk_1234567890abcdef
Token Permissions
API tokens inherit the permissions of the user account that created them:- Read Access: View products, bundles, and rentals
- Write Access: Create and update products and bundles
- Delete Access: Remove products (if user has permission)
Best Practices
Use Environment Variables
Store tokens in environment variables, not in code
Rotate Regularly
Rotate your API keys periodically for enhanced security
Limit Scope
Create separate tokens for different applications or environments
Monitor Usage
Track API key usage in your dashboard to detect anomalies
Revoking API Keys
If a token is compromised or no longer needed:- Go to your API settings
- Find the token in your list
- Click “Revoke” next to the token
- The token will be immediately invalidated
Environment-Specific Tokens
Lightyshare provides different token types for different environments:Environment | Token Prefix | Use Case |
---|---|---|
Production | lsh_live_ | Live production data |
Testing | lsh_test_ | Testing and development |
Always use test tokens during development to avoid affecting production data.
Troubleshooting
Common Authentication Errors
- Verify your token is correct and complete
- Check you’re using the right environment (live vs test)
- Ensure the token hasn’t been revoked