# Authenticate with API keys

> Send your secret key as a bearer token. Keys can be limited to scopes and IP ranges.

Source: https://helpdox.fekbd.com/docs/relay-api/auth/authenticate-with-api-keys/

Send your secret key as a bearer token. Keys can be limited to scopes and IP ranges. Follow the steps below — it takes just a few minutes.

## Before you begin

- A Relay account and a test-mode API key
- `curl` or one of the official SDKs

## Steps

1. 1Add the headerEvery request needs `Authorization: Bearer rk_live_…`.
2. 2Limit the scopeGive each service only the scopes it needs, such as `messages:write`.
3. 3Restrict by IPOptionally allow requests only from your servers’ IP ranges.

Tip

Never put a secret key in a mobile app or browser code.

## Example

POST /v3/messages

```
curl https://api.relay.example/v3/messages \
  -H "Authorization: Bearer $RELAY_KEY" \
  -d channel=sms \
  -d to=+15550100001 \
  -d body="Your code is 482913"
```

```
import Relay from '@relay/node';

const relay = new Relay(process.env.RELAY_KEY);
const msg = await relay.messages.create({
  channel: 'sms',
  to: '+15550100001',
  body: 'Your code is 482913',
});
console.log(msg.status); // queued
```

```
import os, relay

client = relay.Client(os.environ["RELAY_KEY"])
msg = client.messages.create(
    channel="sms", to="+15550100001", body="Your code is 482913"
)
print(msg.status)  # queued
```

## Still stuck?

Include the request ID from the `Relay-Request-Id` response header — it lets us find your call in seconds.
