Creates a new policy that can be used to govern the behavior of projects and accounts.
Options for creating the policy
Options for creating a Policy.
Optional
idempotencyKey?: stringThe idempotency key to ensure the request is processed exactly once. Used to safely retry requests without accidentally performing the same operation twice.
The policy definition to create. Contains the scope, description, and rules for the policy.
Optional
description?: stringAn optional human-readable description for the policy. Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.
Array of rules that comprise the policy. Limited to a maximum of 10 rules per policy.
The scope of the policy. "project" applies to the entire project, "account" applies to specific accounts.
The created policy
const policy = await cdp.policies.createPolicy({
policy: {
scope: "account",
description: "Limits the amount of ETH in transaction",
rules: [
{
action: "reject",
operation: "signEvmTransaction",
criteria: [
{
type: "ethValue",
ethValue: "1000000000000000000",
operator: ">",
},
],
},
],
}
});
const idempotencyKey = uuidv4();
// First call creates the policy
const policy = await cdp.policies.createPolicy({
policy: {
scope: "account",
description: "Limits the amount of ETH in transaction",
rules: [
{
action: "reject",
operation: "signEvmTransaction",
criteria: [
{
type: "ethValue",
ethValue: "1000000000000000000",
operator: ">",
},
],
},
],
},
idempotencyKey
});
// Second call with same key returns the same policy
const samePolicy = await cdp.policies.createPolicy({
policy: { ... },
idempotencyKey
});
Deletes a policy by its unique identifier. If a policy is referenced by an active project or account, this operation will fail.
Options containing the policy ID to delete
Options for deleting a Policy.
The unique identifier of the policy to delete. This is a UUID that's generated when the policy is created.
Optional
idempotencyKey?: stringThe idempotency key to ensure the request is processed exactly once. Used to safely retry requests without accidentally performing the same operation twice.
Void on successful deletion
Retrieves a policy by its unique identifier.
Options containing the policy ID to retrieve
Options for retrieving a Policy by ID.
The requested policy
Lists policies belonging to the developer's CDP Project. Can be filtered by scope (project or account).
Optional
options: ListPoliciesOptions = {}Options for filtering and paginating the results
Optional
pageSize?: numberThe page size to paginate through the accounts.
Optional
pageToken?: stringThe page token to paginate through the accounts.
Optional
scope?: "project" | "account"The scope of the policies to return. If project
, the response will include exactly one policy, which is the project-level policy. If account
, the response will include all account-level policies for the developer's CDP Project.
A paginated list of policies
Updates an existing policy by its unique identifier. This will apply the updated policy to any project or accounts that are currently using it.
Options containing the policy ID and updated policy data
Options for updating a Policy.
The unique identifier of the policy to update. This is a UUID that's generated when the policy is created.
Optional
idempotencyKey?: stringThe idempotency key to ensure the request is processed exactly once. Used to safely retry requests without accidentally performing the same operation twice.
The updated policy definition. Contains the description and rules for the policy.
Optional
description?: stringAn optional human-readable description for the policy. Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.
Array of rules that comprise the policy. Limited to a maximum of 10 rules per policy.
The updated policy
const updatedPolicy = await cdp.policies.updatePolicy({
id: "__ID__",
policy: {
description: "Now with lower transaction limits",
rules: [
{
action: "reject",
operation: "signEvmTransaction",
criteria: [
{
type: "ethValue",
ethValue: "1000000000",
operator: ">",
},
],
},
],
},
});
The namespace containing all Policy methods.