Set parent API key

If you need to change the parent/child relationship for an existing API key, you can do this programmatically using the 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.
    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:

{
    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).

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:

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 to see samples for PHP, JS, and learn how to write code for other languages.