Skip to documentation
Zahara DevelopersAPI documentation
DocumentationCustom Fields (Document)
Download .md
Custom Fields (Document)

Get Custom Fields by ID

Last updated

Retrieve one custom-field definition using its numeric Id.

Request

GET https://api.myzahara.net/api/{businessUnitApiKey}/CustomFieldType/Get/{customFieldId}

Send Accept: application/json.

No request body is required.

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_CUSTOM_FIELD_ID customFieldId. Use an integer reference or offset as appropriate.

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_CUSTOM_FIELD_ID="${ZAHARA_CUSTOM_FIELD_ID:?Set ZAHARA_CUSTOM_FIELD_ID}"
encoded_customFieldId="$(python3 -c 'import os; from urllib.parse import quote; print(quote(os.environ["ZAHARA_CUSTOM_FIELD_ID"], 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}/CustomFieldType/Get/${encoded_customFieldId}"

JavaScript (Node.js 22+)

// Node.js 22+. Standard library only.
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_CUSTOM_FIELD_ID=required('ZAHARA_CUSTOM_FIELD_ID');
let path="CustomFieldType/Get/{customFieldId}";
path=path.replace('{customFieldId}',encodeURIComponent(ZAHARA_CUSTOM_FIELD_ID));
const base='https://api.myzahara.net';
const url=new URL(base+'/api/'+encodeURIComponent(ZAHARA_BUSINESS_UNIT_API_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('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_CUSTOM_FIELD_ID=required('ZAHARA_CUSTOM_FIELD_ID')
path="CustomFieldType/Get/{customFieldId}"
path=path.replace('{customFieldId}',quote(ZAHARA_CUSTOM_FIELD_ID,safe=''))
base='https://api.myzahara.net'
url=base+'/api/'+quote(ZAHARA_BUSINESS_UNIT_API_KEY,safe='')+'/'+path
request=Request(url,method='GET',headers={'Accept':'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

Check the status before parsing JSON. Handle nullable results and arrays according to the returned body, and keep a missing record separate from an authentication or transport failure.

Response example

Fictional business data; array length is illustrative.

{
  "Id": 1001,
  "BusinessUnitId": 1002,
  "Label": "Example Label",
  "TemplateLabel": "Example TemplateLabel",
  "Description": null,
  "Location": 1,
  "IsFilterEnabled": false,
  "Category": 0,
  "IsRequired": true,
  "DisplayOrderPosition": 2,
  "CustomFieldTypeListItems": [
    {
      "Id": 1003,
      "CustomFieldTypeId": 1001,
      "Name": "Example Name",
      "ParentCustomFieldTypeId": null,
      "ParentListItemId": null,
      "IsDefault": false
    }
  ],
  "ListViewSettings": null,
  "Reports": null,
  "BusinessUnit": null,
  "CustomFieldValues": null,
  "CustomFieldGRNs": null,
  "Values": "Example Values",
  "ValuesList": [
    "Example ValuesList"
  ]
}

Field reference

Field Example JSON type Use
Id number Identifier of this record. Keep it separate from its label and any parent reference.
BusinessUnitId number Owning business-unit reference.
Label string Human-readable custom-field label.
TemplateLabel string Template-facing field label.
Description null Description text.
Location number Field location enum. Use the enum reference to interpret numeric values.
IsFilterEnabled boolean Filter configuration flag.
Category number Field category enum. Keep the numeric value separate from its display meaning.
IsRequired boolean Field requirement configuration flag.
DisplayOrderPosition number Configured display position.
CustomFieldTypeListItems array List choices belonging to the custom-field definition.
ListViewSettings null Value associated with this record.
Reports null Value associated with this record.
BusinessUnit null Value associated with this record.
CustomFieldValues null Document-level custom-field values linked through TypeId.
CustomFieldGRNs null Value associated with this record.
Values string Text representation of choices; prefer the structured list for identifiers.
ValuesList array Display-value list; distinct from numeric list-item identifiers.

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

  • These endpoints work with field definitions. Setting a definition is different from setting a field value on a document or line item.
  • Keep the definition identifier separate from list-item identifiers. Use the chosen field’s own list items when setting a choice.
  • Use Location and Category with the enum reference. Labels, template labels and display positions describe different settings.
  • Preserve parent-field and parent-choice references for dependent lists. Do not flatten a hierarchy into unrelated display strings.
  • 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.