# accountSubscribe

## accountSubscribe WebSocket Method

> Subscribe to an account to receive notifications when the lamports or data for a given account public key changes. Returns a subscription ID that can be used to unsubscribe. This method establishes a persistent WebSocket connection that will send real-time notifications whenever the specified account's state changes on the blockchain.<br>

````json
{"openapi":"3.0.3","info":{"title":"Solana WebSocket API - accountSubscribe Method","version":"1.0.0"},"tags":[{"name":"Account Subscriptions","description":"Methods related to real-time account change subscriptions via WebSocket. These methods allow you to monitor specific accounts for state changes including balance updates, data modifications, and ownership transfers.\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":{"AccountSubscribeRequest":{"type":"object","description":"Request object for subscribing to 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":["accountSubscribe"]},"params":{"type":"array","description":"Method parameters array containing the account public key and optional configuration object\n","minItems":1,"maxItems":2,"items":{"oneOf":[{"type":"string","description":"Account public key (base58 encoded)"},{"$ref":"#/components/schemas/AccountSubscribeOptions"}]}}}},"AccountSubscribeOptions":{"type":"object","description":"Optional configuration parameters for account 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"}}},"AccountNotification":{"type":"object","description":"WebSocket notification sent when a subscribed 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 an account change","enum":["accountNotification"]},"params":{"type":"object","description":"Notification parameters containing the account change data","required":["result","subscription"],"properties":{"result":{"type":"object","description":"Account change result data","properties":{"context":{"$ref":"#/components/schemas/Context"},"value":{"$ref":"#/components/schemas/AccountInfo"}}},"subscription":{"type":"integer","description":"Subscription ID that triggered this notification. Matches the ID returned from the initial accountSubscribe call.\n","minimum":0}}}}},"Context":{"type":"object","description":"Context information about when the account change occurred","required":["slot"],"properties":{"slot":{"type":"integer","description":"The slot number at which this account change notification was generated. Slots represent the fundamental unit of time in Solana.\n","minimum":0}}},"AccountInfo":{"type":"object","description":"Current state information for the account","required":["lamports","owner","executable","rentEpoch","data"],"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. The System Program (11111111111111111111111111111111) owns regular user accounts.\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 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},"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":{"parsed":{"type":"object","description":"Parsed account data specific to the program type","additionalProperties":true},"program":{"type":"string","description":"The program type that was used to parse the data"},"space":{"type":"integer","description":"The number of bytes allocated to the account"}},"additionalProperties":true}]}}},"AccountSubscribeResponse":{"type":"object","description":"Response containing the subscription ID for the account 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 account subscription. Use this ID to unsubscribe from notifications using the accountUnsubscribe 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\n- `-32001`: Account not found - The specified account does not exist\n- `-32002`: Invalid public key - The provided public key format is invalid\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":"accountSubscribe WebSocket Method","description":"Subscribe to an account to receive notifications when the lamports or data for a given account public key changes. Returns a subscription ID that can be used to unsubscribe. This method establishes a persistent WebSocket connection that will send real-time notifications whenever the specified account's state changes on the blockchain.\n","operationId":"accountSubscribe","tags":["Account Subscriptions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountSubscribeRequest"}}}},"responses":{"101":{"description":"WebSocket notification for account changes","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountNotification"}}}},"200":{"description":"Subscription successfully created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountSubscribeResponse"}}}},"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"}}}}}}}}}
````
