Skip to documentation
Zahara DevelopersAPI documentation
DocumentationBudgets
Download .md
Budgets

Get All Budgets

Last updated

Retrieve budget definitions for one business unit, including period configuration, budget rows, recorded running totals and matching conditions. Use this method to inspect the budget configuration and data available to an integration.

This is a business-unit request. It does not retrieve every budget across an entire tenancy. The verified response uses structured JSON with BudgetDefinitionId, BudgetPeriodGroup, Rows and BudgetBasisConditionGroup.

Request

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

Send Accept: application/json. The supplied API definition specifies no request body or query parameters. This read-only request does not create a budget or apply a document to one.

Moving from the previous example

The previous article incorrectly showed BusinessUnit/GetAll with a tenancy key. That is the business-unit discovery method, not the budget method. Use BusinessBudget/GetAll with a business-unit API key.

The previous example also used legacy fields such as BudgetId, DetailsXml and Enabled. None of those top-level fields appeared in the verified response. Do not parse DetailsXml or assume its legacy schema applies here. The current observed identifier is BudgetDefinitionId; the top-level activity flag is Active. Enabled appears on individual rows.

Only the business unit used in verification was tested. Behaviour for other budget implementations or older configurations has not been established.

Authentication and scope

Parameter Location Required Description
businessUnitApiKey URL path Yes API key for the business unit whose budgets you want to read. A numeric business-unit ID or tenancy API key is not a substitute.

Obtain the appropriate business-unit key through your Zahara administrator. Store it in an environment variable or secret store. The examples below use ZAHARA_BUSINESS_UNIT_API_KEY.

Keys appear in request paths. Redact URLs in application logs, proxies and monitoring tools. Never paste real keys into shared documentation or an AI conversation. Budget names, amounts, descriptions and matching conditions can also be confidential.

Working examples

The cURL, JavaScript and Python programs below were each executed successfully against the production API on 25 November 2026. They returned a top-level JSON array with matching budget counts. These are read-only examples; a sandbox was not tested.

cURL

Requires cURL 7.76.0 or later for --fail-with-body. Set the environment variable before running it. This example prints the complete response, so use a secure development terminal.

# Set ZAHARA_BUSINESS_UNIT_API_KEY in your environment first.
# cURL 7.76.0+; this request returns confidential budget data.
curl --fail-with-body --silent --show-error --max-time 30 \
  --header 'Accept: application/json' \
  "https://api.myzahara.net/api/${ZAHARA_BUSINESS_UNIT_API_KEY:?Set your business-unit API key}/BusinessBudget/GetAll"

JavaScript (Node.js 22+)

Uses built-in fetch with a 30-second timeout, an HTTP status check and an array check. It prints selected metadata instead of financial amounts.

// Node.js 22+. No additional packages required.
const key = process.env.ZAHARA_BUSINESS_UNIT_API_KEY;
if (!key) throw new Error('Set ZAHARA_BUSINESS_UNIT_API_KEY');
const response = await fetch(
  'https://api.myzahara.net/api/' + encodeURIComponent(key) + '/BusinessBudget/GetAll',
  { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(30000), redirect: 'error' }
);
if (!response.ok) throw new Error('Zahara returned HTTP ' + response.status);
const budgets = await response.json();
if (!Array.isArray(budgets)) throw new Error('Expected a JSON array of budgets');

// Log a small selection rather than financial amounts or the full response.
// Even names and IDs may be confidential: use a secure development console.
console.log(JSON.stringify({
  count: budgets.length,
  budgets: budgets.map(budget => ({
    BudgetDefinitionId: budget.BudgetDefinitionId,
    BudgetName: budget.BudgetName,
    Active: budget.Active,
    CurrencyId: budget.CurrencyId,
    rowCount: Array.isArray(budget.Rows) ? budget.Rows.length : null
  }))
}, null, 2));

Python 3 (standard library)

