Apps
Register applications, manage settings, rotate API keys, and test webhook delivery.
/v1/apps/registeradminRegister a new application and receive an API key.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | App display name, 1–100 characters. |
tenantId | string | Required | Tenant to associate the app with. Required after bootstrap. Format: tenant_ + 16 hex characters. |
webhookUrl | string | null | Optional | URL to receive inbound SMS webhooks. Must be HTTPS in production, max 2000 characters. |
role | string | Optional | "app" (default) or "admin". Only callers with an existing admin key can set this field. Admin keys have platform-wide access. |
curl -X POST https://smsgateway-api.onrender.com/v1/apps/register \-H "Authorization: Bearer YOUR_API_KEY" \-H "Content-Type: application/json" \-d '{"name": "My CRM Integration","tenantId": "tenant_abc123def456abcd","webhookUrl": "https://my-app.example.com/webhooks/sms"}'
Success response
{"appId": "app_f1e2d3c4b5a69870","name": "My CRM Integration","apiKey": "sgw_a1b2c3d4e5f6789012345678abcdef90","apiKeyPrefix": "sgw_a1b2","role": "app","tenantId": "tenant_abc123def456abcd"}
apiKey is returned once and cannot be retrieved again. The gateway stores only a SHA-256 hash.Error responses
{"error": "name must be 1-100 characters"}
{"error": "tenantId is required when registering new apps"}
{"error": "Invalid tenantId format"}
{"error": "Tenant not found or not active"}
{"error": "Invalid webhookUrl: must be https:// in production, max 2000 chars"}
{"error": "Admin API key required to register new apps"}
/v1/appsapp or adminList all apps visible to the caller.
App role returns apps in the same tenant. Admin role returns all apps across all tenants. The apiKeyHash field is never returned.
curl https://smsgateway-api.onrender.com/v1/apps \-H "Authorization: Bearer YOUR_API_KEY"
Success response
{"apps": [{"appId": "app_abc123def456abcd","tenantId": "tenant_abc123def456abcd","name": "My CRM Integration","webhookUrl": "https://my-app.example.com/webhooks/sms","role": "app","isActive": true,"apiKeyPrefix": "sgw_a1b2","lastUsedAt": "2026-03-01T09:30:00.000Z","createdAt": "2026-02-15T12:00:00.000Z","updatedAt": "2026-03-01T09:30:00.000Z"}]}
/v1/apps/:appIdapp (own app) or adminUpdate an app's webhook URL or active status.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
webhookUrl | string | null | Optional | New webhook URL, or null to remove. Must be HTTPS in production, max 2000 characters. |
isActive | boolean | Optional | Set to false to deactivate the app (API key stops working). |
curl -X PUT https://smsgateway-api.onrender.com/v1/apps/app_abc123def456abcd \-H "Authorization: Bearer YOUR_API_KEY" \-H "Content-Type: application/json" \-d '{"webhookUrl": "https://my-app.example.com/webhooks/sms"}'
Success response
{"ok": true}
Error responses
{"error": "Invalid appId format"}
{"error": "Invalid webhookUrl: must be https:// in production, max 2000 chars"}
{"error": "App not found"}
/v1/apps/:appIdapp (own app) or adminDeactivate an app (soft delete). The API key stops working immediately.
curl -X DELETE https://smsgateway-api.onrender.com/v1/apps/app_abc123def456abcd \-H "Authorization: Bearer YOUR_API_KEY"
Success response
{"ok": true}
Error responses
{"error": "Invalid appId format"}
{"error": "App not found"}
/v1/apps/:appId/rotate-keyapp (own app) or adminGenerate a new API key, immediately invalidating the old one.
curl -X POST https://smsgateway-api.onrender.com/v1/apps/app_abc123def456abcd/rotate-key \-H "Authorization: Bearer YOUR_API_KEY"
Success response
{"apiKey": "sgw_new1a2b3c4d5e6f7a8b9c0d1e2f3a4b5","apiKeyPrefix": "sgw_new1"}
Error responses
{"error": "Invalid appId format"}
{"error": "App not found"}
/v1/apps/:appId/test-webhookapp (own app) or adminSend a test payload to the app's configured webhook URL.
Sends a POST request with a test payload to the app's webhookUrl. The test payload has the following shape:
{"type": "test","timestamp": "2026-03-01T12:00:00.000Z","source": "smsgateway"}
curl -X POST https://smsgateway-api.onrender.com/v1/apps/app_abc123def456abcd/test-webhook \-H "Authorization: Bearer YOUR_API_KEY"
Success response
If your webhook responds with a 2xx status:
{"ok": true}
If your webhook responds with a non-2xx status or times out (5 second timeout):
{"ok": false,"status": 500,"error": "Internal Server Error"}
Error responses
{"error": "Invalid appId format"}
{"error": "App has no webhookUrl configured"}
{"error": "App not found"}
Related docs
- Authentication — API key format and roles
- Webhooks Guide — Webhook URL setup and payload format
- Receiving SMS — Inbound SMS webhook delivery