Reject a document at its current workflow step.
Request
POST https://api.myzahara.net/api/Documents/{documentCurrentStepKey}/Reject
Send Accept: application/json.
No request body is required.
Authentication and scope
This endpoint uses the document’s current workflow-step key, not a tenancy or business-unit API key. Read CurrentStepKey from the document and use the key for the intended current step. A workflow change can invalidate an earlier step key.
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_DOCUMENT_STEP_KEY | Private current workflow-step key. |
| ZAHARA_API_BASE_URL | Selected API origin, without an /api path. |
cURL
# cURL 7.76.0+ and Python 3. Keep credentials and business data private.
set -e
export ZAHARA_DOCUMENT_STEP_KEY="${ZAHARA_DOCUMENT_STEP_KEY:?Set ZAHARA_DOCUMENT_STEP_KEY}"
export ZAHARA_API_BASE_URL="${ZAHARA_API_BASE_URL:?Set ZAHARA_API_BASE_URL}"
curl --fail-with-body --silent --show-error --max-time 30 \
--request POST --header 'Accept: application/json' \
"${ZAHARA_API_BASE_URL:?Set ZAHARA_API_BASE_URL}/api/Documents/${ZAHARA_DOCUMENT_STEP_KEY:?Set ZAHARA_DOCUMENT_STEP_KEY}/Reject"
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_DOCUMENT_STEP_KEY=required('ZAHARA_DOCUMENT_STEP_KEY');
const ZAHARA_API_BASE_URL=required('ZAHARA_API_BASE_URL');
let path="Reject";
const base=ZAHARA_API_BASE_URL.replace(/\/$/, '');
const url=new URL(base+'/api/'+'Documents/'+encodeURIComponent(ZAHARA_DOCUMENT_STEP_KEY)+'/'+path);
let response;
try { response=await fetch(url,{method:'POST',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_DOCUMENT_STEP_KEY=required('ZAHARA_DOCUMENT_STEP_KEY')
ZAHARA_API_BASE_URL=required('ZAHARA_API_BASE_URL')
path="Reject"
base=ZAHARA_API_BASE_URL.rstrip('/')
url=base+'/api/'+'Documents/'+quote(ZAHARA_DOCUMENT_STEP_KEY,safe='')+'/'+path
request=Request(url,method='POST',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 HTTP status before using the result. Parse a JSON body when present, and handle an empty successful body separately. Retrieve the relevant record afterwards to confirm the intended change.
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
- Approval, rejection and process logging act on a current workflow step. Confirm the document and step before sending the request.
- After a timeout or uncertain outcome, reconcile current state before retrying. A failed HTTP request is not proof that no change occurred.
- Use numeric identifiers where an identifier is requested. Preserve formatting and leading zeros in displayed document numbers and business codes.