# Set parent API key

> Assign, replace or remove the parent of a child N1ED API key from code, so it inherits configuration from another key on the account.

Source: https://n1ed.com/docs/admin-api/set-parent-api-key  
Section: For developers > Admin API > Set parent 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

If you need to change the [parent/child](https://n1ed.com/docs/multisite/parent-and-child-api-keys) relationship for an existing API key, you can do this programmatically using the [Admin API](https://n1ed.com/docs/admin-api) available on Studio plan and higher ones.

This request lets you assign a parent API key to an existing child, replace the current parent with a different one, or remove the parent connection entirely.

## Request format

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

- `adminToken`: Your secret Admin API token

- `apiKey`: API key of the website you want to assign a parent to or remove a parent from. Both 8-character and full 24-character API keys are accepted.

  It's recommended to use only the first 8 symbols of API key.

- `parentApiKey`: API key on the same account that will be used as a [parent](https://n1ed.com/docs/multisite/parent-and-child-api-keys).  
  Parent API key dynamically provides configuration to its children. So editing configuration in the Dashboard for the child will be blocked and parent's options will be used.  
  Both 8-character and full 24-character API keys are accepted.  
  To remove the existing parent connection, pass an empty string as the value of this parameter.

  It's recommended to use only the first 8 symbols of API key.

## Response format

The server will return a success response if the parent was set or removed successfully, or an error code otherwise.

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

```js
{
    error: null,
    data: "OK"
}
```

Possible error codes:

- `UNABLE-TO-CHANGE-NOT-OWN-API-KEY` - the `apiKey` does not belong to your account.
- `NO-SUCH-API-KEY` - the `apiKey` parameter has been incorrectly specified or the API key doesn't exist.
- `INVALID-PARENT-API-KEY` - the `parentApiKey` is too short. Use at least 8 characters.
- `UNABLE-TO-SET-PARENT-API-KEY` - the parent could not be set (e.g. the parent API key doesn't exist, or the child already has children of its own).
- `INCORRECT-TOKEN` - the `adminToken` parameter has been incorrectly specified.

## Sample request

Here is a sample of how to set a parent API key from the Linux console (sh, bash, or any other shell).

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

To remove the parent connection:

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

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.
