API Keys
API keys authenticate your requests to the SMS Gateway. Each key can have granular permissions and restrictions for secure access control.
Overview
API keys are credentials that allow you to authenticate programmatic access to the SMS Gateway API. Each key is associated with your organization and can be scoped with specific permissions, IP restrictions, and expiration dates.
Your full API key is only shown once at creation time. Store it securely and never expose it in client-side code or version control.
Key Format
API keys follow a standardized format with environment prefixes:
sg_live_xxxxxxxxxxxxUse for live traffic. Requests count toward your billing and send real messages.
sg_test_xxxxxxxxxxxxUse for testing. Requests are simulated and do not incur charges.
Available Endpoints
/api/v1/developer/api-keysList all API keys/api/v1/developer/api-keys/:idGet key details/api/v1/developer/api-keysCreate new key/api/v1/developer/api-keys/:idUpdate key/api/v1/developer/api-keys/:id/regenerateRegenerate key value/api/v1/developer/api-keys/:id/enableEnable key/api/v1/developer/api-keys/:id/disableDisable key/api/v1/developer/api-keys/:idDelete keyCreate an API Key
Send a POST request with the following body to create a new API key.
Request Body
namedescriptionpermissions["sms.send", "sms.read"]).expiresIn"30d", "90d").ipRestrictions1{2 "name": "Production Server",3 "description": "API key for production SMS sending",4 "permissions": ["sms.send", "sms.read"],5 "expiresIn": "90d",6 "ipRestrictions": ["192.168.1.1", "10.0.0.0/8"]7}List API Keys
1[2 {3 "id": "key_abc123def",4 "name": "Production Server",5 "keyPrefix": "sk_4f2a1b9c...",6 "permissions": ["sms.send", "sms.read"],7 "isActive": true,8 "createdAt": "2025-01-10T08:00:00.000Z",9 "lastUsedAt": "2025-01-15T09:30:00.000Z",10 "expiresAt": "2025-04-10T08:00:00.000Z"11 },12 {13 "id": "key_ghi456jkl",14 "name": "CI/CD Pipeline",15 "keyPrefix": "sk_8d3e2f0a...",16 "permissions": ["sms.send"],17 "isActive": true,18 "createdAt": "2025-01-12T14:00:00.000Z",19 "lastUsedAt": null,20 "expiresAt": null21 }22]Regenerate Key
Regenerating a key creates a new secret value while preserving the key's ID, name, and configuration. The old value is immediately invalidated.
1{2 "id": "key_abc123def"3}4// Response:5{6 "id": "key_abc123def",7 "name": "Production Server",8 "rawKey": "sk_abc123def456ghi789jkl012mno345pqr678stu901vwx234yz",9 "keyPrefix": "sk_abc123def..."10}Available Permissions
sms.sendSend single and bulk SMS messagessms.readRead message history and delivery statusotp.sendGenerate and send OTP codesotp.verifyVerify OTP codescontacts.readRead contact listscontacts.writeCreate and manage contactscampaigns.manageCreate and manage campaignsanalytics.readAccess analytics datawebhooks.manageManage webhook endpointsSecurity Best Practices
Rotate Regularly
Rotate API keys periodically (every 90 days recommended) to limit exposure from potential credential leaks.
Use IP Restrictions
Restrict keys to known IP addresses to prevent unauthorized use even if the key is compromised.
Least Privilege
Grant only the minimum permissions required for each key's intended use case.
Monitor Usage
Regularly review key usage in the Developer Portal and revoke unused or suspicious keys.