> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenetlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authenticate Judge API calls with an API key from platform.tenetlabs.com, or with M2M credentials issued by Tenet.

Every request to `judge.tenetlabs.com` carries an `Authorization: Bearer` header. The bearer is either an API key (`sk_tenet_…`) or a token minted from M2M credentials.

| | API key | M2M credentials |
| - | - | - |
| Get it | Sign up at [platform.tenetlabs.com](https://platform.tenetlabs.com) | Issued by Tenet for enterprise accounts |
| Env vars | `TENET_API_KEY` | `TENET_CLIENT_ID` + `TENET_CLIENT_SECRET` |
| Bearer | The key | A short-lived JWT from `auth.tenetlabs.com` |
| Endpoints | `POST /decide`, `POST /decide/stream` | Every authenticated endpoint, including `GET /v1/config` and `GET /ready` |

Use an API key unless Tenet issued you M2M credentials.

## Get an API key

**1. Sign up**

Go to [platform.tenetlabs.com](https://platform.tenetlabs.com) and continue with Google or GitHub.

**2. Copy the key**

On the dashboard, select **View key**. That creates your first key, named `default`, and shows it once. Copy it then; if you lose it, revoke it on **API Keys** and create a new one.

**3. Add keys as you need them**

On **API Keys**, create one key per workload (e.g. `prod-agent`) and revoke keys you no longer use. Revoked keys stop working within seconds.

Sign-up requires a person. If an agent is doing the integration, create the key yourself and give it to the agent through an environment variable or secrets manager.

## SDK setup

```bash theme={null}
# Keep it in an env var or secrets manager, never in source control.
export TENET_API_KEY="sk_tenet_..."

# Or, with M2M credentials (instead of the key, not alongside it):
# export TENET_CLIENT_ID="<your-client-id>"
# export TENET_CLIENT_SECRET="<your-client-secret>"
```

```python theme={null}
from tenet_client import TenetCloudJudgeClient

judge = TenetCloudJudgeClient.from_env()
judge.warmup()  # with M2M credentials, mints the token before the first call
```

`from_env()` uses whichever credentials are set. It raises `ValueError` if both `TENET_API_KEY` and the M2M pair are set.

> [!TIP]
>
> Call `warmup()` (or `await warmup_async()`) at process start. With M2M credentials it mints the token up front, so the first tool call doesn't wait on a token mint. With an API key it does nothing.

A rejected key or a failed token mint raises `JudgeUnavailableError`, the same as a network failure. Your [policy](https://docs.tenetlabs.com/guides/policies.md) decides what happens next.

## Raw HTTP

### With an API key

Send the key as the bearer:

```bash theme={null}
curl -s https://judge.tenetlabs.com/decide \
  -H "Authorization: Bearer $TENET_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"surface": "job_ad_drafting", "messages": [{"role": "user", "content": "rewrite this job ad for a weekend barista"}], "context": {"recruiter_prompt": "rewrite this job ad for a weekend barista"}}'
```

`surface` names the kind of recruiting action being checked — here a job-ad edit, hence `job_ad_drafting`. Pick it per request, not per application: [Surfaces](https://docs.tenetlabs.com/concepts/surfaces.md).

An unknown or revoked key returns `401` with `code: "INVALID_API_KEY"`.

API keys work on `POST /decide`, `POST /decide/stream` and `POST /voice/decide/stream`. `GET /v1/config` and `GET /ready` require an M2M token.

### With M2M credentials

Mint a token with the `client_credentials` grant:

```bash theme={null}
TOKEN=$(curl -s https://auth.tenetlabs.com/oauth/token \
  -H 'Content-Type: application/json' \
  -d '{
    "grant_type": "client_credentials",
    "client_id": "'$TENET_CLIENT_ID'",
    "client_secret": "'$TENET_CLIENT_SECRET'",
    "audience": "https://sdk.tenetlabs.com"
  }' | jq -r .access_token)
```

Send it as the bearer: the same request as above, with `-H "Authorization: Bearer $TOKEN"`.

Cache the token until expiry and reuse it — don't mint per request. A missing or invalid token returns `401`.

## Environment variables

| Variable | Required | Default | Purpose |
| - | - | - | - |
| `TENET_API_KEY` | Key or M2M pair | — | API key from [platform.tenetlabs.com](https://platform.tenetlabs.com). |
| `TENET_CLIENT_ID` | Key or M2M pair | — | M2M client ID, issued by Tenet |
| `TENET_CLIENT_SECRET` | Key or M2M pair | — | M2M client secret, issued by Tenet |
| `TENET_JUDGE_ID` | No | `hr-1` | `hr-1` (EEO/HR) — the only judge served today; other ids raise `JudgeUnavailableError` |
| `TENET_SURFACE` | No | `resume_triage` | Client-default [surface](https://docs.tenetlabs.com/concepts/surfaces.md) — applied only when a call doesn't pass `surface=`. Suits single-purpose screening integrations; multi-action products set the surface per request instead |
| `TENET_WORKFLOW` | No | — | Client-default [workflow](https://docs.tenetlabs.com/sdk/tenet-client.md#evaluation-parameters) label naming the calling integration (e.g. `resume-screener`), applied when a call doesn't pass `workflow=`. Lowercase slug, ≤64 chars; trace-only, never affects the verdict |
| `TENET_JUDGE_TIMEOUT_SECONDS` | No | `3.0` | Per-call HTTP timeout |
| `TENET_USE_STREAM` | No | `false` | Verdict-first SSE on async paths |

## Links

* [Quickstart](https://docs.tenetlabs.com/quickstart.md)
* [API Reference](https://docs.tenetlabs.com/api-reference/introduction.md)
* [Policies — handling `JudgeUnavailableError`](https://docs.tenetlabs.com/guides/policies)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.