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

# Regenerate API Key

> Rotate your API key, invalidating the previous one

Generates a new API key for your account and invalidates the previous one immediately. Use when you suspect a key has leaked, or as part of a regular rotation schedule.

<Note>
  This endpoint **requires an API key** — the current one, which is what's being rotated. After the response, the old key returns 401 on every subsequent request. Update your integrations atomically.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.dotlookup.dev/v1/auth/regenerate-key \
    -H "X-API-Key: your_current_api_key"
  ```

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

  resp = requests.post(
      "https://api.dotlookup.dev/v1/auth/regenerate-key",
      headers={"X-API-Key": old_key},
  )
  new_key = resp.json()["api_key"]
  # Persist new_key BEFORE making any other call — old_key is now invalid
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "api_key": "dl_new_a1b2c3d4e5f6..."
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": "UNAUTHORIZED",
      "message": "API key is required"
    }
  }
  ```
</ResponseExample>

The previous key is invalidated server-side as part of the same transaction that creates the new one — there is no overlap window where both work.
