# Authentication & API keys

Zahara uses API keys to identify the tenancy or business unit an API request acts on. The correct key depends on the method.

## Choose the right scope

| Key | Scope | Example |
| --- | --- | --- |
| Tenancy API key | Tenancy-level methods | Discover business units with BusinessUnit/GetAll. |
| Business-unit API key | Methods for an individual business | Use the key scope specified by the resource's reference article. |

A numeric tenancy ID or business-unit ID is not an API key. Do not substitute an ID into the key position in a request.

## Request URL

The first-request example supplies the tenancy key in the URL path:

```text
https://api.myzahara.net/api/{tenancyApiKey}/BusinessUnit/GetAll
```

Use the authentication format documented for each method. Do not assume a Bearer header or that one key works for every scope.

## Obtain and manage a key

API keys are managed inside Zahara. Ask your Zahara administrator for the appropriate key and follow your organisation's credential policy. Check existing integrations before regenerating a key: a replacement can affect clients that use it.

## Keep credentials private

- Store keys in environment variables or a secret store.
- Call the API from a trusted server or development environment.
- Redact keys from request paths in logs, proxies and error reporting.
- Do not embed keys in browser applications, public repositories or examples sent to an agent.
- Review returned business settings before sharing a response; settings can themselves contain credentials.

## Troubleshoot access

Confirm that the key belongs to the intended environment and has the scope the method expects. For Get Business Units, a nonexistent tenancy key can return HTTP 404. Other methods may behave differently: use their documentation and the actual response rather than assuming a global error contract.

[Make your first request](https://help.zaharasoftware.com/api-docs/guides/first-request.md).
