Authentication Guide

Learn how to authenticate your API requests securely.

API Key Authentication

All API requests require an API key for authentication. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Getting Your API Key

  1. Log in to your OpenSMS account
  2. Go to Settings → API Keys
  3. Click "Generate New Key"
  4. Copy your API key and keep it safe

Using Your API Key

Example Request

curl -X GET https://api.opensms.co.ke/v3/account \
  -H "Authorization: Bearer sk_live_abc123xyz789"

Security Best Practices

  • Never share your API key publicly
  • Store API keys in environment variables, not in code
  • Rotate your API keys regularly
  • Use HTTPS for all API requests
  • Revoke keys that are no longer needed

Revoking API Keys

If your API key is compromised, revoke it immediately:

  1. Log in to your account
  2. Go to Settings → API Keys
  3. Click "Revoke" next to the key
  4. Generate a new API key

Environment Variables Example

PHP (.env file)

OPENSMS_API_KEY=sk_live_abc123xyz789

Python (.env file)

OPENSMS_API_KEY=sk_live_abc123xyz789

Node.js (.env file)

OPENSMS_API_KEY=sk_live_abc123xyz789

Next Steps