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

# Authentication

> How to create a Brew API key, bind it to a brand, store it securely, and validate it works. Covers environment variable setup and SDK client creation.

## Overview

The Brew SDK uses the same API keys as the raw REST API.

Every request is authenticated with your Brew API key. The SDK sends
it as `Authorization: Bearer brew_your_api_key` for you. The server
also accepts the alternate `X-API-Key: brew_your_api_key` header for
raw HTTP callers, but the SDK standardizes on Bearer to keep one
canonical wire format.

**Each API key is bound to exactly one brand** at creation time, so
the SDK never asks you to pass a `brandId` for any endpoint. The Brew
API does not accept `brandId` anywhere in a request body or query —
sending one returns `400 INVALID_REQUEST`. To act on a different
brand, switch brands in the dashboard and create a new key. See the
[API introduction](/api-reference/api/api-introduction#brand-scoping)
for the full breakdown of brand-scoped vs. organization-wide endpoints
and the permission scopes (`contacts`, `emails`, `all`) each route
requires.

## Get Your API Key

<Steps>
  <Step title="Open the API settings page">
    Go to [brew.new/settings/api](https://brew.new/settings/api).
  </Step>

  <Step title="Pick the brand">
    Make sure the brand active in the dashboard is the one you want
    this key to act on. Each key is permanently bound to one brand at
    creation; you cannot retarget it later.
  </Step>

  <Step title="Create a key">
    Create a new API key and copy it somewhere safe.
  </Step>

  <Step title="Store it in your environment">
    Keep it server-side. Do not commit it or expose it in frontend code.
  </Step>
</Steps>

## Recommended Setup

Use an environment variable in your own app code:

```bash theme={null}
export BREW_API_KEY="brew_your_api_key"
```

Then create the SDK client with that value:

```ts theme={null}
import { createBrewClient } from '@brew.new/sdk'

const brew = createBrewClient({
  apiKey: process.env.BREW_API_KEY!,
})
```

## Validate The Key

Use a simple read call to make sure the key works:

```ts theme={null}
const { data: domains } = await brew.domains.list()
console.log(domains)
```

A bad key returns `401 INVALID_API_KEY`. See [TypeScript Error Handling](/sdks/typescript/error-handling) for the full error catch pattern.

## Security Notes

* Keep API keys on the server only.
* Use different keys for development and production.
* Rotate keys if you think one was exposed.
* Log the `x-request-id` from failed calls when debugging.

## Next Steps

<CardGroup cols="2">
  <Card title="TypeScript Installation" icon="download" href="/sdks/typescript/installation">
    Install and configure `@brew.new/sdk`.
  </Card>

  <Card title="API Introduction" icon="book" href="/api-reference/api/api-introduction">
    See the raw public API contract.
  </Card>
</CardGroup>

## Need Help?

Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:

<Tabs>
  <Tab title="Self-Service Tools">
    <CardGroup cols="2">
      <Card title="Search Documentation" icon="magnifying-glass" color="#c44925">
        Type in the "Ask any question" search bar at the top left to instantly find relevant documentation pages.
      </Card>

      <Card title="ChatGPT/Claude Integration" icon="robot" color="#c44925">
        Click "Open in ChatGPT" at the top right of any page to analyze documentation with ChatGPT or Claude for deeper insights.
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Talk to Our Team">
    <CardGroup cols="2">
      <Card title="Schedule a Call" icon="calendar" color="#c44925" href="https://calendar.google.com/calendar/u/0/appointments/schedules/AcZssZ1iYoRUG1J792XQpbuQLjSRRDupr7MwraFK-HQRCtTYdBmrQi8nZu2qXfzKQigb8gbKJK3KN3-R">
        Book time with our founders for personalized guidance on strategy, best practices, or complex implementation questions.
      </Card>

      <Card title="Call Us Directly" icon="phone" color="#c44925">
        Need immediate assistance? Reach us at **+1-(332)-203-2145** for urgent issues or time-sensitive questions.
      </Card>

      <Card title="Slack Channel" icon="slack" color="#c44925">
        Our preferred support channel. You'll receive an invite after signup for direct founder support and fast responses.
      </Card>

      <Card title="Email Support" icon="envelope" color="#c44925" href="mailto:support@brew.new">
        Contact us at **[support@brew.new](mailto:support@brew.new)** for detailed inquiries or if you prefer not to use Slack.
      </Card>
    </CardGroup>
  </Tab>
</Tabs>
