Skip to main content
You can update a policy by updating rules one at a time, or by updating the whole policy at once. You can do this using the Privy Dashboard, the NodeJS SDK, or the REST API. If a policy has an owner, the owner’s signature is required to modify the policy, see setting authorization signatures.

Updating policy rules individually

You can create, get, update, and delete individual rules in a policy. We recommend this over updating the whole policy at once, especially if you find yourself updating the same policy over time. This way, you can ensure there would be no race conditions when updating the policy.

Add a rule to a policy

  • NodeJS
  • NodeJS (server-auth)
  • Rust
  • REST API
Use the PrivyClient’s createRule method in the policies() interface to add a rule to a policy.
const rule = await client.policies().createRule('insert-policy-id', {
  name: 'Allow list USDT',
  method: 'eth_sendTransaction',
  conditions: [
    {
      field_source: 'ethereum_transaction',
      field: 'to',
      operator: 'eq',
      value: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
    }
  ],
  action: 'ALLOW'
});

Edit a rule in a policy

  • NodeJS
  • NodeJS (server-auth)
  • Rust
  • REST API
Use the PrivyClient’s updateRule method in the policies() interface to update a rule in a policy.
const rule = await client.policies().updateRule('insert-rule-id', {
  policy_id: 'insert-policy-id',
  name: 'Allow list USDT',
  method: 'eth_sendTransaction',
  conditions: [
    {
      field_source: 'ethereum_transaction',
      field: 'to',
      operator: 'eq',
      value: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
    }
  ],
  action: 'ALLOW'
});

Delete a rule from a policy

  • NodeJS
  • NodeJS (server-auth)
  • Rust
  • REST API
Use the PrivyClient’s deleteRule method in the policies() interface to delete a rule from a policy.
const rule = await client.policies().deleteRule('insert-rule-id', {
  policy_id: 'insert-policy-id'
});

Update a whole policy

  • NodeJS
  • NodeJS (server-auth)
  • Java
  • Rust
  • REST API
Use the PrivyClient’s update method from the policies() interface to update an existing policy.
const policy = await client.policies().update('fmfdj6yqly31huorjqzq38zc', {
  name: 'Transactions must be <= 5ETH',
  rules: [
    {
      name: 'Transactions must be <= 5ETH',
      method: 'eth_sendTransaction',
      action: 'ALLOW',
      conditions: [
        {
          field_source: 'ethereum_transaction',
          field: 'value',
          operator: 'lte',
          value: '0x2386F26FC10000'
        }
      ]
    }
  ]
});
I