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

# API Keys

> Generate and manage authentication keys for Roark APIs

## Overview

API keys authenticate your requests to Roark's API, enabling secure access to monitoring, testing, and analytics features.

<Note>
  API keys are essential for all integrations - whether you're using our SDKs, webhooks, or direct API calls.
</Note>

## Generating an API Key

<Steps>
  <Step title="Navigate to API Keys">
    Go to the API Keys section in your dashboard
  </Step>

  <Step title="Create New Key">
    Click the "Create API Key" button
  </Step>

  <Step title="Set Permissions">
    Choose your access level:

    * **Read-Only**: Retrieve data only
    * **Full Access**: Read and write operations
  </Step>

  <Step title="Save Securely">
    Copy and store your key immediately - it won't be shown again
  </Step>
</Steps>

<img src="https://mintcdn.com/roark/MpvpibiPGNE0-cte/images/api-key/api-key-new-modal.png?fit=max&auto=format&n=MpvpibiPGNE0-cte&q=85&s=73f5edd675bc052db2de287e97e53bc9" alt="Create API Key Modal" width="2932" height="2006" data-path="images/api-key/api-key-new-modal.png" />

## Using Your API Key

All API requests require authentication via the Authorization header:

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
  curl -X GET "https://api.roark.ai/health" \
       -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
  import requests

  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  response = requests.get("https://api.roark.ai/health", headers=headers)
  ```

  ```typescript TypeScript theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
  const response = await fetch("https://api.roark.ai/health", {
    headers: {
      "Authorization": `Bearer YOUR_API_KEY`
    }
  });
  ```

  ```javascript Node.js theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
  const axios = require('axios');

  const config = {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  };

  const response = await axios.get('https://api.roark.ai/health', config);
  ```
</CodeGroup>

## Security Best Practices

<Warning>
  Never expose your API key in client-side code, public repositories, or logs. If compromised, regenerate immediately in your dashboard.
</Warning>

<CardGroup cols={2}>
  <Card title="Environment Variables" icon="shield">
    Store keys in `.env` files or secure vaults, never hardcode them
  </Card>

  <Card title="Regular Rotation" icon="rotate-cw">
    Regenerate keys periodically to maintain security
  </Card>

  <Card title="Least Privilege" icon="lock">
    Use read-only keys when write access isn't needed
  </Card>

  <Card title="Monitor Usage" icon="activity">
    Check last-used timestamps to detect unauthorized access
  </Card>
</CardGroup>

## Common Integration Patterns

<Tabs>
  <Tab title="SDK Integration">
    Initialize SDKs with your key:

    ```javascript theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
    const roark = new RoarkClient({
      apiKey: process.env.ROARK_API_KEY
    });
    ```
  </Tab>

  <Tab title="CI/CD Pipeline">
    Store as secret in your pipeline:

    ```yaml theme={"theme":{"light":"everforest-light","dark":"everforest-dark"}}
    env:
      ROARK_API_KEY: ${{ secrets.ROARK_API_KEY }}
    ```
  </Tab>
</Tabs>

## Need Help?

<CardGroup cols={2}>
  <Card title="API Reference" icon="terminal" href="/api-reference/introduction">
    Explore all available endpoints and parameters
  </Card>

  <Card title="Integration Guides" icon="plug" href="/documentation/integrations/overview">
    Step-by-step platform integration tutorials
  </Card>
</CardGroup>