Requires no additional packages. Redirects are rejected, HTTP and network errors are handled, and the response is checked before use.

# Python 3. Standard library only.
import json
import os
from urllib.parse import quote
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

key = os.environ.get('ZAHARA_BUSINESS_UNIT_API_KEY')
if not key:
    raise SystemExit('Set ZAHARA_BUSINESS_UNIT_API_KEY')
request = Request(
    'https://api.myzahara.net/api/' + quote(key, safe='') + '/BusinessBudget/GetAll',
    headers={'Accept': 'application/json'}
)
try:
    with build_opener(NoRedirect).open(request, timeout=30) as response:
        budgets = json.load(response)
except HTTPError as error:
    raise SystemExit('Zahara returned HTTP ' + str(error.code)) from None
except URLError:
    raise SystemExit('Could not reach Zahara') from None
if not isinstance(budgets, list):
    raise SystemExit('Expected a JSON array of budgets')

# Names and IDs can also be confidential. Use a secure development console.
print(json.dumps({
    'count': len(budgets),
    'budgets': [
        {
            'BudgetDefinitionId': budget.get('BudgetDefinitionId'),
            'BudgetName': budget.get('BudgetName'),
            'Active': budget.get('Active'),
            'CurrencyId': budget.get('CurrencyId'),
            'rowCount': len(budget['Rows']) if isinstance(budget.get('Rows'), list) else None
        } for budget in budgets
    ]
}, indent=2))

Successful response

The verified request returned HTTP 200 and a top-level JSON array of budget objects, without a wrapper such as items or result. All returned budgets in that test had Active: true and Void: false. This observation does not establish whether inactive or void budgets are always excluded.

The following is a fictionalised, shortened example. IDs, names, dates and amounts are invented. The arrays contain a single illustrative item; real responses may contain multiple rows, periods, condition groups and conditions. Audit properties on nested objects have been omitted for readability.

[
  {
    "BudgetDefinitionId": 1001,
    "Active": true,
    "Void": false,
    "UpdatedDate": null,
    "DeletedDate": null,
    "BudgetHolder": null,
    "BusinessUnitId": 101,
    "BudgetName": "Example purchasing budget",
    "TenancyId": 1,
    "Description": null,
    "BudgetPeriodGroupId": 201,
    "RolloverEnabled": false,
    "EnforceSpendControl": false,
    "AutoRenew": false,
    "CurrencyId": 1,
    "OrderSpendDateType": 0,
    "InvoiceSpendDateType": 1,
    "AllocateMatchedInvoiceDate": 1,
    "AllocateMultipleTierInvoiceMatchesToDateRule": 0,
    "UsePurchaseOrderDatesForMatchedInvoices": false,
    "LegacyMigrationBudgetId": 0,
    "LegacyLockApplied": false,
    "BudgetPeriodGroup": {
      "BudgetPeriodGroupId": 201,
      "GroupName": "Example periods",
      "IntervalType": 4,
      "IsGlobalDefault": false,
      "BudgetCustomPeriodGroupDefinitions": [
        {
          "BudgetCustomPeriodGroupDefinitionId": 301,
          "BudgetPeriodGroupId": 201,
          "PeriodName": "Example period",
          "PeriodNumber": 1,
          "StartDate": "2026-01-01T00:00:00Z",
          "EndDate": "2026-01-31T23:59:59Z"
        }
      ]
    },
    "Rows": [
      {
        "BudgetDefinitionRowId": 401,
        "BudgetDefinitionId": 1001,
        "RolloverEnabled": false,
        "RolloverValue": 0,
        "BudgetBasisConditionGroupId": 501,
        "BudgetPeriodGroupId": 201,
        "PeriodNumber": 1,
        "PeriodStart": "2026-01-01T00:00:00Z",
        "PeriodEnd": "2026-01-31T23:59:59Z",
        "PeriodBudgetAmount": 10000,
        "RunningTotalNet": 1000,
        "RunningTotalGross": 1200,
        "PendingRunningTotalNet": 200,
        "PendingRunningTotalGross": 240,
        "CurrencyId": 1,
        "Enabled": true
      }
    ],
    "BudgetBasisConditionGroup": [
      {
        "BudgetBasisConditionGroupId": 501,
        "BudgetBasisConditions": [
          {
            "BudgetBasisConditionId": 601,
            "BasisId": 701,
            "BudgetBasisTypeId": 4,
            "BasisCondition": 0,
            "CustomTypeId": null,
            "CustomValue": "",
            "BudgetBasisConditionGroupId": 501
          }
        ]
      }
    ]
  }
]

