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.
To call this endpoint, you must use your access token in the authorization header of the API request. Useful resources:
On testnets, the userOp price is always $0, and hence the
maxSpendUsd
,maxSpendPerSenderUsd
, andmaxSpendPerUoUsd
should not be configured.
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
The POST
request sent to your URL will include the following:
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:
{
"userOperation": { }, // structure depends on EntryPoint version
"policyId": "",
"chainId": "",
"webhookData": ""
}
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.