# Rotate API key

> Change characters 9 to 24 of an exposed N1ED API key through the Admin API while the public first 8 characters stay the same.

Source: https://n1ed.com/docs/admin-api/rotate-api-key  
Section: For developers > Admin API > Rotate API key  
Updated: 2026-09-29  
Every page of n1ed.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://n1ed.com/llms-full.txt

When you feel your API key might have been accidentally exposed, or as part of periodically changing secrets for security purposes, you can change API keys used on your websites. API key rotation may be used only with the help of [Admin API](https://n1ed.com/docs/admin-api) available on Studio and higher plans.

Be careful when calling this request, because the specified key will be rotated immediately, and if your script loses the response and doesn't save it to the DB, you'll be left with an outdated API key. However, you can retrieve it manually from the [Dashboard](https://n1ed.com/dashboard).

This request will change only characters 9–24 of the API key, keeping positions 1–8 intact. The first 8-character part is a constant public part and should never be changed.

## Request format

**URL:** `https://cloud.n1ed.com/a/admin/api-key-rotate`  
**Request type:** `POST`  
**Content type:** `application/x-www-form-urlencoded`  
**Parameters:**

- `adminToken`: Your secret Admin API token
- `apiKey`: API key on the current account to be rotated (changed).

## Response format

The server will return the new API key in the data section if the request succeeds, or an error code otherwise.

**HTTP code:** `200`  
**Content type:** `application/json`  
**Body:**

```js
{
    error: null,
    data: {
        apiKey: "rotated-api-key"
    }
}
```

Possible error codes:

- `NO-SUCH-API-KEY` - the `apiKey` parameter has been incorrectly specified. Are you trying to rotate the same old API key a second time?
- `INCORRECT-TOKEN` - the `adminToken` parameter has been incorrectly specified.

## Sample request

Here is a sample of how to make this request from the Linux console (sh, bash, or any other shell).

```bash
curl \
    -X POST https://cloud.n1ed.com/a/admin/api-key-rotate \
    -d "adminToken=your-secret-admin-token&apiKey=your-api-key"
```

Please refer to [Admin API](https://n1ed.com/docs/admin-api) to see samples for PHP, JS, and learn how to write code for other languages.
