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

# Add Auth to an HTTP Server

> Protect an HTTP Redop server with the built-in apiKey plugin.

This tutorial shows the quickest way to add auth to a hosted Redop server.

## What you will add

* header-based auth with a built-in plugin
* protected HTTP tools
* a client call that includes the expected header

## Step 1: Add the plugin

```ts theme={null}
import { apiKey, Redop } from "@redopjs/redop";

new Redop({ serverInfo: { name: "auth-demo" } })
  .use(
    apiKey({
      key: process.env.API_SECRET ?? "dev-secret",
    }),
  )
  .tool("ping", {
    handler: () => ({ ok: true }),
  });
```

## Step 2: Call the tool with the header

Send the header your plugin expects:

```txt theme={null}
x-api-key: dev-secret
```

## Step 3: Keep advanced config optional

If you need to change where the validated value is stored on `ctx`, use `contextKey`. Most servers can ignore that option.

## Next

* [API key authentication](/docs/guides/authentication/api-key)
* [JWT authentication](/docs/guides/authentication/jwt)
* [Build a plugin or middleware](/docs/guides/build-plugin-or-middleware)
* [Debug HTTP connections and sessions](/docs/guides/debug-http)
