Overview
The Lamah SMS API uses Bearer token authentication for all requests. This guide covers everything you need to know about obtaining, using, and managing your API tokens securely.Getting Your API Token
1
Create Account
Sign up for a Lamah account at https://sms.lamah.com
2
Create Project
Navigate to the Projects section and create a new project
3
Generate Token
Copy the API token from your project settings
4
Secure Storage
Store your token securely using environment variables
Using Your Token
Include your API token in theAuthorization header of every request:
Security Best Practices
Environment Variables
Store tokens in environment variables, never in code
Rotate Regularly
Generate new tokens periodically for security
Limit Scope
Use project-specific tokens with minimal required permissions
Monitor Usage
Regularly monitor API usage for suspicious activity
Token Management
Environment Variables
Token Validation
Test your token with a simple API call:Common Authentication Errors
401 Unauthorized
- Verify your token is correct
- Check the Authorization header format
- Ensure the token hasn’t expired
403 Forbidden
- Verify your project has access to the endpoint
- Check if your account has the required permissions
- Contact support if you believe this is an error
SDK Examples
JavaScript/Node.js SDK
Python SDK
Rate Limiting
The API includes rate limiting to ensure fair usage:- SMS Endpoints: 100 requests per minute
- OTP Endpoints: 10 requests per minute per phone number
- Other Endpoints: 1000 requests per minute
Troubleshooting
Token not working after generation
Token not working after generation
Wait a few minutes after generating a new token, as there may be a brief propagation delay.
Intermittent authentication failures
Intermittent authentication failures
Check if you’re hitting rate limits or if there are network connectivity issues.
Token works in testing but not production
Token works in testing but not production
Ensure you’re using the correct token for your production environment and that environment variables are properly set.