Inspect the API key
/v1/api-keys/currentReturns the environment, scopes and project of the key making the request. Needs no scope; useful as a startup check.
Responses
- 200
The key.
- 401
The API key is missing, malformed, unknown, revoked or expired.
Example
Response 401{ "success": false, "error": { "code": "AUTHENTICATION_REQUIRED", "message": "An API key is required; send it in the X-API-Key header or as \"Authorization: Bearer <key>\"" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 403
The key may not do this: missing scope, IP not on the allow-list, company, project or key suspended by SMS21, project archived, wallet suspended or destination blocked.
Example
Response 403{ "success": false, "error": { "code": "INSUFFICIENT_SCOPE", "message": "This API key does not have the required scope", "details": [ { "message": "requires scope sms:send" } ] }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 429
Rate limited. Wait
Retry-Afterseconds, then retry with the same Idempotency-Key.Example
Response 429{ "success": false, "error": { "code": "RATE_LIMITED", "message": "Rate limit exceeded for this API key" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 503
Temporarily unavailable, or live sending paused by SMS21. Retry later with the same Idempotency-Key.
Example
Response 503{ "success": false, "error": { "code": "SERVICE_UNAVAILABLE", "message": "Service temporarily unavailable" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" }
curl -X GET "https://sms21.in/v1/api-keys/current" \
-H "X-API-Key: $SMS21_API_KEY"{
"success": true,
"id": "key_01k55q8y4m3d9v7x2c6b0n1r8t",
"environment": "test",
"scopes": [
"otp:send",
"otp:verify",
"reports:read"
],
"projectId": "prj_01k55q8y4m3d9v7x2c6b0n1r8t",
"companyId": "cmp_01k55q8y4m3d9v7x2c6b0n1r8t"
}