Create Policy

Creates a new gas manager policy with the specified rules. Returns the policy id of a successfully created policy. The newly created policy will be in the inactive status.

Header Access Token

To call this endpoint, you must use your access token in the authorization header of the API request. Useful resources:

Testnets

On testnets, the userOp price is always $0, and hence the maxSpendUsd, maxSpendPerSenderUsd, and maxSpendPerUoUsd should not be configured.

Adding Custom Rules

If you add custom rules (webhook URL) to the policy, the Gas Manager will make a POST request to the URL every time you use alchemy_requestPaymasterAndData, alchemy_requestGasAndPaymasterAndData, or pm_getPaymasterData.

Request Payload

  • userOperation: The userOp object.
  • policyId: The ID of your policy.
  • chainId: The ID of the network where the operation is being performed.
  • webhookData: Additional data you wish to include in the request, such as proof of humanity.

Here is an example request body:

1{
2 "userOperation": { }, // structure depends on EntryPoint version
3 "policyId": "",
4 "chainId": "",
5 "webhookData": ""
6}

Expected Result

Your endpoint should respond with a 200 status code and a JSON body ({ "approved": true | false }) indicating whether to the userOp passes the custom rules.

Anything other than the above will be treated as error, and the Gas Manager will sponsor the userOp only if approveOnFailure is true.

Headers

AuthorizationstringRequired

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
policyNamestringRequired

Name of the policy

policyTypestringRequired

Type of the policy (e.g. “sponsorship”). Currently we support sponsorship (for EVM network policies) and solana (for Solana network policies).

appIdstringRequired

ID for the app associated with the new policy. Learn how to find your app ID here.

networkslist of stringsRequired

Networks for the policy. Example: ETH_MAINNET. For Solana policies, valid values are SOLANA_MAINNET and SOLANA_DEVNET.

rulesobjectOptional

Rules for sponsorship policy type. Empty if policyType is not sponsorship.

Response

Policy created successfully

dataobject
errorobject