Skip to content

Updating a policy

To update an existing policy, make a PATCH request to:

sh
https://api.privy.io/v1/policies/<policy_id>

Replacing <policy_id> with the ID of your desired policy.

TIP

In the request headers, make sure to include Privy's required authentication headers and headers that may be required for your app's wallet API setup.

Body

In the request body, include the following fields:

FieldTypeDescription
namestring(Optional) New name to assign to policy.
method_rulesMethodRule(Optional) New list of MethodRule objects describing what rules to apply to each RPC method (e.g. 'eth_sendTransaction') that the wallet can take. Learn more about MethodRules.
default_action'ALLOW' | 'DENY'(Optional) New default action to take if a wallet request does not satisfy any of the method_rules for the policy.

Any fields not included in the PATCH request body will remain unchanged from the original policy.

Response

If the policy is updated successfully, the response will include the full updated policy object.

FieldTypeDescription
idstringUnique ID for the policy.
version'1.0'Version of the policy. Currently, 1.0 is the only version.
namestringUpdated name of the policy.
chain_type'ethereum'Chain type for wallets that the policy will be applied to.
method_rulesMethodRuleUpdated list of MethodRule objects describing what rules to apply to each RPC method (e.g. 'eth_sendTransaction') that the wallet can take. Learn more about MethodRules.
default_action'ALLOW' | 'DENY'Updated default action to take if a wallet request does not satisfy any of the rules for the policy.

Example

As an example, a sample request to update the method_rules of a policy with ID fmfdj6yqly31huorjqzq38zc might look like the following:

bash
$ curl --request PATCH https://api.privy.io/v1/policies/fmfdj6yqly31huorjqzq38zc \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>" \
-H "privy-authorization-signature: <authorization-signature-for-request>" \
-H 'Content-Type: application/json' \
-d '{
    "method_rules": [{
      "method": "eth_sendTransaction",
      "rules": [{
        "name": "Allowlist USDT"
        "conditions": [
            {
                "field_source": "ethereum_transaction",
                "field": "to",
                "operator": "eq",
                "value": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
            },
        ],
        "action": "ALLOW"
      }],
    }],
    "default_action": "DENY"
}'

A successful response will look like the following:

json
{
  "id": "fmfdj6yqly31huorjqzq38zc",
  "name": "Allowlist certain smart contracts",
  "version": "1.0",
  "chain_type": "ethereum",
  "method_rules": [
    {
      "method": "eth_sendTransaction",
      "rules": [
        {
          "name": "Allowlist USDT",
          "conditions": [
            {
              "field_source": "ethereum_transaction",
              "field": "to",
              "operator": "eq",
              "value": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
            }
          ],
          "action": "ALLOW"
        }
      ]
    }
  ],
  "default_action": "DENY"
}