Retrieve one user within a tenancy.
Request
GET https://api.myzahara.net/api/{tenancyApiKey}/User/Get/{userId}
Send Accept: application/json.
No request body is required.
Authentication and scope
Use the tenancy API key. A business-unit key has a different scope.
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_TENANCY_API_KEY | Private tenancy API key. |
| ZAHARA_USER_ID | userId. 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_TENANCY_API_KEY="${ZAHARA_TENANCY_API_KEY:?Set ZAHARA_TENANCY_API_KEY}"
export ZAHARA_USER_ID="${ZAHARA_USER_ID:?Set ZAHARA_USER_ID}"
encoded_userId="$(python3 -c 'import os; from urllib.parse import quote; print(quote(os.environ["ZAHARA_USER_ID"], safe=""))')"
curl --fail-with-body --silent --show-error --max-time 30 \
--request GET --header 'Accept: application/json' \
"https://api.myzahara.net/api/${ZAHARA_TENANCY_API_KEY:?Set ZAHARA_TENANCY_API_KEY}/User/Get/${encoded_userId}"
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_TENANCY_API_KEY=required('ZAHARA_TENANCY_API_KEY');
const ZAHARA_USER_ID=required('ZAHARA_USER_ID');
let path="User/Get/{userId}";
path=path.replace('{userId}',encodeURIComponent(ZAHARA_USER_ID));
const base='https://api.myzahara.net';
const url=new URL(base+'/api/'+encodeURIComponent(ZAHARA_TENANCY_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_TENANCY_API_KEY=required('ZAHARA_TENANCY_API_KEY')
ZAHARA_USER_ID=required('ZAHARA_USER_ID')
path="User/Get/{userId}"
path=path.replace('{userId}',quote(ZAHARA_USER_ID,safe=''))
base='https://api.myzahara.net'
url=base+'/api/'+quote(ZAHARA_TENANCY_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.
{
"UserId": 1001,
"UserName": "Example UserName",
"ActiveDirectoryUser": null,
"FirstName": "Example FirstName",
"LastName": "Example LastName",
"Email": "example@example.com",
"JobTitle": "Example JobTitle",
"LastUpdated": "2026-01-15T10:30:00Z"
}
Field reference
| Field | Example JSON type | Use |
|---|---|---|
| UserId | number | Numeric user reference. |
| UserName | string | User account name; may contain personal data. |
| ActiveDirectoryUser | null | Value associated with this record. |
| FirstName | string | Value associated with this record. |
| LastName | string | Value associated with this record. |
| string | Email address; treat it as personal/business data. | |
| JobTitle | string | Value associated with this record. |
| LastUpdated | string | Record update timestamp. |
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
- Keep UserId separate from account names and email addresses. Apply the key scope shown on this page and minimise stored personal data.
- Use numeric identifiers where an identifier is requested. Preserve formatting and leading zeros in displayed document numbers and business codes.