Skip to documentation
Zahara DevelopersAPI documentation
DocumentationDivisions
Download .md
Divisions

Get Division by Property Value

Last updated

Look up divisions by their Name using a JSON string body.

Request

POST https://api.myzahara.net/api/{businessUnitApiKey}/BusinessDivision/GetBy/Name

Send Accept: application/json and Content-Type: application/json.

Send the body as JSON. Keep strings quoted, and retain the object, array or scalar shape shown below. This POST is a lookup; do not wrap its scalar body in an object.

Request body example

Replace the fictional identifiers and values with those for your business.

"Example value"

Request fields

The body is a quoted JSON string. Retain that shape.

Authentication and scope

Use the API key for the business unit that owns these records. A tenancy key, business-unit ID and resource ID are different values.

Keep credentials in environment variables or a secret store. They appear in the URL path: redact URLs in logs, monitoring and errors. Do not share real keys, workflow tokens or customer responses with a coding agent.

Working examples

Set the environment variables below, then run one example. Node.js requires version 22+; Python uses its standard library. cURL requires 7.76.0+ and Python 3 for path/query encoding. The clients use a 30-second timeout and do not automatically retry.

Environment variable Purpose
ZAHARA_BUSINESS_UNIT_API_KEY Private business-unit API key.
ZAHARA_REQUEST_FILE File containing the JSON request body.

cURL

# cURL 7.76.0+ and Python 3. Keep credentials and business data private.
set -e
export ZAHARA_BUSINESS_UNIT_API_KEY="${ZAHARA_BUSINESS_UNIT_API_KEY:?Set ZAHARA_BUSINESS_UNIT_API_KEY}"
export ZAHARA_REQUEST_FILE="${ZAHARA_REQUEST_FILE:?Set ZAHARA_REQUEST_FILE}"


curl --fail-with-body --silent --show-error --max-time 30 \
  --request POST --header 'Accept: application/json' --header 'Content-Type: application/json' --data-binary "@${ZAHARA_REQUEST_FILE}" \
  "https://api.myzahara.net/api/${ZAHARA_BUSINESS_UNIT_API_KEY:?Set ZAHARA_BUSINESS_UNIT_API_KEY}/BusinessDivision/GetBy/Name"

JavaScript (Node.js 22+)

// Node.js 22+. Standard library only.
import { readFileSync } from 'node:fs';
function required(name, fallback) { const value=process.env[name] || fallback; if(!value) throw new Error('Set '+name); return value; }
const ZAHARA_BUSINESS_UNIT_API_KEY=required('ZAHARA_BUSINESS_UNIT_API_KEY');
const ZAHARA_REQUEST_FILE=required('ZAHARA_REQUEST_FILE');
let path="BusinessDivision/GetBy/Name";

const base='https://api.myzahara.net';
const url=new URL(base+'/api/'+encodeURIComponent(ZAHARA_BUSINESS_UNIT_API_KEY)+'/'+path);

const body=JSON.stringify(JSON.parse(readFileSync(ZAHARA_REQUEST_FILE,'utf8')));
let response;
try { response=await fetch(url,{method:'POST',headers:{Accept:'application/json','Content-Type':'application/json'},body,signal:AbortSignal.timeout(30000),redirect:'error'}); }
catch { throw new Error('Request failed or timed out; URL omitted to protect credentials'); }
if(!response.ok) throw new Error('Zahara returned HTTP '+response.status);
const text=await response.text();
const result=text.trim()?JSON.parse(text):null;
console.log(JSON.stringify(result,null,2));

Python 3

# Python 3, standard library.
import os,json
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,fallback=None):
    value=os.environ.get(name) or fallback
    if not value: raise SystemExit('Set '+name)
    return value
ZAHARA_BUSINESS_UNIT_API_KEY=required('ZAHARA_BUSINESS_UNIT_API_KEY')
ZAHARA_REQUEST_FILE=required('ZAHARA_REQUEST_FILE')
path="BusinessDivision/GetBy/Name"

