# Authentication

> Bearer tokens, scopes, IP allowlists, rate limits and client references for the hoshime API.

Every call carries a bearer token in the `Authorization` header. Create your first one in the [dashboard](/dashboard/keys) after you [sign up](/signup). Tokens start with `hsk_` and are shown once, when they are created; hoshime stores only a hash.

```bash
curl "https://api.hoshime.com/v1/github/repo?repo=golang/go" \
  -H "Authorization: Bearer hsk_…"
```

A missing or invalid token answers `401 auth_token_invalid`. A token without the scope a route needs answers `403 auth_permission`.

## Scopes

Each route names the scope its token must hold. `*` grants every scope.

| Scope | Grants |
|---|---|
| `social:read` | Every public data endpoint, `GET /v1/<platform>/<endpoint>`, and the MCP server |
| `browser:read`, `browser:write` | Scrape and crawl |
| `serp:read`, `serp:write` | Search results and rank checks |
| `screenshots:read`, `screenshots:write` | Screenshots |
| `jobs:read`, `jobs:write` | Jobs and schedules |
| `webhooks:read`, `webhooks:write` | Webhook endpoints and deliveries |
| `usage:read` | Usage reports |
| `tunnels:read`, `tunnels:write` | List tunnels; register, connect (`hoshime tunnel`) and delete them |
| `tokens:admin` | Create and revoke tokens |

## Tokens for your own customers

A token with `tokens:admin` creates tokens in its own account with only the scopes it holds itself. A new token inherits the creator's expiry, IP allowlist and rate limit, and may only narrow them. Give each of your customers their own narrow token, and revoke it with `DELETE /v1/tokens/{tokenId}`.

## IP allowlists and rate limits

A token may carry an IP allowlist: calls from other addresses answer `403 auth_ip_not_allowed`. A token may also carry a per-minute rate limit: calls over it answer `429 rate_limited` with a `Retry-After` header in seconds.

## Client references

Send `X-Client-Ref` (up to 128 characters) to tag a call with your own reference, such as your customer's id. It is stored with created work and usage, comes back on webhook events as `clientRef`, and `GET /v1/usage?groupBy=clientRef` sums usage by it, so you can bill your own customers.