Does WebSocket connection use authorization headers?

Last updated: August 25, 2026

Yes. Alchemy WebSocket connections support authentication via an HTTP Authorization header, in addition to the standard URL-embedded API key.

Option 1: API key in the URL

The default and simplest setup embeds your API key directly in the WebSocket URL:

wss://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY

Option 2: Authorization header

WebSocket connections also accept a bearer token in the Authorization header, using either your API key or an access key:

wscat -c wss://eth-mainnet.g.alchemy.com/v2/ -H 'Authorization: Bearer YOUR-API-KEY'

This works the same way as sending an API key or access key in the Authorization header for HTTP requests.

Related docs