base='https://api.myzahara.net'
url=base+'/api/'+quote(ZAHARA_BUSINESS_UNIT_API_KEY,safe='')+'/'+path
with open(ZAHARA_REQUEST_FILE,encoding='utf-8') as file: body=json.dumps(json.load(file)).encode('utf-8')
request=Request(url,data=body,method='POST',headers={'Accept':'application/json','Content-Type':'application/json'})
try:
    with build_opener(NoRedirect).open(request,timeout=30) as response:
        data=response.read()
except HTTPError as error: raise SystemExit('Zahara returned HTTP '+str(error.code)) from None
except URLError: raise SystemExit('Request failed; URL omitted to protect credentials') from None
text=data.decode('utf-8')
result=json.loads(text) if text.strip() else None
print(json.dumps(result,indent=2))

Successful response

Parse the top-level JSON array and iterate its records. An empty array is a valid empty result, not a network failure.

Response example

Fictional business data; array length is illustrative.

[
  {
    "BusinessDivisionId": 1001,
    "BusinessUnitId": 1002,
    "BudgetId": 1003,
    "BusinessBudgetId": 1003,
    "Name": "Example Name",
    "ContactTelephone": null,
    "ContactEmail": null,
    "VatReg": null,
    "CountryCodeId": 1004,
    "CountryCode": "gb",
    "Description": "Example Description",
    "Archived": false,
    "LastUpdated": "2026-01-15T10:30:00Z",
    "DateCreated": "2026-01-15T10:30:00Z",
    "IconId": 1005,
    "AvailableNominalCodes": null,
    "RestrictNominalCodes": null,
    "DepartmentId": null,
    "Address": {
      "AddressId": 1006,
      "AddressLines": "Example AddressLines",
      "Postcode": "",
      "CountryCodeId": 1004,
      "CountryCode": "gb",
      "AddressType": 1,
      "IsPrimary": false,
      "Void": false,
      "LastUpdated": "2026-01-15T10:30:00Z"
    },
    "DivisionSettings": [
      {
        "SettingsId": 1001,
        "DefaultCostCodeId": null,
        "DefaultPurchaseOrderProcessId": null,
        "DefaultInvoiceProcessId": null,
        "DefaultDeliveryNoteProcessId": null,
        "PurchaseOrderNumberPrefix": null,
        "DivisionHeadId": null,
        "Sage200DepartmentId": null
      }
    ]
  }
]

Field reference

Field Example JSON type Use
BusinessDivisionId number Numeric division reference.
BusinessUnitId number Owning business-unit reference.
BudgetId number Budget reference; distinct from display codes.
BusinessBudgetId number Numeric or external reference; use the appropriate resource context.
Name string Display name.
ContactTelephone null Value associated with this record.
ContactEmail null Value associated with this record.
VatReg null Value associated with this record.
CountryCodeId number Numeric or external reference; use the appropriate resource context.
CountryCode string Country short code.
Description string Description text.
Archived boolean Value associated with this record.
LastUpdated string Record update timestamp.
DateCreated string Record creation timestamp.
IconId number Numeric or external reference; use the appropriate resource context.
AvailableNominalCodes null Value associated with this record.
RestrictNominalCodes null Value associated with this record.
DepartmentId null Numeric or external reference; use the appropriate resource context.
Address object Address object; preserve nullable fields.
DivisionSettings array Division settings array.

Handling failures

Check the HTTP status before parsing or saving the body as a business result. Handle authentication failures, missing records, invalid references, timeouts and unexpected formats separately. Do not turn a failed request into [], null, false or a zero count. Redact credential-bearing URLs and avoid logging personal or financial data.

Integration notes

  • Use numeric identifiers where an identifier is requested. Preserve formatting and leading zeros in displayed document numbers and business codes.

Enum reference · API overview

.md
Take this page to your coding agent.

Copy a clean Markdown URL that follows the published article.