---
title: Get an API Key
description: Get your application's API key, configure it safely in your program, and rotate it when needed.
type: guide
status: stable
updated: 2026-12-03
url: /en/docs/authentication
markdown: /en/docs/authentication.md
---

## Data Access Path

Recommended reading order, not a record of completed steps. Optional steps can be skipped.

1. [Get an API Key](/en/docs/authentication) ← current page
2. [Make Your First Query in 5 Minutes](/en/docs/quickstart)
3. [Keyword Search](/en/docs/search)
4. [Browse by User, Topic, Tag & Category](/en/docs/browse) (optional)
5. [Read Content & Versions](/en/docs/documents)
6. [Download Images & Attachments](/en/docs/attachments) (optional)
7. [Production Checklist](/en/docs/production)

**Before You Start**：Have an organization account or contact its administrator; with an existing key, configure the environment without signing into the console again.

# Get an API Key

By the end of this page you will have an API key and have configured it safely.

Each API key belongs to an **application**, not to a person. It only calls the API; it can't sign in to the console.

## Get a key [#get]

| Your situation | What to do |
| --- | --- |
| You are an owner or admin of the organization | Sign in to the [console](/en/portal), pick or create an application, and generate a key under "Application keys" |
| You don't have admin rights | Tell your organization admin which platforms, fields and use you need, and ask them to send you a key securely |
| You already have a key | Go to the next section |

The full key is shown only once, when it's created. Save it right away.

## Configure it in your program [#configure]

All examples use two environment variables: `WHALE_BASE_URL` and `WHALE_API_KEY`.

Type the key in interactively so it doesn't end up in your shell history:


```bash
export WHALE_BASE_URL="https://www.marsyoo.com"
read -r -s -p "API Key: " WHALE_API_KEY
printf '\n'
export WHALE_API_KEY
```


On servers, inject it from a secret manager, key vault or protected environment variable.

Send the key in the request header:


```http
Authorization: Bearer whale_consumer_xxx
```


> Note: Never put the key in source code, images, front-end pages or URL parameters. Log only the key prefix.

Then check it works with [your first query](/en/docs/quickstart).

## Try it in the browser first [#playground]

You can try the API without code in the [Playground](/en/playground):

1. Sign in, then choose an application and key.
2. Choose **History**.
3. Click **Run request**.

- Without signing in you only see example data, marked as such.
- Existing keys can't be shown again. Paste the full key, or ask someone with rights to generate a test key.
- Auto mode may generate a test key when none is available.
- Real requests are billed like any other call.

## See what you can read [#access]

Your application's **access** decides which platforms and fields a key can read. See the current access and call limits on the application's "Access limits" page in the console.

- New applications follow the organization's settings by default.
- An application can be narrowed within the organization's access, never widened.
- A new key doesn't change permissions.

To widen access, ask your organization admin to contact us. See [Console](/en/docs/portal).

## Rotate and revoke [#rotate]

- Use a separate key for each environment and each external system, so you can trace and revoke them.
- To rotate: create a new key, switch traffic to it, then revoke the old one.
- If you suspect a leak, revoke the key in the console immediately and contact us.

## When something fails [#errors]

An invalid key returns `401`; a request outside your access returns `403`. Full list: [Error codes](/en/docs/errors).

## Check and Continue

**Completion Check**：Confirm effective application platforms and fields, receive a Consumer Key securely and configure your environment; never paste secrets into agent conversations.

**Recommended Next Step**：[Make Your First Query in 5 Minutes](/en/docs/quickstart)
