# Get all Purchase Orders

Last updated: 2026-11-26

Retrieve purchase orders belonging to the selected business unit.

 

## Request

 

` GET https://api.myzahara.net/api/{businessUnitApiKey}/PurchaseOrder/GetAll `

 

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

 

### cURL

 

```sh
# 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}"


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}/PurchaseOrder/GetAll"
```

 

### JavaScript (Node.js 22+)

 

```javascript
// 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');
let path="PurchaseOrder/GetAll";

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
# 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')
path="PurchaseOrder/GetAll"

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.

 

```json
{
  "Address": {
    "AddressId": 1001,
    "AddressLines": "Example AddressLines",
    "Postcode": "",
    "CountryCodeId": 1002,
    "CountryCode": "gb",
    "AddressType": 0,
    "IsPrimary": false,
    "Void": false,
    "LastUpdated": "2026-01-15T10:30:00Z"
  },
  "RequisitorId": 1003,
  "PurchaseOrderNumber": "EXAMPLE-001",
  "TotalNetValue": 100,
  "TotalGrossValue": 120,
  "RequiredDate": "2026-01-15T10:30:00Z",
  "SupplierComment": null,
  "DocumentId": 1004,
  "BusinessDivisionId": 1005,
  "CreatedBy": 1,
  "SupplierId": 1006,
  "Description": null,
  "DateCreated": "2026-01-15T10:30:00Z",
  "ImageLocation": null,
  "Type": 1,
  "Status": 5,
  "Comments": null,
  "LastUpdated": "2026-01-15T10:30:00Z",
  "Void": false,
  "LineItemMatchType": 3,
  "ExternalRef": null,
  "ProcessId": 1007,
  "ProcessStatus": 4,
  "CurrentStepIndex": 3,
  "DoxStoreId": null,
  "SecondaryOrderRef": null,
  "LineItems": [
    {
      "LineItemId": 1008,
      "DocumentId": 1004,
      "ProjectId": 1009,
      "CostCodeId": 1010,
      "OrderNumber": "EXAMPLE-001",
      "Quantity": 1,
      "Unit": null,
      "Price": 100,
      "Description": "Example Description",
      "NominalCodeId": 1011,
      "NominalCode": "EXAMPLE-001",
      "TaxCodeId": 1012,
      "TaxCode": "EXAMPLE-001",
      "TaxPercentage": 20,
      "TaxValue": 20,
      "NetValue": 100,
      "QuantityReceived": 1,
      "LastUpdated": "2026-01-15T10:30:00Z",
      "ProductCode": "EXAMPLE-001",
      "DiscountPercentage": 0,
      "MatchType": 3,
      "DivisionId": 1005,
      "ProjectItemCodeId": null,
      "RequiredDate": "2026-01-15T10:30:00Z",
      "CustomCodingFieldValues": [
        {
          "LineItemId": 1008,
          "CustomCodingFieldValueId": 1013,
          "CustomCodingFieldTypeId": 1014,
          "Value": "Example Value"
        }
      ]
    }
  ],
  "CustomFields": [
    {
      "DocumentId": 1004,
      "Document": {
        "TotalTaxValue": 20,
        "IsFullyReceived": true,
        "IsReceivedInExcess": false,
        "IsNotFullyReceived": false,
        "IsNotReceivedAtAll": false,
        "IsMatched": false,
        "IsPartialyMatched": true,
        "IsMismatched": false,
        "IsNotMatched": false,
        "ReportStatus": "Example ReportStatus",
        "DaysDue": 0,
        "GrnStatus": "Example GrnStatus",
        "DivisionWorkflowDictionary": null,
        "RequisitorId": 1003,
        "PurchaseOrderNumber": "EXAMPLE-001",
        "RequiredDate": "2026-01-15T10:30:00Z",
        "TotalNetValue": 100,
        "TotalGrossValue": 120,
        "DoxStoreQuoteId": null,
        "SupplierComment": null,
        "SentToSupplier": true,
        "EverSentToSupplier": true,
        "IsRetrospective": false,
        "ApplyToBudgetFromInvoice": true,
        "AcceptedBySupplier": null,
        "GeneratedFromPr": false,
        "SupplierEmailId": 1015,
        "SendToSupplierFailed": false,
        "BasePurchaseOrderNumber": "EXAMPLE-001",
        "SecondaryOrderRef": null,
        "SentToSupplierDate": "2026-01-15T10:30:00Z",
        "Requisitor": null,
        "GRNs": [],
        "SupplierEmail": null,
        "LineItemMatchType": 3,
        "FullyReceived": true,
        "IsDraft": false,
        "IsApproved": true,
        "ApplicableBudgets": [],
        "IsRejected": false,
        "SyncFriendlyName": "Example SyncFriendlyName",
        "ViewModeOnly": false,
        "PaymentInProgress": false,
        "DocumentNumber": "EXAMPLE-001",
        "DocumentNumberForFilePath": "EXAMPLE-001",
        "IsViewedBySupplierPortal": false,
        "Id": 1004,
        "DocumentId": 1004,
        "BusinessDivisionId": 1005,
        "ProcessId": 1007,
        "ProcessStatus": 4,
        "ProcessRevisionNumber": 1,
        "CurrentStepIndex": 3,
        "CreatedBy": 1,
        "ExternalRef": null,
        "SupplierId": 1006,
        "CurrencyId": 1016,
        "Description": null,
        "LastUpdated": "2026-01-15T10:30:00Z",
        "DateCreated": "2026-01-15T10:30:00Z",
        "ImageLocation": null,
        "Status": 5,
        "Comments": null,
        "MatchType": null,
        "Void": false,
        "DoxStoreId": null,
        "Exported": false,
        "CurrentExportStatus": 0,
        "CurrentExportType": 0,
        "ExportedTo": 0,
        "ExportedDate": null,
        "CurrentExportMessage": "Example CurrentExportMessage",
        "SyncId": null,
        "SyncDate": null,
        "SyncType": null,
        "LastProcessingDateTime": null,
        "ReprocessCount": 0,
        "DeliveryAddressId": 1001,
        "ExportedByWorkflow": false,
        "AutomaticProcessId": null,
        "StatusBeforeClosing": null,
        "PriorityApprovalDocument": false,
        "LastApprovalComment": null,
        "LastApproverName": "Example LastApproverName",
        "CurrentApproversNames": "Example CurrentApproversNames",
        "CurrentApproverIds": "Example CurrentApproverIds",
        "ApprovalDate": "2026-01-15T10:30:00Z",
        "IsGrouped": false,
        "IsChild": false,
        "ParentId": null
      },
      "LastUpdated": "2026-01-15T10:30:00Z",
      "Id": 1017,
      "TypeId": 1018,
      "Value": "Example Value",
      "Type": null
    }
  ],
  "CustomFieldValues": [
    {
      "DocumentId": 1004,
      "Id": 1017,
      "TypeId": 1018,
      "Value": "Example Value"
    }
  ],
  "LastProcessingDateTime": null,
  "ReprocessCount": 0,
  "DoxStoreQuoteId": null,
  "SentToSupplier": true,
  "EverSentToSupplier": true,
  "AcceptedBySupplier": null,
  "GeneratedFromPr": false,
  "SendToSupplierFailed": false,
  "BasePurchaseOrderNumber": "EXAMPLE-001",
  "CurrencyId": 1016,
  "CurrentExportMessage": "Example CurrentExportMessage",
  "ExportedTo": 0,
  "CurrentExportType": 0,
  "CurrentExportStatus": 0,
  "Exported": false,
  "ExportedDate": null,
  "SyncId": null,
  "SyncType": null,
  "ExportedByWorkflow": false,
  "AutomaticProcessId": null,
  "StatusBeforeClosing": null,
  "Supplier": {
    "Address": null,
    "BankAccountNumber": "",
    "BankSortCode": "",
    "BusinessUnitId": 1019,
    "ContactName": "Example ContactName",
    "CountryCode": "gb",
    "CountryCodeId": 1002,
    "DefaultNominalCode": null,
    "DefaultNominalCodeId": 1020,
    "DefaultPaymentTerms": 0,
    "PaymentTermStartType": 0,
    "PaymentTermDaysNumber": 1,
    "PaymentTermType": 1,
    "DefaultTaxCode": null,
    "DefaultTaxCodeId": 1012,
    "Email": null,
    "SupplierEmails": null,
    "LastUpdated": "2026-01-15T10:30:00Z",
    "DateCreated": "2026-01-15T10:30:00Z",
    "Products": [],
    "ReferenceNumber": "EXAMPLE-001",
    "SupplierId": 1006,
    "SupplierName": "Example SupplierName",
    "Telephone": "",
    "VatReg": "",
    "Void": false,
    "SmartName": "Example SmartName",
    "IsActive": true,
    "DefaultCostCodeId": 1021,
    "DefaultCostCode": null,
    "Type": "Example Type",
    "DefaultCurrencyId": 1016,
    "TrustedStatus": true,
    "DefaultDivisionId": 1005,
    "SupplierBankIBANNumber": "",
    "SupplierBankSwiftCode": "",
    "SupplierBankName": "",
    "SupplierBankAddress": ""
  },
  "PriorityApprovalDocument": false
}
```

 

### Field reference

 

| Field | Example JSON type | Use |
| --- | --- | --- |
| Address | object | Address object; preserve nullable fields. |
| RequisitorId | number | Numeric or external reference; use the appropriate resource context. |
| PurchaseOrderNumber | string | Displayed purchase-order number; preserve its formatting. |
| TotalNetValue | number | Document net amount; keep it consistent with line totals. |
| TotalGrossValue | number | Document gross amount; keep it consistent with tax and line values. |
| RequiredDate | string | Value associated with this record. |
| SupplierComment | null | Value associated with this record. |
| DocumentId | number | Numeric document reference; distinct from invoice or order number. |
| BusinessDivisionId | number | Numeric division reference. |
| CreatedBy | number | Value associated with this record. |
| SupplierId | number | Numeric supplier reference. |
| Description | null | Description text. |
| DateCreated | string | Record creation timestamp. |
| ImageLocation | null | Value associated with this record. |
| Type | number | Value associated with this record. |
| Status | number | Status enum value for the intended workflow. |
| Comments | null | Value associated with this record. |
| LastUpdated | string | Record update timestamp. |
| Void | boolean | Void flag. Choose changes deliberately. |
| LineItemMatchType | number | Value associated with this record. |
| ExternalRef | null | Value associated with this record. |
| ProcessId | number | Workflow definition reference. |
| ProcessStatus | number | Value associated with this record. |
| CurrentStepIndex | number | Value associated with this record. |
| DoxStoreId | null | Numeric or external reference; use the appropriate resource context. |
| SecondaryOrderRef | null | Value associated with this record. |
| LineItems | array | Document line objects with quantities, values and coding references. |
| CustomFields | array | Value associated with this record. |
| CustomFieldValues | array | Document-level custom-field values linked through TypeId. |
| LastProcessingDateTime | null | Value associated with this record. |
| ReprocessCount | number | Value associated with this record. |
| DoxStoreQuoteId | null | Numeric or external reference; use the appropriate resource context. |
| SentToSupplier | boolean | Value associated with this record. |
| EverSentToSupplier | boolean | Value associated with this record. |
| AcceptedBySupplier | null | Value associated with this record. |
| GeneratedFromPr | boolean | Value associated with this record. |
| SendToSupplierFailed | boolean | Value associated with this record. |
| BasePurchaseOrderNumber | string | Value associated with this record. |
| CurrencyId | number | Numeric currency reference. |
| CurrentExportMessage | string | Value associated with this record. |
| ExportedTo | number | Value associated with this record. |
| CurrentExportType | number | Value associated with this record. |
| CurrentExportStatus | number | Value associated with this record. |
| Exported | boolean | Value associated with this record. |
| ExportedDate | null | Value associated with this record. |
| SyncId | null | Numeric or external reference; use the appropriate resource context. |
| SyncType | null | Value associated with this record. |
| ExportedByWorkflow | boolean | Value associated with this record. |
| AutomaticProcessId | null | Numeric or external reference; use the appropriate resource context. |
| StatusBeforeClosing | null | Value associated with this record. |
| Supplier | object | Value associated with this record. |
| PriorityApprovalDocument | boolean | Value associated with this record. |

 

## 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](https://help.zaharasoftware.com/api-docs/enums-complete-list.md) · [API overview](https://help.zaharasoftware.com/api-docs/home.md)
