useCapxulOrgDeployRoles
Mutation hook that deploys an organization's role set so role grants and spend caps become enforceable.
Deploys an organization's seeded role set, making it live so role grants and
spend caps are enforced. This is the org's deploy-readiness surface, not
its money — the org's balance lives on
useCapxulOrgTreasury.
Read the current role set with
useCapxulOrgRoles.
Import
import { useCapxulOrgDeployRoles } from "@capxul/sdk-react";Usage
"use client";
import type { OrgId } from "@capxul/sdk";
import { useCapxulOrgDeployRoles } from "@capxul/sdk-react";
function DeployRolesButton({ orgId }: { orgId: OrgId }) {
const deployRoles = useCapxulOrgDeployRoles();
return (
<div>
<button
type="button"
disabled={deployRoles.isPending}
onClick={() => deployRoles.mutate(orgId)}
>
{deployRoles.isPending ? "Deploying…" : "Deploy roles"}
</button>
{deployRoles.error ? <p>{deployRoles.error.message}</p> : null}
</div>
);
}Parameters
The hook itself takes no parameters. The mutation takes the OrgId of the
organization whose role set to deploy:
deployRoles.mutate(orgId);Return type
import { type UseCapxulOrgDeployRolesReturn } from "@capxul/sdk-react";
// UseMutationResult<readonly RoleView[], CapxulError, OrgId>On success, data is the deployed role list — readonly RoleView[], the same
shape returned by
useCapxulOrgRoles.
The hook returns TanStack Query's UseMutationResult. The most-used fields:
| Field | Description |
|---|---|
mutate | Fire the mutation (fire-and-forget; pair with onSuccess/onError callbacks). |
mutateAsync | Fire the mutation and get a Promise of the result. Rejects with a CapxulError on failure. |
data | The mutation result (typed per hook, shown above). undefined until the first success. |
error | A CapxulError when the last attempt failed, otherwise null. |
isPending | true while the mutation is in flight. Use it to disable submit buttons. |
reset | Clear the mutation state (data, error) back to idle. |
Mutations do not retry by default. The full field list is in the
TanStack Query useMutation reference;
see also the TanStack Query integration guide.
Cache behavior
On success this mutation invalidates the org's role list
(["capxul", "org", orgId, "roles"]), the org detail
(["capxul", "org", orgId]), and the org list (["capxul", "orgs"]), so the
readiness change is reflected everywhere the org appears.
Errors
Failures surface as a CapxulError on
error / thrown from mutateAsync — for example when role deployment is not
available for the key's environment.
Client method
This hook wraps client.org(orgId).deployRoles() — the
entity-scoped org bundle on the core SDK.