Top-level field reference

Types below describe the tested response. They are not a complete schema or a guarantee of requiredness or nullability in every configuration.

Field Observed JSON type Meaning / integration use
BudgetDefinitionId number Identifier for the returned budget definition. This is not the legacy BudgetId field.
BusinessUnitId number Business unit associated with the budget.
TenancyId number Associated tenancy ID, not an API key.
BudgetName string Budget name for display or selection. Do not assume names are unique.
Active boolean Top-level budget activity flag. Inactive-budget inclusion was not verified.
Void boolean Void flag. Inclusion of void budgets was not verified.
UpdatedDate / DeletedDate null These were null in the test. Do not assume they are always null or that their non-null format is established.
BudgetHolder / Description null These were null in every tested object. Their populated shapes were not established.
BudgetPeriodGroupId number Identifier for the associated period group.
BudgetPeriodGroup object Period-group configuration and custom period definitions.
Rows array of objects Budget rows combining periods and matching-condition groups, with amounts and recorded totals.
BudgetBasisConditionGroup array of objects Matching-condition groups referenced by the rows. The property name is singular even though its value is an array.
RolloverEnabled boolean Budget-level rollover setting. Rows also carry their own rollover fields.
EnforceSpendControl boolean Spend-control configuration flag. This response does not itself evaluate a proposed purchase.
AutoRenew boolean Auto-renewal configuration flag; renewal execution was not tested.
CurrencyId number Currency identifier. Do not infer an ISO currency code from the numeric value.
OrderSpendDateType / InvoiceSpendDateType number Date-selection configuration codes. Exact enum mappings were not verified.
AllocateMatchedInvoiceDate / AllocateMultipleTierInvoiceMatchesToDateRule number Matched-invoice date-allocation configuration codes. Exact mappings were not verified.
UsePurchaseOrderDatesForMatchedInvoices boolean Configuration flag for use of purchase-order dates with matched invoices.
LegacyMigrationBudgetId / LegacyLockApplied number / boolean Legacy migration reference and lock flag. A full migration-state contract was not verified.

Period-group fields

Field Observed JSON type Meaning / integration use
BudgetPeriodGroup.BudgetPeriodGroupId number Identifier of the period group.
BudgetPeriodGroup.GroupName string Period-group name.
BudgetPeriodGroup.IntervalType number Interval configuration code. Do not reuse an enum mapping from the legacy budget example.
BudgetPeriodGroup.IsGlobalDefault boolean Flag identifying a global-default group.
BudgetPeriodGroup.BudgetCustomPeriodGroupDefinitions array of objects Custom period definitions observed in the response.
…BudgetCustomPeriodGroupDefinitionId number Custom period definition identifier.
…BudgetPeriodGroupId number Associated period-group identifier.
…PeriodName / PeriodNumber string / number Period label and number.
…StartDate / EndDate string Observed ISO 8601 UTC date-time strings. Boundary inclusivity was not verified.

Row fields

Rows form a matrix of periods and matching conditions. Do not treat Rows.length as the number of unique periods: different condition groups can produce multiple rows for a period.

