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:
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
Bearer authentication of the form Bearer <token>, where token is your auth token.
Request
Name of the policy
Type of the policy (e.g. “sponsorship”). Currently we support sponsorship
(for EVM network policies) and solana
(for Solana network policies).
ID for the app associated with the new policy. Learn how to find your app ID here.
Networks for the policy. Example: ETH_MAINNET
. For Solana policies, valid values are SOLANA_MAINNET
and SOLANA_DEVNET
.
Rules for sponsorship
policy type. Empty if policyType
is not sponsorship
.
Response
Policy created successfully