# Authentication (/docs/api/authentication)



Every request to the Tawa API is authenticated with an **API key**, passed
as a bearer token or the `x-api-key` header:

```bash
curl -X POST "https://gateway.tawaguard.com/v1/scan" \
  -H "Authorization: Bearer $TAWA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "…"}'
```

<Callout type="warn">
  Keys are secret. Don't embed them in client-side code, mobile apps, or
  public repositories.
</Callout>

## Verify a key [#verify-a-key]

`POST /v1/verify` checks a key and returns its metadata:

```bash
curl -X POST "https://gateway.tawaguard.com/v1/verify" \
  -H "Authorization: Bearer $TAWA_API_KEY"
```

```json
{
  "valid": true,
  "key": { "id": "…", "name": "Production key", "enabled": true, "requestCount": 42 }
}
```

## Managing keys [#managing-keys]

Create and revoke API keys from the [dashboard](https://tawaguard.com) under
**Settings → API keys**.

## Errors [#errors]

A missing or invalid key returns `401`:

```json
{ "error": "Invalid API key", "code": "INVALID_API_KEY" }
```

<Callout type="info">
  Building with an official SDK? [TypeScript](/docs/typescript/guides/authentication)
  and [Python](/docs/python/guides/authentication) both call `/verify`
  automatically on client construction, so a bad key surfaces immediately
  rather than on the first scan call — see those pages for the SDK-specific
  behavior.
</Callout>
