# Authentication

Use a workspace API key to authenticate requests to the public Fetch Hive API.

## Authentication header

Send your API key in the `Authorization` header on every request:

```bash
Authorization: Bearer YOUR_API_KEY
```

Fetch Hive uses the same bearer header for public invoke endpoints and public resource endpoints.

## How do I create an API key? <a href="#create-api-key" id="create-api-key"></a>

Open **Settings**, then click **API Keys**.

If your workspace does not have a default key yet, click **Create Default Key**.

If you want another key for a specific service or environment, click **Add API Key**.

Choose the environment you want to use:

* **Production**
* **Staging**
* **Development**

Copy the full key when Fetch Hive shows **Your New API Key**. After that dialog closes, Fetch Hive usually only shows the key prefix.

## Example request

```bash
curl 'https://api.fetchhive.com/v1/invoke' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data-raw '{
    "deployment": "YOUR_DEPLOYMENT_NAME",
    "variant": "YOUR_VARIANT_NAME",
    "inputs": {
      "text": "Fetch Hive helps teams ship AI products faster."
    },
    "streaming": true
  }' \
  --compressed
```

## What happens when authentication fails?

If the API key is missing, invalid, or revoked, Fetch Hive returns an error response.

```json
{
  "error": "Invalid access."
}
```

See [Errors and rate limits](https://docs.fetchhive.com/api-reference/errors-and-rate-limits) for common status codes and error shapes. For API key management in the dashboard, see [API keys](https://docs.fetchhive.com/your-workspace/api-keys).
