# Get All Policies

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

GET https://manage.g.alchemy.com/api/gasManager/policies

Returns all policies. The results are paginated.

<Note title="Header Access Token">
  To call this endpoint, you must use your [access token](/docs/how-to-create-access-keys) in the [authorization header](/docs/how-to-use-api-keys-in-http-headers) of the API request. 
</Note>


Reference: https://www.alchemy.com/docs/wallets/api-reference/gas-manager-admin-api/admin-api-endpoints/get-all-policies

## Headers

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Authorization | string | Yes | Bearer authentication token |

## Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| appId | string | No | An optional app id to filter results by policies associated with that app.  |
| limit | integer | No | An optional parameter to limit the number of results per page. |
| before | string | No | String - used for pagination. If there are previous results, `before` field is returned in the response and can be passed in the request to fetch the previous page. |
| after | string | No | String - used for pagination. If more results are available `after` field is returned in the response and can be passed in the request to fetch the next page. |
| nameFilter | string | No | Optional case-insensitive policy name filter. |

## Code Examples

### cURL

```bash
curl --request GET \
  --url https://manage.g.alchemy.com/api/gasManager/policies \
  --header 'Authorization: Bearer <token>'
```

### JavaScript

```javascript
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://manage.g.alchemy.com/api/gasManager/policies', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://manage.g.alchemy.com/api/gasManager/policies"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://manage.g.alchemy.com/api/gasManager/policies"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.get("https://manage.g.alchemy.com/api/gasManager/policies")
  .header("Authorization", "Bearer <token>")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://manage.g.alchemy.com/api/gasManager/policies");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /api/gasManager/policies
method: GET
operation:
  summary: Get All Policies
  description: |
    Returns all policies. The results are paginated.

    <Note title="Header Access Token">
      To call this endpoint, you must use your [access token](/docs/how-to-create-access-keys) in the [authorization header](/docs/how-to-use-api-keys-in-http-headers) of the API request. 
    </Note>
  operationId: get-all-policies
  security:
    - BearerAuth: []
  parameters:
    - name: appId
      in: query
      description: |
        An optional app id to filter results by policies associated with that app.
      schema:
        type: string
        default: 6d834x9k1yh4dx6z
    - name: limit
      in: query
      description: An optional parameter to limit the number of results per page.
      schema:
        type: integer
        default: 10
        maximum: 50
    - name: before
      in: query
      description: String - used for pagination. If there are previous results, `before` field is returned in the response and can be passed in the request to fetch the previous page.
      schema:
        type: string
    - name: after
      in: query
      description: String - used for pagination. If more results are available `after` field is returned in the response and can be passed in the request to fetch the next page.
      schema:
        type: string
    - name: nameFilter
      in: query
      description: Optional case-insensitive policy name filter.
      schema:
        type: string
  responses:
    '200':
      description: Policies fetched successfully
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                type: object
                properties:
                  policies:
                    type: array
                    items:
                      type: object
                      properties:
                        policyId:
                          type: string
                          description: String ID of the policy
                          default: '0x1234567890abcdef'
                        appId:
                          type: string
                          description: String ID of the app
                          default: '0x1234567890abcdef'
                        status:
                          type: string
                          enum:
                            - active
                            - inactive
                            - pending_approval
                            - rejected
                          description: Status of the policy.
                        rules:
                          description: Rules for `sponsorship` and `bundler_sponsorship` policy types. Empty if `policyType` is not `sponsorship` or `bundler_sponsorship`.
                          type: object
                          properties:
                            maxSpendUsd:
                              type: number
                              description: Maximum amount of USD that can be sponsored
                              default: 5000
                            maxSpendPerSenderUsd:
                              type: number
                              description: Maximum amount of USD that can be sponsored for a single sender (not enforced on testnets)
                              default: 100
                            maxSpendPerUoUsd:
                              type: number
                              description: Maximum amount of USD that can be sponsored for a single userOperation (not enforced on testnets)
                              default: 20
                            maxCount:
                              type: integer
                              description: Maximum number of userOperations that can be sponsored
                              default: 100
                            maxCountPerSender:
                              type: integer
                              description: Maximum number of userOperations that can be sponsored for a single sender
                              default: 2
                            senderAllowlist:
                              type: array
                              items:
                                type: string
                              description: List of addresses that are eligible for sponsorship
                              default:
                                - '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
                                - '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
                            senderBlocklist:
                              type: array
                              items:
                                type: string
                              description: List of addresses that are banned from receiving sponsorship
                            startTimeUnix:
                              type: string
                              description: Unix timestamp of when the policy starts
                              default: '1674228753'
                            endTimeUnix:
                              type: string
                              description: Unix timestamp of when the policy ends
                              default: '1679340742'
                            sponsorshipExpiryMs:
                              type: string
                              description: Milliseconds after the sponsorship is issued that it expires
                              default: '600000'
                            webhookRules:
                              type: object
                              description: Enable conditional gas sponsorship by making a request to your server to verify sponsorship eligibility
                              properties:
                                webhookUrl:
                                  type: string
                                  format: uri
                                  description: The URL to call to verify sponsorship eligibility.
                                  example: https://dashboard.alchemy.com/gas-manager/policy/create
                                approveOnFailure:
                                  type: boolean
                                  description: If true, the userOp will be sponsored in the event on an error or timeout.
                                  default: false
                              required:
                                - webhookUrl
                                - approveOnFailure
                          required:
                            - startTimeUnix
                        policyName:
                          type: string
                          description: Name of the policy
                          default: Gas Manager Policy
                        lastUpdatedUnix:
                          type: string
                          description: Unix timestamp of when the policy was last updated
                          default: '1674228753'
                        policyVersion:
                          type: integer
                          description: Version of the policy
                          default: 0
                        policyType:
                          description: Type of the policy.
                          type: string
                          enum:
                            - sponsorship
                            - bundler_sponsorship
                            - erc20
                            - solana
                          default: sponsorship
                        policyState:
                          type: string
                          description: State of the policy
                          default: ongoing
                        networks:
                          type: array
                          items:
                            type: string
                          description: List of networks the policy is active on
                        gasPumpId:
                          type: string
                          description: Gas pump id
                        erc20Rules:
                          description: Erc20 rules for policy. Empty if `policyType` is not `erc20`.
                          allOf:
                            - type: object
                              properties:
                                maxSpendUsd:
                                  type: number
                                  description: Maximum amount of USD that can be sponsored
                                  default: 5000
                                maxSpendPerSenderUsd:
                                  type: number
                                  description: Maximum amount of USD that can be sponsored for a single sender (not enforced on testnets)
                                  default: 100
                                maxSpendPerUoUsd:
                                  type: number
                                  description: Maximum amount of USD that can be sponsored for a single userOperation (not enforced on testnets)
                                  default: 20
                                maxCount:
                                  type: integer
                                  description: Maximum number of userOperations that can be sponsored
                                  default: 100
                                maxCountPerSender:
                                  type: integer
                                  description: Maximum number of userOperations that can be sponsored for a single sender
                                  default: 2
                                senderAllowlist:
                                  type: array
                                  items:
                                    type: string
                                  description: List of addresses that are eligible for sponsorship
                                  default:
                                    - '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
                                    - '0x70997970c51812dc3a010c7d01b50e0d17dc79c8'
                                senderBlocklist:
                                  type: array
                                  items:
                                    type: string
                                  description: List of addresses that are banned from receiving sponsorship
                                startTimeUnix:
                                  type: string
                                  description: Unix timestamp of when the policy starts
                                  default: '1674228753'
                                endTimeUnix:
                                  type: string
                                  description: Unix timestamp of when the policy ends
                                  default: '1679340742'
                                sponsorshipExpiryMs:
                                  type: string
                                  description: Milliseconds after the sponsorship is issued that it expires
                                  default: '600000'
                                webhookRules:
                                  type: object
                                  description: Enable conditional gas sponsorship by making a request to your server to verify sponsorship eligibility
                                  properties:
                                    webhookUrl:
                                      type: string
                                      format: uri
                                      description: The URL to call to verify sponsorship eligibility.
                                      example: https://dashboard.alchemy.com/gas-manager/policy/create
                                    approveOnFailure:
                                      type: boolean
                                      description: If true, the userOp will be sponsored in the event on an error or timeout.
                                      default: false
                                  required:
                                    - webhookUrl
                                    - approveOnFailure
                              required:
                                - startTimeUnix
                            - type: object
                              properties:
                                tokens:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      network:
                                        type: string
                                        description: Network of the Erc20 token
                                      tokenAddress:
                                        type: string
                                        description: Erc20 token contract address
                                      priceReferenceNetwork:
                                        type: string
                                        description: Network of the token used as a price reference to calculate an ERC-20 token's conversion rate. Required together with `priceReferenceTokenAddress` for testnet tokens. For mainnet tokens, omit both fields to use the payment token's supported price, or provide both fields to use a price reference instead. Choose a reference token with the same number of decimals as the payment token.
                                      priceReferenceTokenAddress:
                                        type: string
                                        description: Contract address of the token on `priceReferenceNetwork` used as a price reference to calculate an ERC-20 token's conversion rate. Required together with `priceReferenceNetwork` for testnet tokens. For mainnet tokens, omit both fields to use the payment token's supported price, or provide both fields to use a price reference instead. Choose a reference token with the same number of decimals as the payment token.
                                    required:
                                      - network
                                      - tokenAddress
                                  description: Erc20 tokens allowed under this policy.
                                recipientAddress:
                                  type: string
                                  description: Wallet address that will receive the tokens paid by users. Please ensure that you own this address across all networks enabled under this policy.
                                usePostOp:
                                  type: boolean
                                  description: |
                                    Erc20 transfer mode
                                    - [Recommended] True: The user pays for the gas after the userOp execution. Enables the user to allow the paymaster contract to spend the ERC-20 token on their behalf (`approve()`) without a separate tx, improving ux. If the transfer fails, the userOp will revert but you’ll remain liable for the gas costs.
                                    - False: The user pays for the gas before the userOp execution. Requires the paymaster contract to have allowance onchain before the userOp gets submitted. If the allowance doesn’t exist, the userOp will fail immediately.
                                priceMultiplier:
                                  type: number
                                  default: 1
                                  description: |
                                    Adjust the Erc20 amount the user pays. For example:
                                    - `1.1` means that the user pays 10% more (you monetize gas payments)
                                    - `0.95` means that the user pays 5% less (you partially sponsor gas)
                              required:
                                - tokens
                                - recipientAddress
                                - usePostOp
                        solanaRules:
                          description: Solana rules for policy. Empty if `policyType` is not `solana`.
                          type: object
                          properties:
                            maxSpendUsd:
                              type: number
                              description: Maximum amount of USD that can be sponsored
                              default: 6500
                            maxSpendPerTxnUsd:
                              type: number
                              description: Maximum amount of USD that can be sponsored per transaction (not enforced on testnet)
                              default: 30
                            maxCount:
                              type: integer
                              description: Maximum number of transactions that can be sponsored
                              default: 200
                            startTimeUnix:
                              type: string
                              description: Unix timestamp of when the policy starts
                              default: '1674228753'
                            endTimeUnix:
                              type: string
                              description: Unix timestamp of when the policy ends
                              default: '1679340742'
                          required:
                            - startTimeUnix
                      required:
                        - policyId
                        - appId
                        - status
                  before:
                    type: string
                    description: String - used for pagination. If there are previous results, `before` field is returned in the response and can be passed in the request to fetch the previous page. Can be null if there are no previous results. Can be null if there are no previous results.
                  after:
                    type: string
                    description: String - used for pagination. If more results are available `after` field is returned in the response and can be passed in the request to fetch the next page. Can be null if there are no more results.
```
