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

# Validate API Key

> Validate an API key for external access

# Validate API Key

Validate an API key to verify it's active and has proper permissions.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.weir.ai/external/validate/key' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -H 'Content-Type: application/json'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "data": {
      "valid": true,
      "clientId": "cli_123456789",
      "permissions": ["read", "write"],
      "expiresAt": "2025-01-22T00:00:00Z"
    },
    "message": "API key is valid",
    "status": "success"
  }
  ```
</ResponseExample>

## Response Fields

<ResponseField name="data.valid" type="boolean" required>
  Whether the API key is valid.
</ResponseField>

<ResponseField name="data.clientId" type="string" required>
  Associated client identifier.
</ResponseField>

<ResponseField name="data.permissions" type="array" required>
  Array of permissions granted to this API key.
</ResponseField>

<ResponseField name="data.expiresAt" type="timestamp">
  API key expiration timestamp.
</ResponseField>

## Usage Examples

<CodeGroup>
  ```javascript JavaScript theme={null}
  const validateApiKey = async (apiKey) => {
    const response = await fetch('https://api.weir.ai/external/validate/key', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
      }
    });
    if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
    return await response.json();
  };
  ```

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

  def validate_api_key(api_key):
      response = requests.post(
          'https://api.weir.ai/external/validate/key',
          headers={'Authorization': f'Bearer {api_key}'}
      )
      response.raise_for_status()
      return response.json()
  ```
</CodeGroup>

<Tip>
  **Pro Tip**: Use this endpoint to verify API keys before performing operations.
</Tip>
