- NodeJS
- NodeJS (server-auth)
- Java
- Rust
- REST API
Use the
PrivyClient’s get method from the policies() interface to get a policy by its ID.Report incorrect code
Copy
Ask AI
const policy = await privy.policies().get('fmfdj6yqly31huorjqzq38zc');
The
@privy-io/server-auth library is deprecated. We recommend integrating @privy-io/node for
the latest features and support.PrivyClient’s getPolicy method to get a policy by its ID.Report incorrect code
Copy
Ask AI
const policy = await privy.getPolicy({
id: 'fmfdj6yqly31huorjqzq38zc'
});
You can get a policy using the Java SDK by using the
policies().retrieve() method.Report incorrect code
Copy
Ask AI
try {
PolicyRetrieveResponse response = privyClient
.policies()
.retrieve("fmfdj6yqly31huorjqzq38zc");
if (response.policy().isPresent()) {
Policy policy = response.policy().get();
String policyId = policy.id();
}
} catch (APIException e) {
String errorBody = e.bodyAsString();
System.err.println(errorBody);
} catch (Exception e) {
System.err.println(e.getMessage());
}
Parameters
The ID of the policy to retrieve.
Returns
ThePolicyRetrieveResponse object contains an optional policy() field that contains the retrieved
policy if the policy was retrieved successfully.The retrieved policy.
Show Policy
Show Policy
Version of the policy.
Name of the policy.
Chain type of the wallets that the policy will be applied to.
Unique ID of the policy.
The key quorum ID of the owner of the policy.
The Unix time of when the policy was created.
A list of
Rule objects describing what rules to apply to each RPC method (e.g.
'eth_sendTransaction') that the wallet can take. Learn more about
Rules.Use the
PrivyClient’s get method from the policies() interface to get a policy by its ID.Report incorrect code
Copy
Ask AI
use privy_rs::PrivyClient;
let client = PrivyClient::new(app_id, app_secret)?;
let policy = client
.policies()
.get("fmfdj6yqly31huorjqzq38zc")
.await?;
println!("Policy: {}", policy.name);
println!("Rules: {:?}", policy.rules);
Parameters and Returns
See the Rust SDK documentation for detailed parameter and return types, including embedded examples:For REST API details, see the API reference.To get a policy by its ID, make a Replacing
GET request to:Report incorrect code
Copy
Ask AI
https://api.privy.io/v1/policies/<policy_id>
<policy_id> with the ID of your desired policy.Response
A successful response will return the following fields:Unique ID for the policy.
Version of the policy. Currently, 1.0 is the only version.
Name to assign to policy.
Chain type for wallets that the policy will be applied to.
A list of
Rule objects describing what rules to apply to each RPC method (e.g.
'eth_sendTransaction') that the wallet can take. Learn more about
Rules.The key quorum ID of the owner of the policy, whose signature is required to modify the policy.
Example
A sample request to fetch a policy with IDfmfdj6yqly31huorjqzq38zc looks like:Report incorrect code
Copy
Ask AI
curl --request GET https://api.privy.io/v1/policies/fmfdj6yqly31huorjqzq38zc \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>"
Response
A successful response will look like the following:Report incorrect code
Copy
Ask AI
{
"id": "fmfdj6yqly31huorjqzq38zc",
"name": "Allowlist certain smart contracts",
"version": "1.0",
"chain_type": "ethereum",
"rules": [
{
"name": "Allowlist USDC",
"method": "eth_sendTransaction",
"conditions": [
{
"field_source": "ethereum_transaction",
"field": "to",
"operator": "eq",
"value": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
],
"action": "ALLOW"
}
],
"owner_id": "fmfdj6yqly31huorjqzq38zc"
}

