Capxul Docs
HooksOrganizations

useCapxulOrganizationAccount

Query hook for an organization's account summary — balance, available balance, and account address, scoped by org id.

Reads an organization's account summary — one flat record with the account id, the org's account address, its balance, and its available balance. The money numbers are the same as useCapxulOrgTreasury; this hook adds the org's address on top. Like the treasury, this is the org's money view — deploy readiness lives on useCapxulOrgDeployRoles.

Import

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

Usage

"use client";

import type { OrgId } from "@capxul/sdk";
import { useCapxulOrganizationAccount } from "@capxul/sdk-react";

function OrgAccountCard({ orgId }: { orgId: OrgId }) {
  const account = useCapxulOrganizationAccount(orgId);

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

  return (
    <div>
      <p>
        {account.data.balance.value} {account.data.balance.currency}
      </p>
      <p>
        Available: {account.data.available.value}{" "}
        {account.data.available.currency}
      </p>
    </div>
  );
}

Parameters

organizationId

OrgId | undefined

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

options

UseCapxulOrganizationAccountOptions | undefined

Prop

Type

Return type

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

data is an OrganizationAccount:

FieldTypeDescription
idstringThe org account's id.
addressstring | nullThe org's account address. null when the org cannot be resolved from your org list.
balanceMoneyThe org's balance.
availableMoneyThe spendable portion of the balance.

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, "account"] — org-scoped, invalidated alongside the treasury key by org money mutations (for example useCapxulRunPayroll for that org) without touching other orgs.

Client method

This hook wraps client.org(orgId).account.get() — the entity-scoped org bundle on the core SDK. The client composes the record from the treasury read plus your org list.

On this page