# Get Tax Codes by Property Value

Last updated: 2026-11-25

Look up tax-code records by a property value. The verified request uses the TaxPercentage property and a numeric JSON body over POST.

 

## Request

 

` POST https://api.myzahara.net/api/{businessUnitApiKey}/TaxCode/GetBy/TaxPercentage `

 

Send ` Accept: application/json ` and ` Content-Type: application/json `. The request has a JSON body.

 

Send a JSON number such as 20, as shown by the supplied definition. Do not send {"TaxPercentage":20} or assume a quoted string is equivalent. The samples read the number from ZAHARA\_REQUEST\_FILE.

 

### Request body example

 

Representative value; replace it with the property value you intend to look up.

 

```json
20
```

 

## 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. |

 

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\_REQUEST\_FILE | File containing a JSON number. |

 

### 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 POST \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-binary "@${ZAHARA_REQUEST_FILE:?Set ZAHARA_REQUEST_FILE}" \
  "https://api.myzahara.net/api/${ZAHARA_BUSINESS_UNIT_API_KEY:?Set ZAHARA_BUSINESS_UNIT_API_KEY}/TaxCode/GetBy/TaxPercentage"
```

 

### 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.
import { readFileSync } from 'node:fs';
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 = "TaxCode/GetBy/TaxPercentage";

const url = new URL(base + '/api/' + encodeURIComponent(key) + '/' + path);

const payload = JSON.parse(readFileSync(required('ZAHARA_REQUEST_FILE'), 'utf8'));
let response;
try {
  response = await fetch(url, {
    method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify(payload),
    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 = "TaxCode/GetBy/TaxPercentage"

url = base + '/api/' + quote(key, safe='') + '/' + path

with open(required('ZAHARA_REQUEST_FILE'), encoding='utf-8') as file:
    payload = json.load(file)
data = json.dumps(payload).encode('utf-8')
request = Request(url, data=data, method='POST',
    headers={'Accept': 'application/json', 'Content-Type': '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

 

The matching test returned HTTP 200 with a JSON array of 12 records sharing the supplied percentage. A deliberately absent percentage returned HTTP 200 and \[\]. Do not take the first matching rate as the uniquely correct tax code.

 

### Fictionalised response example

 

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

 

```json
[
  {
    "Id": 1001,
    "SyncFriendlyName": "Example SyncFriendlyName",
    "TaxCodeId": 1001,
    "BusinessUnitId": 101,
    "Code": "EXAMPLE-001",
    "CodeName": "Example CodeName",
    "TaxPercentage": 20,
    "SyncId": "Example SyncId",
    "SyncDate": "2026-01-01T12:00:00Z",
    "SyncType": 1,
    "IsDefault": false,
    "IsActive": true,
    "TaxAgencyId": "Example TaxAgencyId",
    "SageReverseChargeDetailId": null,
    "LastUpdated": "2026-01-01T12:00:00Z",
    "DateCreated": "2026-01-01T12:00:00Z",
    "Void": false,
    "IsStartingDefaultCode": 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. |
| TaxCodeId | number | Numeric tax-code identifier. |
| BusinessUnitId | number | Business-unit identifier, not its API key. |
| Code | string | Display/accounting code; not the numeric record ID. |
| CodeName | string | Tax-code display name. |
| TaxPercentage | number | Numeric configured percentage. This is not a unique record identifier. |
| SyncId | null or string | Synchronisation reference; preserve strings and nulls. |
| SyncDate | null or string | Synchronisation date metadata; preserve nulls and verify formats before parsing. |
| SyncType | null or number | Synchronisation type code; enum meanings remain unverified. |
| IsDefault | boolean | Default-code configuration flag; automatic selection behaviour is unverified. |
| IsActive | boolean | Activity flag. Do not assume every returned record is active. |
| TaxAgencyId | null or string | External agency reference. Strings were observed; do not coerce it to an integer. |
| SageReverseChargeDetailId | null | Integration-specific reference; its populated form was not observed. |
| LastUpdated | string | Observed UTC date-time string. |
| DateCreated | string | Observed UTC date-time string. |
| Void | boolean | Void flag; inclusion and reversal semantics are not established by a normal lookup. |
| IsStartingDefaultCode | boolean | Starting/default-code configuration flag. |
| 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 tax-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:

 

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

 

The no-match value test returned **HTTP 200** with:

 

```json
[]
```

 

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

 

- TaxPercentage was tested. The original article also lists Code, but its alternate property route and string body were not executed in this batch.
- The supplied example represents a percentage of 20 with the number 20; do not silently convert input to a fraction or infer rounding rules.
- Preserve the full result set and choose a code using verified integration requirements, identifiers and flags.
- The tax-code list was unchanged after the lookup tests. Property allowlists, comparison precision, case handling and permissions remain unverified.
- 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.
