Skip to main content

Policy structure

Our policies are defined using JSON. The effect determines if an activity should be allowed or denied based on the evaluation of the consensus and condition fields. consensus and condition are composed of ergonomic expressions written in our policy language that must evaluate to a bool. consensus determines which user(s) may take an action (e.g. a given user ID). condition determines the conditions under which the policy applies (e.g. signing with a specific wallet). condition is required. Creating a policy whose condition is missing, empty, or only whitespace is rejected with HTTP 400 (INVALID_ARGUMENT, message policy condition is required); so is an update that sets policyCondition to an empty or whitespace-only value (an update that omits policyCondition keeps the current one). To write a policy that applies to every activity, set "condition": "true" explicitly. consensus is optional.

See below for an example policy that allows a single user to send transactions to a single address

Managing policies

The SDK method names are the same in @0xkey-io/sdk-server, the Swift SDK (ZeroXKeyClient), and the Kotlin SDK (ZeroXKeyClient). Deleting a policy ID that does not exist in the organization returns HTTP 404 (NOT_FOUND); call list_policies and retry with the current IDs. See Errors.
For keys that are restricted by transaction fields (eth.tx.*, solana.tx.*, tron.tx.*), sign with the transaction-signing endpoints (such as sign_transaction), and add a policy that denies raw payload signing for those keys unless your integration needs it. See Activity parameters.

Policy evaluation

All policies defined within an Organization are evaluated on each request. The image below describes how an activity outcome is determined when resolving multiple policies. The rule follows the below steps:
1
If a quorum of root users takes the action, the final outcome is OUTCOME_ALLOW
2
Else if any applicable policy has EFFECT_DENY, the final outcome is OUTCOME_DENY. This is also referred to as “explicit deny.”
3
Else if at least one applicable policy has EFFECT_ALLOW, then the final outcome is OUTCOME_ALLOW
4
Else the final outcome is OUTCOME_DENY. This is also referred to as “implicit deny.” In cases of conflicts, EFFECT_DENY always wins.
Stated differently:
policy overview
Almost all actions on 0xkey are implicitly denied by default. There are a few exceptions, however:
  • The Root Quorum bypasses any policies.
  • All users have implicit GET (read) permissions in their own Organization and any associated Sub-Organizations.
  • All users have implicit permission to change their own credentials, unless a policy explicitly allows or denies those actions.
  • All users have implicit permission to approve an activity if they were included in consensus (i.e., a user specified as part of the consensus required to approve a SIGN_TRANSACTION activity does not need separate, explicit permission to sign transactions).