# API key

> An API key is the secret credential that identifies an account to the SMS API; it is sent as a bearer token, scoped to what it may do, and should be created per system and revoked when exposed.

An API key is a password for software: a long random string that identifies the account and carries a set of permissions. Unlike a person's password it is used by machines, without a second factor, so its protection rests on how it is issued, stored and limited. A sound implementation shows the key once at creation and keeps only a hash, lets you scope it to what it may do, can tie it to an IP allowlist and revokes it instantly. A recognisable prefix, such as one marking live or test keys, helps people and secret-scanning tools spot a key that has leaked into a repository or a log.

The working rule is one key per system and environment, with the smallest scope that works. Keys belong in environment variables or a secrets manager, never in client-side code, a mobile app or source control. Rotation is routine: create the new key, deploy it, revoke the old one. A leak is handled the same way, immediately.

## Example

A hypothetical company runs a checkout service that only sends codes and a reporting job that only reads statuses. The checkout service gets a live key scoped to sending and allowlisted to its two servers; the reporting job gets a read-only key; staging uses a test key. When the reporting key turns up in a public log, it cannot send a single message, and replacing it touches one system.

## Common mistakes

- Shipping the key inside a web page or an app, where anyone can extract it.

- Sharing one key across every system, so that a leak means rotating everywhere.

- Logging full request headers, which writes the key into log files.

- Running automated tests with a live key.

At SMSMeteor: keys are created in the panel, shown once, and sent as [bearer tokens](https://smsmeteor.io/glossary/bearer-token) with an `sk_live_` or `sk_test_` prefix. They are scoped to `send`, `read` or both, and a key may carry an IP allowlist; requests from other addresses receive `401 unauthorized`. [Test keys](https://smsmeteor.io/glossary/test-key) validate, price and answer like live ones, return the status `test`, and never send or bill. See also the [security page](https://smsmeteor.io/security).

Related terms: [Bearer token](https://smsmeteor.io/glossary/bearer-token), [Test key (sandbox)](https://smsmeteor.io/glossary/test-key), [REST API (SMS)](https://smsmeteor.io/glossary/rest-api)

---
Source: https://smsmeteor.io/glossary/api-key (HTML). Generated by SMSMeteor from the same data as the page. Summary of the whole site: https://smsmeteor.io/llms.txt
