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

# Authentication

> Learn how to authenticate your API requests to the Artaios Multi-Agent System

## Overview

The AMAS API uses API keys to authenticate requests. All API requests must include your API key in the `x-api-key` header.

<Warning>
  Keep your API keys secure! Do not share your API keys in publicly accessible areas such as GitHub, client-side code, or in your application's source code.
</Warning>

## API Key Authentication

Include your API key in the `x-api-key` header with every request:

```bash theme={null}
x-api-key: YOUR_API_KEY
```

API keys are generated in the settings of the Artaios Agent Studio with an expiration date and can be invalidated when needed.

## Usage Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.artaios.ai/api/v1/agent/validate/ \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "My Agent",
      "agent_type": "llm_agent",
      "system_prompt": "You are a helpful assistant.",
      "llm_config": {"model": "gpt-4o"}
    }'
  ```

  ```python Python theme={null}
  import requests

  headers = {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
  }

  config = {
      "name": "My Agent",
      "agent_type": "llm_agent",
      "system_prompt": "You are a helpful assistant.",
      "llm_config": {"model": "gpt-4o"}
  }

  response = requests.post(
      'https://api.artaios.ai/api/v1/agent/validate/',
      json=config,
      headers=headers
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const config = {
    name: "My Agent",
    agent_type: "llm_agent",
    system_prompt: "You are a helpful assistant.",
    llm_config: {model: "gpt-4o"}
  };

  const response = await fetch('https://api.artaios.ai/api/v1/agent/validate/', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(config)
  });

  const result = await response.json();
  ```
</CodeGroup>

## API Key Management

Contact your administrator or use the dashboard to manage your API keys.

<Warning>
  API keys are generated with an expiration date. Make sure to rotate your keys before they expire to avoid service interruptions.
</Warning>

## Best Practices

<CardGroup cols={2}>
  <Card title="Environment Variables" icon="leaf">
    Store API keys and tokens as environment variables rather than hardcoding them in your application.
  </Card>

  <Card title="Key Rotation" icon="rotate">
    Regularly rotate your API keys, especially after team member departures or suspected compromise.
  </Card>

  <Card title="Expiration Monitoring" icon="clock">
    Monitor API key expiration dates and rotate keys before they expire to avoid service interruptions.
  </Card>

  <Card title="Secure Storage" icon="shield">
    Never commit API keys to version control. Use secret management tools in production.
  </Card>
</CardGroup>

## Authentication Errors

### 401 Unauthorized

Invalid or expired authentication credentials:

```json theme={null}
{
  "error": {
    "type": "authentication_error",
    "message": "Invalid or missing authentication credentials"
  }
}
```

### 403 Forbidden

Insufficient permissions to access the resource:

```json theme={null}
{
  "error": {
    "type": "permission_error",
    "message": "You do not have permission to access this resource"
  }
}
```

### Expired API Key

```json theme={null}
{
  "error": {
    "type": "authentication_error",
    "message": "API key has expired"
  }
}
```
