# Get Business Units

Last updated: 2026-11-25

Retrieve the business units belonging to a tenancy, including their business settings and head-office address when present. Use this request when discovering the business units available to an integration. The tested response included archived business units, so filter on ` Archived ` when you only want active units.

 

## Request

 

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

 

Send ` Accept: application/json `. The Postman definition specifies no request body or query parameters.

 

## Authentication and scope

 

| Parameter | Location | Required | Description |
| --- | --- | --- | --- |
| tenancyApiKey | URL path | Yes | The API key for the tenancy you intend to read. The Postman collection distinguishes this from a business-unit key. |

 

Keep the key in an environment variable or secret store. Because it appears in the request path, redact URLs in application logs, proxies and monitoring tools. Do not embed a real key in shared documentation.

 

## Working examples

 

All three examples were verified against the production API on 25 November 2026. A sandbox has not been tested. For a sandbox, replace the hostname with the confirmed sandbox API hostname.

 

### cURL

 

```sh
# Set ZAHARA_TENANCY_API_KEY in your environment first.
curl --fail-with-body --silent --show-error --max-time 30 \
  --header 'Accept: application/json' \
  "https://api.myzahara.net/api/${ZAHARA_TENANCY_API_KEY:?Set your tenancy API key}/BusinessUnit/GetAll"
```

 

### JavaScript (Node.js 22+)

 

```javascript
// Node.js 22+. Set ZAHARA_TENANCY_API_KEY in your environment first.
const key = process.env.ZAHARA_TENANCY_API_KEY;
if (!key) throw new Error('Set ZAHARA_TENANCY_API_KEY');
const response = await fetch(
  'https://api.myzahara.net/api/' + encodeURIComponent(key) + '/BusinessUnit/GetAll',
  { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(30000), redirect: 'error' }
);
if (!response.ok) throw new Error('Zahara returned HTTP ' + response.status);
const businessUnits = await response.json();
// Inspect the response shape before mapping fields. It includes business settings.
console.log(JSON.stringify(businessUnits, null, 2)); // Use a secure development console only.
```

 

### Python 3 (standard library)

 

```python
# Python 3. Requires only the standard library.
import json
import os
from urllib.parse import quote
from urllib.request import Request, urlopen, build_opener, HTTPRedirectHandler
from urllib.error import HTTPError, URLError

class NoRedirect(HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None

key = os.environ.get('ZAHARA_TENANCY_API_KEY')
if not key:
    raise SystemExit('Set ZAHARA_TENANCY_API_KEY')
request = Request(
    'https://api.myzahara.net/api/' + quote(key, safe='') + '/BusinessUnit/GetAll',
    headers={'Accept': 'application/json'}
)
try:
    with build_opener(NoRedirect).open(request, timeout=30) as response:
        business_units = json.load(response)
except HTTPError as error:
    raise SystemExit('Zahara returned HTTP ' + str(error.code)) from None
except URLError:
    raise SystemExit('Could not reach Zahara') from None
# Contains business settings: inspect only in a secure development console.
print(json.dumps(business_units, indent=2))
```

 

## Successful response

 

The verified request returned HTTP 200 and a top-level JSON array, without a wrapper object. The response included archived business units with ` Archived: true `. Filter these out if your integration requires active units only.

 

The following is a **fictionalised, shortened example** showing the observed structure. The real ` Settings ` object contained 130 fields in the first unit and is deliberately abbreviated here. Never treat omitted settings as absent from the real response.

 

```json
[
  {
    "HeadOfficeAddress": {
      "AddressId": 101,
      "AddressLines": "1 Example Street",
      "Postcode": "EX1 1AA",
      "CountryCodeId": 1,
      "CountryCode": "GB",
      "AddressType": 0,
      "IsPrimary": true,
      "Void": false,
      "LastUpdated": "2026-01-01T12:00:00Z"
    },
    "Settings": {
      "SettingsId": 201,
      "ApiKey": "[REDACTED]",
      "SmtpPassword": "[REDACTED]"
    },
    "BusinessUnitId": 301,
    "TenancyId": 1,
    "Name": "Example Business Unit",
    "SettingsId": 201,
    "DateCreated": "2026-01-01T12:00:00Z",
    "Archived": false,
    "LastUpdated": "2026-01-02T12:00:00Z"
  }
]
```

 

### Top-level field reference

 

| Field | Observed JSON type | Meaning / integration use |
| --- | --- | --- |
| BusinessUnitId | number | Identifies the business unit. Preserve the exact casing when reading JSON. |
| TenancyId | number | Tenancy associated with the business unit. This is an ID, not an API key. |
| Name | string | Business-unit name for display and selection. |
| SettingsId | number | Identifier for the associated settings. |
| Settings | object | Business configuration. Includes credential fields such as ApiKey and SmtpPassword; never share an unreviewed payload. |
| HeadOfficeAddress | object or null | Head-office address. Null was observed: check before accessing nested properties. |
| DateCreated | string | Creation timestamp; observed in ISO 8601 UTC form, for example 2026-01-01T12:00:00Z. |
| Archived | boolean | Archive flag. True entries were included in the tested result. |
| LastUpdated | string | Last-update timestamp, observed in ISO 8601 UTC form. |

 

The address contained AddressId, AddressLines, Postcode, CountryCodeId, CountryCode, AddressType, IsPrimary, Void and LastUpdated. Postcode and CountryCodeId were nullable in the sampled response. Numeric enum meanings such as AddressType have not been verified.

 

These are observed types, not a formal API contract. Other tenants and configurations may expose additional fields or nulls. Empty-tenancy behaviour has not been tested. Inspect the actual response for your tenancy before relying on additional fields.

 

## Handling failures

 

Check the HTTP status before parsing JSON. Treat non-2xx responses as failures and preserve the status for troubleshooting. A deliberately nonexistent tenancy key returned **HTTP 404**, with this response (key redacted):

 

```json
{
  "ApiMessage": "Could not find tenancy with the API key '[REDACTED]'",
  "StatusCode": 404
}
```

 

Do not assume that every invalid credential returns 401. Other error conditions and statuses remain unverified.

 

If authentication fails, confirm that the key is a tenancy key for the selected environment. If the response is not JSON, check the environment and endpoint path. If the request times out, investigate availability before retrying. Do not automatically retry writes when expanding this pattern to other methods.

 

## Integration notes

 

- Business settings are returned, including credential-bearing fields. Review the response for confidential configuration and credentials before storing, displaying or sharing it.
- To show active units only, filter the returned array by Archived === false. Do not assume GetAll excludes archived entries.
- No pagination parameters appear in the supplied Postman definition. Maximum result size and pagination behaviour remain unverified.
- Rate limits, permissions, deleted business units, ordering and version guarantees remain unverified. Archived and deleted are different concepts; only archive behaviour was observed.

 

## Verification

 

The GET request, cURL, Node.js and Python examples, and nonexistent-key HTTP 404 behaviour were verified on 25 November 2026. Request details and key scope were checked against Zahara’s API collection.

 

The JSON example uses fictional values and abbreviated settings. Field types describe observed responses rather than a complete formal schema.

 

Sandbox behaviour, empty results, business-unit-key error behaviour, enum meanings, rate limits, comprehensive nullability and permission behaviour have not been verified.
