# Authentication

API keys for the sandbox and live environments, how to send them as a Bearer token, and how to keep them safe on your server.

Every request is authenticated with an API key sent in a **header**. Keys are never accepted in the URL, so they cannot leak into server logs, proxies or browser history.

```http
Authorization: Bearer sk_live_...
```

`X-API-Key: sk_live_...` is accepted as an alternative for clients that cannot set `Authorization`.

## Sandbox and live keys

| Prefix | Environment | Charged | Use it for |
|---|---|---|---|
| `sk_test_` | Sandbox | No | Development and CI: real calculations, up to 500 calls a day |
| `sk_live_` | Live | Yes | Production traffic |
| `pk_test_` / `pk_live_` | Sandbox / Live | Like `sk_` | [Publishable keys](https://96astroapi.com/docs/key-restrictions.md#publishable-keys) for browser widgets on your allowed websites |

A key works only in its own environment.

## Managing keys

- **Viewable again by the right people.** Secret keys can be shown again on the API keys page by whoever made them, and by owners and admins; they stay encrypted at rest and every tool in the portal picks them from a list, so you rarely copy one. A few early keys were stored only as a fingerprint and cannot be shown: if you lose one, rotate it.
- **Named.** Give each integration its own key, so revoking one never breaks another. A key can call every capability unless you give it [scopes](https://96astroapi.com/docs/key-restrictions.md#scopes), and can be limited to your servers' [IP addresses](https://96astroapi.com/docs/key-restrictions.md#ip-allow-lists).
- **In a project.** Every key belongs to a [project](https://96astroapi.com/docs/teams-and-projects.md) of your organization. Its calls count toward that project's usage and, if the project has one, its monthly credit budget (`429 project_budget_exceeded` when it is used up). Keys belong to projects, not people: a key keeps working when the teammate who created it leaves the team, unless it is revoked.
- **Rotation.** Create the new key, deploy it, then revoke the old one. Both work during the changeover.
- **Last used.** The dashboard shows when each key was last used.
- **Revocation** takes effect immediately.
- **Who can manage keys.** In a team, owners, admins and developers can create keys; developers can revoke the keys they created, owners and admins any key. Billing members and viewers cannot see or create keys. See [Teams and projects](https://96astroapi.com/docs/teams-and-projects.md).

## Keep keys on your server

Call the API from your backend. A key inside a mobile app, a single-page app or a WordPress theme can be extracted by anyone. If you need astrology data in a browser or app, have it call your server, and have your server call us, or, for a simple widget (today's panchang, a daily horoscope, a match), use a [publishable key](https://96astroapi.com/docs/key-restrictions.md#publishable-keys) restricted to your website.
