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

# API Keys

> Create and manage API keys for authenticating with the Gumnut API

# API Keys

API keys are the simplest way to authenticate with Gumnut. They're ideal for server-side applications, scripts, automation, and CI/CD pipelines.

## Creating an API Key

1. Log into the [Gumnut Dashboard](https://app.gumnut.ai)
2. Navigate to **API Keys**
3. Click **Create API Key**
4. Name your key descriptively (e.g., "Production Server", "Development")
5. Choose what the key is allowed to do:
   * **View only**
   * **View, add, and edit**
   * **View, add, edit, and move to trash** (the default)
   * **Full access** — also permits permanent deletion
6. Choose which libraries it can reach — **All current and future libraries**,
   or **Selected libraries** (only the ones you pick; new libraries aren't
   added automatically)
7. Copy and securely store the key

Scope each key to the least authority the integration needs. Creating keys
through the REST API additionally lets you combine actions freely rather than
picking one of the presets above — `read` is always required, and at least one
action must be set.

<Warning>
  API keys are shown only once when created. Store them securely in environment variables or a secrets manager. Never commit API keys to version control.
</Warning>

## Using API Keys

Include your API key in the `Authorization` header as a Bearer token:

```bash theme={null}
curl -X GET https://api.gumnut.ai/api/assets \
  -H "Authorization: Bearer apikey_your_api_key_here"
```

### TypeScript SDK

```typescript theme={null}
import Gumnut from 'gumnut-sdk';

const client = new Gumnut({
  apiKey: process.env.GUMNUT_API_KEY
});
```

### Python SDK

```python theme={null}
import os
from gumnut import Gumnut

client = Gumnut(
    api_key=os.environ.get("GUMNUT_API_KEY")
)
```

### Node.js with axios

```javascript theme={null}
import axios from 'axios';

const gumnutApi = axios.create({
  baseURL: 'https://api.gumnut.ai',
  headers: {
    Authorization: `Bearer ${process.env.GUMNUT_API_KEY}`,
  },
});

const { data } = await gumnutApi.get('/api/assets');
console.log(data);
```

## Managing Keys

View and manage API keys in the [dashboard](https://app.gumnut.ai):

* See creation date and last used time
* Track usage statistics
* Revoke keys instantly

## Error Handling

**401 Unauthorized** — Invalid or expired API key:

```json theme={null}
{
  "error": "unauthorized",
  "message": "Invalid or expired token"
}
```

Solutions:

* Verify the key is copied correctly (should start with `apikey_`)
* Check it hasn't been revoked in the dashboard
* Ensure you're using the correct environment's key

**403 Forbidden** — Insufficient permissions:

```json theme={null}
{
  "error": "forbidden",
  "message": "Insufficient permissions for this operation"
}
```

**429 Too Many Requests** — Rate limit exceeded. See [Rate Limiting](/guides/apis/rate-limiting) for details.
