# Check Whether a Nominal Code Exists

Last updated: 2026-11-26

Check whether a numeric NominalCodeId exists within the API key’s business unit.

 

## Request

 

` GET https://api.myzahara.net/api/{businessUnitApiKey}/NominalCode/Exists/{nominalCodeId} `

 

Send ` Accept: application/json `. No request body appears in the supplied definition.

 

Supply NominalCodeId rather than the display Code or Description.

 

## Authentication and scope

 

| Parameter | Location | Meaning |
| --- | --- | --- |
| businessUnitApiKey | URL path | API key for the owning business unit; not a tenancy key, numeric ID or user name. |
| nominalCodeId | URL path | Integer ≥ 1; use the owning business unit’s record reference. |

 

Store the key in an environment variable or secret store. Because it appears in the URL path, redact request URLs in logs, proxies and monitoring. Do not put real keys in source examples, shared screenshots or coding-agent prompts. Response codes and names may also be confidential.

 

## Working examples

 

The cURL, Node.js and Python programs were each executed successfully against the production API on 25 November 2026. Result shapes and item counts matched the direct request.

 

| Environment variable | Purpose |
| --- | --- |
| ZAHARA\_BUSINESS\_UNIT\_API\_KEY | Business-unit API key, kept private. |
| ZAHARA\_NOMINAL\_CODE\_ID | nominalCodeId. Use a valid integer in the documented context. |

 

### cURL

 

Requires cURL 7.76.0+ for ` --fail-with-body `. It prints the full result; use a secure development terminal.

 

```sh
# cURL 7.76.0+. Set the environment variables documented below.
# Treat response data as confidential. Keep keys out of logs.
set -e
curl --fail-with-body --silent --show-error --max-time 30 \
  --request GET \
  --header 'Accept: application/json' \
  "https://api.myzahara.net/api/${ZAHARA_BUSINESS_UNIT_API_KEY:?Set ZAHARA_BUSINESS_UNIT_API_KEY}/NominalCode/Exists/${ZAHARA_NOMINAL_CODE_ID:?Set ZAHARA_NOMINAL_CODE_ID}"
```

 

### JavaScript (Node.js 22+)

 

Uses built-in fetch, a 30-second timeout and an HTTP status check. No extra packages are required.

 

```javascript
// Node.js 22+. Standard library only.
function required(name) {
  const value = process.env[name];
  if (!value) throw new Error('Set ' + name);
  return value;
}
const key = required('ZAHARA_BUSINESS_UNIT_API_KEY');
const base = 'https://api.myzahara.net';
let path = "NominalCode/Exists/{nominalCodeId}";
const nominalCodeId = required('ZAHARA_NOMINAL_CODE_ID');
if (!/^\d+$/.test(nominalCodeId) || !Number.isSafeInteger(Number(nominalCodeId)) || Number(nominalCodeId) < 1) throw new Error('Invalid ZAHARA_NOMINAL_CODE_ID');
path = path.replace('{nominalCodeId}', encodeURIComponent(nominalCodeId));
const url = new URL(base + '/api/' + encodeURIComponent(key) + '/' + path);


let response;
try {
  response = await fetch(url, {
    method: 'GET', headers: { Accept: 'application/json' },
    signal: AbortSignal.timeout(30000), redirect: 'error'
  });
} catch { throw new Error('Zahara request failed or timed out; URL omitted to protect the key'); }
if (!response.ok) throw new Error('Zahara returned HTTP ' + response.status);
const text = await response.text();
// Some methods may return an empty successful body. Do not assume a JSON shape.
const result = text.trim() ? JSON.parse(text) : null;
// Use a secure console; response fields may include financial or business data.
console.log(JSON.stringify(result, null, 2));
```

 

### Python 3 (standard library)

 

Rejects redirects and reports HTTP/network errors without exposing the credential-bearing URL.

 

```python
# Python 3. Standard library only.
import json
import os
from urllib.parse import quote, urlencode
from urllib.request import Request, build_opener, HTTPRedirectHandler
from urllib.error import HTTPError, URLError

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

def required(name):
    value = os.environ.get(name)
    if not value:
        raise SystemExit('Set ' + name)
    return value

key = required('ZAHARA_BUSINESS_UNIT_API_KEY')
base = 'https://api.myzahara.net'
path = "NominalCode/Exists/{nominalCodeId}"
nominalCodeId = required('ZAHARA_NOMINAL_CODE_ID')
if not nominalCodeId.isascii() or not nominalCodeId.isdigit() or int(nominalCodeId) < 1:
    raise SystemExit('Invalid ZAHARA_NOMINAL_CODE_ID')
path = path.replace('{nominalCodeId}', quote(nominalCodeId, safe=''))
url = base + '/api/' + quote(key, safe='') + '/' + path


request = Request(url, method='GET',
    headers={'Accept': 'application/json'})
try:
    with build_opener(NoRedirect).open(request, timeout=30) as response:
        text = response.read().decode('utf-8')
except HTTPError as error:
    raise SystemExit('Zahara returned HTTP ' + str(error.code)) from None
except URLError:
    raise SystemExit('Zahara request failed; URL omitted to protect the key') from None
result = json.loads(text) if text.strip() else None
# Use a secure console: the result may contain confidential data.
print(json.dumps(result, indent=2))
```

 

## Successful response

 

An existing ID returned HTTP 200 with the JSON boolean true. A known-absent ID returned HTTP 200 with false. There is no observed object wrapper.

 

### Fictionalised response example

 

All identifiers, business labels and dates below are fictional. The example preserves an observed shape; array length is illustrative.

 

```json
true
```

 

### Response contract

 

The response is a top-level JSON boolean, not an object containing an exists field and not the text string "true" or "false". Compare the parsed value explicitly; a false result is different from a failed HTTP request.

 

## Handling failures

 

The invalid-key test returned **HTTP 401** with:

 

```json
{
  "ApiMessage": "The API key is missing or not recognised.",
  "StatusCode": 401
}
```

 

The known-absent ID test returned **HTTP 200** with:

 

```json
false
```

 

Check the HTTP status and then inspect the body before using it. Do not convert network failures into empty results. The supplied clients make one request and do not automatically retry it.

 

## Integration notes

 

- Compare the parsed JSON boolean explicitly. Do not convert a network or authentication failure to false.
- An existing record may still be inactive or void; existence alone does not establish suitability for a transaction.
- A subsequent read or write is a separate request. Existence checks do not lock the record or establish a transaction.
- Case/format rules, permissions beyond the tested context, rate limits, complete nullability and undocumented variants remain unverified.

 

## Verification

 

Verified on 25 November 2026 with an authorised business-unit key on the production API. cURL, JavaScript and Python each completed successfully. Invalid-key and documented empty/missing-result cases were exercised.
