Capxul Docs
HooksOrganizations

useCapxulOrgTreasury

Query hook for an organization's treasury Account — the org's balance, scoped by org id.

Reads an organization's treasury — the org's Account, with balance and available balance. This is the money view of the org, not its deploy-readiness status.

Import

import { useCapxulOrgTreasury } from "@capxul/sdk-react";

Usage

"use client";

import { useCapxulOrgs, useCapxulOrgTreasury } from "@capxul/sdk-react";

function TreasuryCard() {
  const orgs = useCapxulOrgs();
  const orgId = orgs.data?.[0]?.id;
  const treasury = useCapxulOrgTreasury(orgId);

  if (treasury.isLoading) return <p>Loading treasury…</p>;
  if (treasury.error) return <p>{treasury.error.message}</p>;

  return (
    <p>
      {treasury.data.balance.value} {treasury.data.balance.currency}
    </p>
  );
}

Parameters

orgId

OrgId | undefined

The organization to read. The query stays disabled while orgId is undefined, so you can pass the result of another query directly — no manual gating needed.

options

UseCapxulOrgTreasuryOptions | undefined

Prop

Type

Return type

import { type UseCapxulOrgTreasuryReturn } from "@capxul/sdk-react";
// UseQueryResult<Account, CapxulError>

data is the treasury Account. Note this is the org's money (Account with balances), never the deploy-readiness ladder — those live on the org lifecycle surface.

The hook returns TanStack Query's UseQueryResult. The most-used fields:

FieldDescription
dataThe query data (typed per hook, shown above). undefined until the first success.
errorA CapxulError when the last fetch failed, otherwise null.
status'pending' | 'error' | 'success'.
isLoadingtrue during the first fetch (no data yet).
isFetchingtrue whenever a fetch is in flight, including background refetches.
refetchManually refetch the query.

Capxul query hooks stay pending until the provider finishes bootstrapping — you do not need to gate them on useCapxul() yourself. The full field list is in the TanStack Query useQuery reference; see also the TanStack Query integration guide.

Query key

["capxul", "org", orgId, "treasury"] — org-scoped, so org money mutations (for example useCapxulRunPayroll for that org) invalidate it without touching other orgs.

Client method

This hook wraps client.org(orgId).treasury() — the entity-scoped org bundle on the core SDK.

On this page