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

# Authentication

> Authenticate your WebSocket connection with an API key issued in the customer portal.

Every connection to the stream authenticates with an API key issued in the metar.ws portal. There are two equivalent ways to present it.

## Presenting the key

<Tabs>
  <Tab title="Query parameter">
    Append the key as a query parameter on the WebSocket URL. This is the only option available to the browser `WebSocket` API.

    ```text theme={null}
    wss://stream.metar.ws/v1/ws?key=mts_live_YOUR_KEY
    ```
  </Tab>

  <Tab title="Authorization header">
    Send the key as a bearer token on the HTTP upgrade request. This keeps the key out of URLs and access logs, and works with any client that lets you set headers on the upgrade request.

    ```text theme={null}
    Authorization: Bearer mts_live_YOUR_KEY
    ```
  </Tab>
</Tabs>

## Managing keys

Keys are created, listed, renamed and revoked from the Keys page in the portal. Revoking a key is enforced by the stream layer immediately: any open connection using a revoked key is closed within a second.

<Warning>
  Your API key is your only credential. Do not commit it to a repository or ship it inside client-side code you distribute publicly. If you suspect a key has leaked, revoke it and create a new one.
</Warning>

<Card title="Next: Sandbox Mode" icon="flask" href="/sandbox-mode">
  See what you can build before upgrading to a paid plan.
</Card>
