Skip to main content
Declarative rules are in early access and are not enabled by default. Talk to us if you’d like to participate.
These helpers write declarative rules to the wallet layer and to the caller’s own signer layer. They run with the signed-in end user’s session (the wallet owner, or a business-account owner or admin), not an API token. For the legacy PolicyRules helpers, see Manage Policies.

Before you start

  • Create and initialize a Dynamic client (see Creating a Dynamic Client, Initializing the Dynamic Client).
  • Use @dynamic-labs-sdk/client and @dynamic-labs-sdk/react-hooks 1.42.0 or later. The helpers are exported from @dynamic-labs-sdk/client/waas, and the hooks from @dynamic-labs-sdk/react-hooks.
  • walletAccount below is the WaaS wallet account, for example one returned by getWalletAccounts().
  • A layer holds legacy rules or declarative rules, never both. A write that would mix them is refused, and until declarative rules are enabled for your environment a declarative write is refused with rule_syntax_disabled.
The examples use this rule from Rule examples:

Read rules

getWalletPolicyLayer and getSignerPolicyLayer return the layer. readPolicyLayerRules returns its entries, and isDeclarativePolicyRule tells declarative rules apart from legacy ones.
For the caller’s own signer layer, use getSignerPolicyLayer({ walletAccount }) or useGetSignerPolicyLayer({ walletAccount }).

Add or update a rule

An upsert creates the rule, or updates it when its ruleId already exists on the layer. Leave ruleId out to create a rule, and the returned layer contains the generated id.
For the caller’s own signer layer, use upsertSignerPolicyRule({ walletAccount, rule }) or useUpsertSignerPolicyRule.

Remove a rule

For the caller’s own signer layer, use removeSignerPolicyRule({ walletAccount, ruleId }) or useRemoveSignerPolicyRule.

Replace the layer’s rules

replacePolicyLayerRules sets the layer’s full rule list, so any rule you leave out is removed. Keep the ruleId of every rule you are keeping. Use scope: { walletId } for the wallet layer, where walletId is the wallet’s verifiedCredentialId, or scope: { shareSetId } for the caller’s own signer layer. Only environment admins and business-account admins can replace a layer.

Errors

The write helpers throw an APIError when the request is refused. Its code tells you why, for example rule_syntax_disabled when declarative rules are not enabled for the environment, or composition_layer_edit_mixed_rule_syntax when the write would mix legacy and declarative rules.

Next steps

Rule examples

Ready-made declarative rules.

Manage Policies

The legacy PolicyRules helpers.
Last modified on October 23, 2026