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

# Authentication

> How to authenticate with the Ochy Partner API using your API key.

Every request to the Partner API requires an API key passed as a query parameter.

## Passing your API key

Add `apiKey` as a query parameter on every request:

```
GET /analysis?apiKey=YOUR_API_KEY
POST /analysis/start?apiKey=YOUR_API_KEY
GET /subjects?apiKey=YOUR_API_KEY
```

<Warning>
  Do not expose your API key in client-side code. Always call the Ochy API from
  your backend server.
</Warning>

## Getting an API key

Contact sales through the [Ochy website](https://www.ochy.io) or from your account to request a partner account.
Once your organization is set up, generate an API key from the
[web dashboard](/guides/webhooks-and-api-keys#generate-a-key).

## Error responses

If authentication fails, the API returns one of these responses:

### Missing API key -- 401

Returned when the `apiKey` query parameter is absent.

```json theme={null}
{
  "detail": "API Key is missing"
}
```

### Invalid API key -- 403

Returned when the key does not match any active partner account.

```json theme={null}
{
  "detail": "Invalid API Key"
}
```

## Credits

Each analysis consumes one credit from your account balance. The credit is deducted
when the analysis starts, not when results are retrieved.

### Insufficient credits -- 402

Returned when your account has no remaining credits.

```json theme={null}
{
  "detail": "Insufficient credits to perform analysis",
  "code": "insufficient_credits"
}
```

To add credits, contact sales through the [Ochy website](https://www.ochy.io) or from your account.

## Security best practices

* Store your API key in environment variables or a secrets manager -- never hard-code it.
* [Rotate your key](/guides/webhooks-and-api-keys#rotate-a-key) periodically from the web dashboard.
* Monitor your credit usage to avoid unexpected exhaustion.
