Skip to documentation
Zahara DevelopersAPI documentation
DocumentationNominal Codes
Download .md
Nominal Codes

Search for a Nominal Code

Last updated

Search nominal-code records within one business unit using text in the path.

Request

GET https://api.myzahara.net/api/{businessUnitApiKey}/NominalCode/Search/{search}

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

Set ZAHARA_SEARCH_TEXT to raw search text. All samples percent-encode it as a single segment; cURL requires Python 3 for that step.

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.
search URL path Raw search text, encoded as one segment.

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_SEARCH_TEXT search. Raw text; clients percent-encode the path segment.

cURL

Requires cURL 7.76.0+ for --fail-with-body and Python 3 for path encoding. It prints the full result; use a secure development terminal.

# cURL 7.76.0+. Set the environment variables documented below.
# Treat response data as confidential. Keep keys out of logs.
set -e
# Python 3 safely percent-encodes the text path segment.
encoded_search="$(python3 -c 'import os; from urllib.parse import quote; print(quote(os.environ["ZAHARA_SEARCH_TEXT"], safe=""))')"
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/Search/${encoded_search}"

JavaScript (Node.js 22+)

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

// 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/Search/{search}";
const search = required('ZAHARA_SEARCH_TEXT');

path = path.replace('{search}', encodeURIComponent(search));
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 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/Search/{search}"
search = required('ZAHARA_SEARCH_TEXT')

path = path.replace('{search}', quote(search, 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

A matching description search returned HTTP 200 with a top-level array. A deliberately unmatched term returned HTTP 200 with []. There was no observed result-count wrapper.

Fictionalised response example

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

[
  {
    "Id": 1001,
    "SyncFriendlyName": "Example SyncFriendlyName",
    "NominalCodeId": 1001,
    "BusinessUnitId": 100,
    "Code": "EXAMPLE-001",
    "Description": "Example nominal description",
    "SyncId": "Example SyncId",
    "SyncDate": "2026-01-15T10:30:00Z",
    "SyncType": 1001,
    "LastUpdated": "2026-01-15T10:30:00Z",
    "DateCreated": "2026-01-15T10:30:00Z",
    "IsActive": true,
    "IsStartingDefaultCode": false,
    "Void": false,
    "BusinessUnit": null,
    "Suppliers": [],
    "LineItems": []
  }
]

Field reference

Field Observed JSON type Meaning / integration use
Id number Additional identifier returned by the API. Use the resource-specific ID for documented path parameters.
SyncFriendlyName string Synchronisation-facing label.
NominalCodeId number Numeric nominal-code identifier.
BusinessUnitId number Business-unit identifier, not its API key.
Code string Display/accounting code; not the numeric record ID.
Description string Record description. Preserve any nulls reported by the API.
SyncId string or null Synchronisation reference; preserve strings and nulls.
SyncDate string or null Synchronisation date metadata; preserve nulls and verify formats before parsing.
SyncType number or null Synchronisation type code; enum meanings remain unverified.
LastUpdated string Observed UTC date-time string.
DateCreated string Observed UTC date-time string.
IsActive boolean Activity flag. Do not assume every returned record is active.
IsStartingDefaultCode boolean Starting/default-code configuration flag.
Void boolean Void flag; inclusion and reversal semantics are not established by a normal lookup.
BusinessUnit null Null in the observed records; populated relationship shape is unverified.
Suppliers array Relationship array; non-empty element shapes were not established.
LineItems array Relationship array; non-empty element shapes were not established.

These types combine the observed complete nominal-code list with the tested lookup. They do not establish requiredness, every possible null, populated relationship shapes or a complete formal schema.

Handling failures

The invalid-key test returned HTTP 401 with:

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

The no-match value test returned HTTP 200 with:

[]

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

  • Use the resource-specific numeric identifier from the returned record, rather than its Code or position in a list.
  • Case sensitivity, whitespace normalisation, ordering, permissions beyond the tested key and maximum result counts remain unverified.
  • A known description was tested. Searching additional fields, substring/prefix matching and tokenisation remain unverified.
  • Use NominalCodeId from the selected result when making identifier-based requests. A description can be shared by multiple records.
  • 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.

.md
Take this page to your coding agent.

Copy a clean Markdown URL that follows the published article.