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

# Authentication Overview

> Learn how authentication works with the agntdata API.

## Bearer Token Authentication

All agntdata API endpoints require authentication via Bearer tokens. Include your API key in the `Authorization` header of every request:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## How It Works

<Steps>
  <Step title="Generate an API Key">
    Create an API key from the [dashboard](https://app.agntdata.dev/dashboard). Each key is tied to a workspace and has its own credit balance.
  </Step>

  <Step title="Include in Requests">
    Pass the API key as a Bearer token in the Authorization header. The API validates the key and checks your credit balance.
  </Step>

  <Step title="Credits Deducted">
    Successful requests deduct credits from your workspace balance. The response includes your remaining credits.
  </Step>
</Steps>

## Request Example

```bash theme={null}
curl -X GET "https://api.agntdata.dev/v1/data/linkedin/get-company-details?username=microsoft" \
  -H "Authorization: Bearer agnt_live_abc123..."
```

## Security Best Practices

<AccordionGroup>
  <Accordion title="Keep Keys Secret">
    Never expose API keys in client-side code, public repositories, or logs. Treat them like passwords.
  </Accordion>

  <Accordion title="Use Environment Variables">
    Store API keys in environment variables rather than hardcoding them:

    ```bash theme={null}
    export AGNTDATA_API_KEY=agnt_live_abc123...
    ```
  </Accordion>

  <Accordion title="Rotate Keys Regularly">
    Periodically rotate your API keys, especially if you suspect they may have been compromised.
  </Accordion>

  <Accordion title="Use Separate Keys for Environments">
    Create separate API keys for development, staging, and production environments.
  </Accordion>
</AccordionGroup>

## API Key Format

API keys follow the format `agnt_live_` followed by a unique identifier:

```
agnt_live_abc123def456ghi789...
```

The `agnt_live_` prefix indicates a production key. All keys are 32+ characters for security.

## Error Responses

Invalid or missing authentication returns a `401 Unauthorized` response:

```json theme={null}
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or missing API key"
  }
}
```

Common authentication errors:

| Error Code             | Description                             |
| ---------------------- | --------------------------------------- |
| `UNAUTHORIZED`         | API key is missing, invalid, or revoked |
| `INSUFFICIENT_CREDITS` | Not enough credits to complete request  |

## Next Steps

<CardGroup cols={2}>
  <Card title="Managing API Keys" icon="key" href="/authentication/api-keys">
    Learn how to create, rotate, and revoke API keys.
  </Card>

  <Card title="Credits & Billing" icon="credit-card" href="/billing/credits">
    Understand how credits work and manage your balance.
  </Card>
</CardGroup>