Field in Rows[] Observed JSON type Meaning / integration use
BudgetDefinitionRowId number Budget row identifier.
BudgetDefinitionId number Associated budget definition.
BudgetBasisConditionGroupId number Link to the matching group in BudgetBasisConditionGroup[].
BudgetPeriodGroupId / PeriodNumber number Period-group reference and period number.
PeriodStart / PeriodEnd string Observed ISO 8601 UTC period boundaries. A null end date was not observed; do not assume universal non-nullability.
PeriodBudgetAmount number Budget amount recorded for the row.
RunningTotalNet / RunningTotalGross number Recorded net and gross running totals.
PendingRunningTotalNet / PendingRunningTotalGross number Recorded pending net and gross running totals.
RolloverEnabled / RolloverValue boolean / number Row-level rollover configuration and value.
CurrencyId number Currency reference for the row.
Enabled boolean Row-level enabled flag, distinct from the top-level Active flag.

Do not present a simple subtraction of these fields as Zahara's authoritative available-budget calculation. Matching, pending spend, rollover, currency and date rules affect interpretation. This method returns recorded data; spend validation and applying documents to budgets are separate operations.

Condition-group fields

Field Observed JSON type Meaning / integration use
BudgetBasisConditionGroup[].BudgetBasisConditionGroupId number Group identifier referenced by budget rows.
BudgetBasisConditionGroup[].BudgetBasisConditions array of objects Conditions in the group.
…BudgetBasisConditionId number Individual condition identifier.
…BudgetBasisConditionGroupId number Parent group reference.
…BasisId / BudgetBasisTypeId / BasisCondition number Matching target, basis type and condition codes. Target semantics, enum mappings and evaluation rules were not verified.
…CustomTypeId null Null in the test; its populated form was not established.
…CustomValue string Custom-value field; the test does not establish every possible value or format.

The nested period groups, period definitions, rows, condition groups and conditions also included tenancy/business-unit references and audit properties such as Void, CreatedDate, UpdatedDate and DeletedDate. Observed dates were strings or null depending on the object. These fields are omitted from the shortened example above.

Handling failures

Check the HTTP status before parsing or using the response. Both a deliberately nonexistent key and a tenancy key supplied in place of a business-unit key returned HTTP 401 with:

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

If you receive this response, check the key, environment and scope. Do not assume article 177's invalid-tenancy-key HTTP 404 behaviour applies to this method.

Other error statuses and response formats remain unverified. Handle network timeouts and non-JSON responses as failures. Avoid logging credential-bearing request URLs. The examples make one request and do not automatically retry it.

Integration notes

  • GetAll is scoped to the supplied business unit, not the entire tenancy. Use authorised business-unit keys separately when integrating multiple businesses.
  • Property names are case-sensitive in many clients. Use BudgetDefinitionId, Rows and BudgetBasisConditionGroup exactly as returned.
  • No pagination parameters appear in the supplied API definition. Maximum result size, pagination guarantees and response ordering were not established.
  • All four tested budgets were active and non-void. Empty-business-unit results, inactive or deleted-budget inclusion and other budget implementations were not tested.
  • Treat budget amounts as financial data and handle decimal precision deliberately; JSON number alone does not define a rounding policy.
  • Preserve nulls and unknown enum codes. Do not infer missing semantics from the old DetailsXml example.
  • A returned budget definition is not a permission grant, a spend check or confirmation that an invoice has been applied to a budget.

Verification

Verified on 25 November 2026 using an authorised business-unit key on the production API: HTTP 200 with an array of budget definitions; the cURL, Node.js and Python samples each completed successfully; invalid and wrong-scope keys returned HTTP 401.

The method, path and key scope were checked against Zahara's API collection. Local budget-domain models were used to cross-check the meaning of period groups and budget rows, while the response field reference follows the observed API JSON rather than assuming entity-model property names.

The example uses fictional data. Enum mappings, comprehensive nullability, inactive/void and empty-result behaviour, other budget implementations, permissions, rate limits, pagination limits and sandbox behaviour remain unverified.

.md
Take this page to your coding agent.

Copy a clean Markdown URL that follows the published article.