Authentication and API keys
Create an API key, send it as a Bearer token and keep it secret.
Every API call needs an API key, except the few public routes marked in the API reference.
Live and test keys
| Key starts with | What happens |
|---|---|
jtsms_live_ | Real SMS. Each message is charged to your balance. |
jtsms_test_ | Sandbox. Nothing is sent to a phone and nothing is charged. Use it while you build. |
A test key only sees test messages. A live key only sees live messages.
Create a key
- Sign in at app.sms.jtnoble.com.
- Open API keys and choose Create key.
- Give it a name, for example
website, and pick live or test. - Copy the key now. It is shown once. We only store a fingerprint of it.
Keys are made and revoked in the dashboard. An API key cannot make another key (HTTP 403, code portal_only).
Send the key
Put the key in the Authorization header on every request:
Authorization: Bearer jtsms_live_YOUR_KEYDo not put the key in the URL. URLs end up in logs.
Scopes
A key can be limited to some actions.
| Scope | Allows |
|---|---|
send | Sending messages, and every other change except webhooks. |
query | Reading messages, balance and reports. |
webhooks | Reading and changing webhook settings. |
New keys get send, query and webhooks. A call outside the key's scopes gets HTTP 403 with code insufficient_scope. A key with query only is read-only on every route.
What a key cannot do
These need a person signed in to the dashboard: making or revoking API keys, team and workspace membership, and reseller client routes. In the reference they are marked "dashboard session token". API calls to them get HTTP 403 with code portal_only, or reseller_only on reseller routes.
Errors
| HTTP | Code | Meaning |
|---|---|---|
| 401 | unauthorized | No key, or the key is wrong or revoked. |
| 403 | insufficient_scope | The key does not have the scope for this action. |
| 403 | portal_only | This action is only available in the dashboard. |
| 403 | account_suspended | The account is suspended or paused. Contact support. |
Keep keys safe
- Keep keys on your server. Never put a key in a mobile app, a web page or a public code repository.
- Use one key per app, so you can turn one off without stopping the others.
- If a key leaks, delete it in the dashboard at once and create a new one.