> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# programSubscribe

> Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes.

## Endpoints

Websockets are available on mainnet and devnet with the following URLs:

* **Mainnet** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **Devnet** `wss://devnet.helius-rpc.com/?api-key=<api-key>`

<Note>Websockets have a 10-minute inactivity timer; implementing health checks and sending pings every minute is heavily recommended to keep the websocket connection alive.</Note>

## Authorizations

<ParamField query="api-key" type="string" required>
  Your Helius API key. You can get one for free in the [dashboard](https://dashboard.helius.dev/api-keys).
</ParamField>

## Body

<ParamField body="params" type="array" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="programId" type="string" required>
      Pubkey of the `program_id`, as base-58 encoded string.
    </ParamField>

    <ParamField body="config" type="object">
      Configuration object containing the following fields:

      <ParamField body="commitment" type="string">
        The commitment level for the subscription. Can be `finalized`, `confirmed`, or `processed`.
      </ParamField>

      <ParamField body="filters" type="array">
        Array of filter objects to apply.
      </ParamField>

      <ParamField body="encoding" type="string">
        Encoding format for account data. Can be `base58`, `base64`, `base64+zstd`, or `jsonParsed`.

        * `base58` is slow
        * `jsonParsed` encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data
        * If `jsonParsed` is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the data field is type string.
      </ParamField>
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="result" type="integer">
  Subscription id (needed to unsubscribe)
</ResponseField>

## Notification Format

The notification format is a **single** program account object as seen in the `getProgramAccounts` RPC HTTP method.

<RequestExample>
  ```json Request theme={"system"}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "programSubscribe",
    "params": [
      "11111111111111111111111111111111",
      {
        "encoding": "base64",
        "filters": [{ "dataSize": 80 }]
      }
    ]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={"system"}
  {
    "jsonrpc": "2.0",
    "result": 24040,
    "id": 1
  }
  ```

  ```json Notification (base58) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "programNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5208469
        },
        "value": {
          "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq",
          "account": {
            "data": [
              "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR",
              "base58"
            ],
            "executable": false,
            "lamports": 33594,
            "owner": "11111111111111111111111111111111",
            "rentEpoch": 636,
            "space": 80
          }
        }
      },
      "subscription": 24040
    }
  }
  ```

  ```json Notification (jsonParsed) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "programNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5208469
        },
        "value": {
          "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq",
          "account": {
            "data": {
              "program": "nonce",
              "parsed": {
                "type": "initialized",
                "info": {
                  "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX",
                  "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k",
                  "feeCalculator": {
                    "lamportsPerSignature": 5000
                  }
                }
              }
            },
            "executable": false,
            "lamports": 33594,
            "owner": "11111111111111111111111111111111",
            "rentEpoch": 636,
            "space": 80
          }
        }
      },
      "subscription": 24040
    }
  }
  ```
</ResponseExample>
