# programSubscribe

## programSubscribe WebSocket Method

> Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes. This method establishes a persistent WebSocket connection that will send real-time notifications whenever accounts owned by the specified program are created, modified, or deleted. You can filter results by data size, account owner, or custom criteria to only receive notifications for accounts that match your requirements.<br>

````json
{"openapi":"3.0.3","info":{"title":"Solana WebSocket API - programSubscribe Method","version":"1.0.0"},"tags":[{"name":"Program Subscriptions","description":"Methods related to real-time program account subscriptions via WebSocket. These methods allow you to monitor all accounts owned by specific programs for state changes including balance updates, data modifications, account creation and deletion. You can filter results by data size, memory comparison, or other criteria to only receive notifications for accounts that match your specific requirements.\n"}],"servers":[{"url":"wss://public.rpc.solanavibestation.com","description":"SVS Public WebSocket Node Endpoint"},{"url":"wss://basic.rpc.solanavibestation.com"},{"url":"wss://ultra.rpc.solanavibestation.com"},{"url":"wss://elite.rpc.solanavibestation.com"},{"url":"wss://epic.rpc.solanavibestation.com"},{"url":"wss://basic.swqos.solanavibestation.com"},{"url":"wss://ultra.swqos.solanavibestation.com"},{"url":"wss://elite.swqos.solanavibestation.com"}],"security":[{},{"AuthHeader":[]},{"URLParameter":[]}],"components":{"securitySchemes":{"AuthHeader":{"type":"apiKey","in":"header","name":"Authorization","description":"Authorization header for API key authentication.\n\n**Example:**\n```\nAuthorization: your-api-key-here\n```\n"},"URLParameter":{"type":"apiKey","in":"query","name":"api_key","description":"API key passed as a URL parameter for authentication.\n\n**Example:**\n```\nwss://public.rpc.solanavibestation.com/?api_key=your-api-key-here\n```\n"}},"schemas":{"ProgramSubscribeRequest":{"type":"object","description":"Request object for subscribing to program account changes via WebSocket","required":["jsonrpc","id","method","params"],"properties":{"jsonrpc":{"type":"string","description":"JSON-RPC protocol version","enum":["2.0"]},"id":{"oneOf":[{"type":"string"},{"type":"number"}],"description":"Request identifier that will be returned in the response"},"method":{"type":"string","description":"The WebSocket method name","enum":["programSubscribe"]},"params":{"type":"array","description":"Method parameters array containing the program ID and optional configuration object\n","minItems":1,"maxItems":2,"items":{"oneOf":[{"type":"string","description":"Program ID public key (base58 encoded)","pattern":"^[A-HJ-NP-Za-km-z1-9]{32,44}$"},{"$ref":"#/components/schemas/ProgramSubscribeOptions"}]}}}},"ProgramSubscribeOptions":{"type":"object","description":"Optional configuration parameters for program subscriptions","properties":{"commitment":{"type":"string","description":"Commitment level for querying the state. Higher commitment levels provide more finality but may have higher latency.\n","enum":["processed","confirmed","finalized"],"default":"finalized"},"encoding":{"type":"string","description":"Encoding format for account data. Use 'jsonParsed' for automatic parsing of known program account types.\n","enum":["base58","base64","base64+zstd","jsonParsed"],"default":"base58"},"filters":{"type":"array","description":"Filter results using various filter objects. The resultant account must meet ALL filter criteria to be included in the results.\n","items":{"$ref":"#/components/schemas/AccountFilter"}}}},"AccountFilter":{"description":"Filter criteria for program accounts","oneOf":[{"type":"object","description":"Filter accounts by data size","required":["dataSize"],"properties":{"dataSize":{"type":"integer","description":"Size of account data in bytes","minimum":0}}},{"type":"object","description":"Filter accounts by memory comparison","required":["memcmp"],"properties":{"memcmp":{"type":"object","required":["offset","bytes"],"properties":{"offset":{"type":"integer","description":"Offset into account data to start comparison","minimum":0},"bytes":{"type":"string","description":"Data to match, as base58 encoded string"}}}}}]},"ProgramNotification":{"type":"object","description":"WebSocket notification sent when a program account changes","required":["jsonrpc","method","params"],"properties":{"jsonrpc":{"type":"string","description":"JSON-RPC protocol version","enum":["2.0"]},"method":{"type":"string","description":"Notification method name indicating this is a program notification","enum":["programNotification"]},"params":{"type":"object","description":"Notification parameters containing the program account change data","required":["result","subscription"],"properties":{"result":{"type":"object","description":"Program account change result data","required":["context","value"],"properties":{"context":{"$ref":"#/components/schemas/Context"},"value":{"$ref":"#/components/schemas/ProgramAccount"}}},"subscription":{"type":"integer","description":"Subscription ID that triggered this notification. Matches the ID returned from the initial programSubscribe call.\n","minimum":0}}}}},"Context":{"type":"object","description":"Context information about when the program account change occurred","required":["slot"],"properties":{"slot":{"type":"integer","description":"The slot number at which this program account change notification was generated. Slots represent the fundamental unit of time in Solana.\n","minimum":0}}},"ProgramAccount":{"type":"object","description":"Program account information including public key and account details","required":["pubkey","account"],"properties":{"pubkey":{"type":"string","description":"Base58 encoded public key of the account that changed. This is the unique identifier for the account on the Solana blockchain.\n","pattern":"^[A-HJ-NP-Za-km-z1-9]{32,44}$"},"account":{"$ref":"#/components/schemas/AccountInfo"}}},"AccountInfo":{"type":"object","description":"Current state information for the program account","required":["lamports","owner","executable","rentEpoch","data","space"],"properties":{"lamports":{"type":"integer","description":"Number of lamports (smallest unit of SOL) assigned to this account. 1 SOL = 1,000,000,000 lamports.\n","minimum":0},"owner":{"type":"string","description":"Base58 encoded public key of the program that owns this account. This matches the program ID you subscribed to.\n","pattern":"^[A-HJ-NP-Za-km-z1-9]{32,44}$"},"executable":{"type":"boolean","description":"Boolean indicating if the account contains executable program code. Most program accounts are not executable and contain data instead.\n"},"rentEpoch":{"type":"integer","description":"The epoch at which this account will next owe rent. Accounts with sufficient balance are rent-exempt and show large epoch numbers.\n","minimum":0},"space":{"type":"integer","description":"The number of bytes allocated to the account. This determines how much data the account can store.\n","minimum":0},"data":{"description":"Data associated with the account. Format depends on the encoding parameter specified in the subscription request.\n","oneOf":[{"type":"array","description":"Binary data encoded as [data, encoding] array when using base58, base64, or base64+zstd encoding.\n","items":[{"type":"string","description":"Encoded account data"},{"type":"string","description":"Encoding format used","enum":["base58","base64","base64+zstd"]}]},{"type":"object","description":"Parsed account data when using jsonParsed encoding. Structure varies based on the account's program type.\n","properties":{"program":{"type":"string","description":"The program type that was used to parse the data"},"parsed":{"type":"object","description":"Parsed account data specific to the program type","additionalProperties":true}},"additionalProperties":true}]}}},"ProgramSubscribeResponse":{"type":"object","description":"Response containing the subscription ID for the program subscription","required":["jsonrpc","id"],"properties":{"jsonrpc":{"type":"string","description":"JSON-RPC protocol version","enum":["2.0"]},"id":{"oneOf":[{"type":"string"},{"type":"number"}],"description":"Request identifier matching the original request"},"result":{"type":"integer","description":"Unique subscription ID for this program subscription. Use this ID to unsubscribe from notifications using the programUnsubscribe method.\n","minimum":0},"error":{"$ref":"#/components/schemas/RpcError"}}},"RpcError":{"type":"object","description":"Standard JSON-RPC error object","required":["code","message"],"properties":{"code":{"type":"integer","description":"Numeric error code following JSON-RPC 2.0 specification:\n- `-32700`: Parse error - Invalid JSON was received\n- `-32600`: Invalid request - The JSON sent is not a valid request object\n- `-32601`: Method not found - The method does not exist\n- `-32602`: Invalid params - Invalid method parameter(s)\n- `-32603`: Internal error - Internal JSON-RPC error\n- `-32000`: Server error - WebSocket connection issues or subscription limits\n- `-32001`: Invalid program ID - The provided program ID format is invalid\n- `-32002`: Invalid filter - Filter criteria is malformed or unsupported\n"},"message":{"type":"string","description":"Human-readable error message describing the error"},"data":{"type":"object","description":"Additional structured error information (optional). May contain specific details about what caused the error.\n","additionalProperties":true}}},"ErrorResponse":{"type":"object","description":"JSON-RPC error response for failed requests","required":["jsonrpc","error","id"],"properties":{"jsonrpc":{"type":"string","description":"JSON-RPC protocol version","enum":["2.0"]},"error":{"$ref":"#/components/schemas/RpcError"},"id":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"null"}],"description":"Request identifier from the original request, or null if the request was malformed and no ID could be extracted."}}}}},"paths":{"/":{"post":{"summary":"programSubscribe WebSocket Method","description":"Subscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes. This method establishes a persistent WebSocket connection that will send real-time notifications whenever accounts owned by the specified program are created, modified, or deleted. You can filter results by data size, account owner, or custom criteria to only receive notifications for accounts that match your requirements.\n","operationId":"programSubscribe","tags":["Program Subscriptions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProgramSubscribeRequest"}}}},"responses":{"101":{"description":"WebSocket notification for program account changes","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProgramNotification"}}}},"200":{"description":"Subscription successfully created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProgramSubscribeResponse"}}}},"400":{"description":"Bad Request - Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"text/plain":{"schema":{"type":"string"}}}},"403":{"description":"Forbidden","content":{"text/plain":{"schema":{"type":"string"}}}},"429":{"description":"Too Many Requests","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"text/plain":{"schema":{"type":"string"}}}}}}}}}
````
