> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runautomat.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runautomat.com/_mcp/server.

# Authentication

## Overview

All API requests to Automat require authentication using an API key. API keys are scoped to
your organization and provide access to all extractors within that organization.

> **Warning**
>
> Keep your API keys secure! Never commit them to version control or expose them in client-side code.

## Getting Your API Key

1. Log in to the [Automat Dashboard](https://studio.runautomat.com)
2. Navigate to **Settings** → **API Keys**
3. Click **Create API Key**
4. Give your key a descriptive name (e.g., "Production Backend", "Development")
5. Copy the key immediately — it won't be shown again

> **Note**
>
> You can create multiple API keys for different environments or services. Each key can be revoked independently without
> affecting others.

## Using Your API Key

Include your API key in the `Authorization` header using the Bearer scheme:

```bash
Authorization: Bearer YOUR_API_KEY
```

### Example Request

```bash
curl -X POST https://studio.runautomat.com/api/extract \
  -H "Authorization: Bearer ak_xxxxxxxxxxxxx" \
  -F "extractorId=ext_abc123" \
  -F "file=@document.pdf"
```

## Error Handling

If authentication fails, you'll receive a `401 Unauthorized` response:

```json
{
  "error": "unauthorized",
  "message": "Invalid API key"
}
```

Common authentication errors:

| Error                        | Cause                              | Solution                        |
| ---------------------------- | ---------------------------------- | ------------------------------- |
| Missing Authorization header | No `Authorization` header provided | Add the header to your request  |
| Invalid API key              | Key doesn't exist or was revoked   | Check the key in your dashboard |
| Malformed header             | Wrong format                       | Use `Bearer YOUR_KEY` format    |

## Environment Variables

We recommend storing your API key in environment variables:

**`.env`**

```bash .env
AUTOMAT_API_KEY=ak_xxxxxxxxxxxxx
```

#### Node.js

`typescript const apiKey = process.env.AUTOMAT_API_KEY; `

#### Python

`python import os api_key = os.environ["AUTOMAT_API_KEY"] `

#### Go

`go apiKey := os.Getenv("AUTOMAT_API_KEY") `

## API Key Best Practices

#### Use Environment Variables

Never hardcode API keys in your source code

#### Rotate Regularly

Periodically generate new keys and revoke old ones

#### Separate by Environment

Use different keys for development, staging, and production

#### Monitor Usage

Review API key activity in your dashboard