Authentication
TXTLINK API supports two authentication methods: API keys (recommended) and username/password. Choose the method that works best for your application.
Authentication Methods
API Key (Recommended)
RecommendedUse API keys for production applications. More secure and easier to manage.
Username/Password
Use your account credentials. Great for testing and simple integrations.
API Key Types
Test Keys
Use test keys for development. Messages sent with test keys are not delivered to real phone numbers.
Live Keys
Use live keys for production. Messages sent with live keys are delivered to real phone numbers and charged to your account.
Using API Keys
Include your API key in the Authorization header of every API request as a Bearer token:
curl https://api.txtlink.com/v1/sms/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+254712345678",
"message": "Hello from TXTLINK",
"senderIdName": "TXTLINK"
}'Getting Your API Key
Using Username/Password
You can authenticate using your account email and password in two ways:
Use HTTP Basic Authentication. This is the standard and most secure method:
curl https://api.txtlink.com/v1/sms/send \
-u "your-email@example.com:your-password" \
-H "Content-Type: application/json" \
-d '{
"to": "+254712345678",
"message": "Hello from TXTLINK",
"senderIdName": "TXTLINK"
}'Security Note
Environment Variables
Store your API key in an environment variable. Never hardcode it in your source code.
# .env file
TXTLINK_API_KEY=sk_live_abc123xyz...Security Best Practices
- Never commit API keys to version control
- Use different keys for test and production environments
- Rotate keys regularly
- Use IP whitelisting for additional security
Key Rotation
Regularly rotate your API keys to maintain security. You can create new keys and revoke old ones from the dashboard without service interruption.
- Generate a new API key in Settings → API Keys
- Update your environment variables with the new key
- Test that your application works with the new key
- Revoke the old key once you've confirmed everything works
IP Whitelisting
For additional security, you can restrict API key usage to specific IP addresses. This prevents unauthorized access even if your key is compromised.