> For the complete documentation index, see [llms.txt](https://docs.validationcloud.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.validationcloud.io/v1/solana/websocket-stable-methods/programsubscribe.md).

# programSubscribe

(Subscription Websocket) Subscribe to a program to receive notifications when the lamports or data for a given account owned by the program changes.

This method will use `20` [Compute Units](/v1/about/billing.md).

***

## **Parameters**

* `program_id` string. The Pubkey encoded base-58 string.
* `object` *optional.* Configuration object containing the following fields:
  * `commitment` string. The level of commitment required for the query. The options include:
    * `finalized` string. The node will query the most recent block confirmed by the supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.
    * `confirmed` string. The node will query the most recent block that has been voted on by the supermajority of the cluster.
    * `processed` string. The node will query its most recent block. Note that the block may not be complete.
* `encoding` string. The encoding format for account data. It can be one of base58 (slow), base64, base64+zstd or jsonParsed.
* `filters` string. The filter results using various filter objects; The account must meet all filter criteria to be included in results.

## Returns

`result` The result will be an RpcResponse JSON object with id equal to the subscription id (needed to unsubscribe).

`Notification Format:` The notification format is the same as seen in the getProgramAccounts RPC HTTP method.

```bash
// Result
{ "jsonrpc": "2.0", "result": 24040, "id": 1 }
```

{% tabs %}
{% tab title="mainnet" %}

<pre class="language-bash"><code class="lang-bash"><strong>wscat -c wss://mainnet.solana.validationcloud.io/v1/&#x3C;YOUR_API_KEY_HERE>
</strong># wait for connection
{"jsonrpc": "2.0", "id": 1,"method": "programSubscribe","params": ["11111111111111111111111111111111", {"encoding": "base64", "commitment": "finalized"}]}
    
</code></pre>

{% endtab %}

{% tab title="devnet" %}

```bash
wscat -c wss://devnet.solana.validationcloud.io/v1/<YOUR_API_KEY_HERE>
# wait for connection
{"jsonrpc": "2.0", "id": 1,"method": "programSubscribe","params": ["11111111111111111111111111111111", {"encoding": "base64", "commitment": "finalized"}]}
    
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.validationcloud.io/v1/solana/websocket-stable-methods/programsubscribe.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
