Update an API key

NAS File Storage REST API Reference

Version
15.6.x
File Size
1291 KB
Audience
anonymous
Part Number
MK-92HNAS100-07
ft:lastEdition
2026-04-07
patch /v9/storage/file-devices/management/api-keys/{apiKeyObjectId}

Update an API key.

Note: The authentication required to access this API call differs from the general defaults. The default access to this call is: Writable user, Writable API key (key types: unrestricted,callId restricted).

Authentication: x_subsystem_user Api Key "X-Subsystem-User"
Authentication: x_subsystem_password Api Key "X-Subsystem-Password"
Authentication: api_key Api Key "X-Api-Key"
Authentication: basicAuth HTTP - basic scheme
Path parameters
apiKeyObjectId String required

Object ID of an API key

Example: 567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56
CLIENT REQUEST
curl -X 'PATCH'
-H "X-Subsystem-User: [[apiKey]]" \
-H "X-Subsystem-Password: [[apiKey]]" \
-H "X-Api-Key: [[apiKey]]" \
-H "Authorization: Basic [[basicHash]]" \
-H 'Accept: application/json'
-H 'Content-Type: application/json'
'https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/{apiKeyObjectId}'
-d ''
import http.client conn = http.client.HTTPSConnection("172.27.146.40:8444") payload = "{\"description\":\"This is the description\",\"isEnabled\":true,\"restApiAccess\":\"READ_ONLY\",\"restrictedToApiKeyGroups\":[\"313a3a3a3a3a3a303a3a3a4f49445f24232140255f56\"],\"restrictedToVirtualServers\":[\"1\"],\"soapApiAccess\":\"FULL_CONTROL\"}" headers = { 'Authorization': "Basic REPLACE_BASIC_AUTH", 'content-type': "application/json" } conn.request("PATCH", "/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
require 'uri' require 'net/http' require 'openssl' url = URI("https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Patch.new(url) request["Authorization"] = 'Basic REPLACE_BASIC_AUTH' request["content-type"] = 'application/json' request.body = "{\"description\":\"This is the description\",\"isEnabled\":true,\"restApiAccess\":\"READ_ONLY\",\"restrictedToApiKeyGroups\":[\"313a3a3a3a3a3a303a3a3a4f49445f24232140255f56\"],\"restrictedToVirtualServers\":[\"1\"],\"soapApiAccess\":\"FULL_CONTROL\"}" response = http.request(request) puts response.read_body
const data = JSON.stringify({ "description": "This is the description", "isEnabled": true, "restApiAccess": "READ_ONLY", "restrictedToApiKeyGroups": [ "313a3a3a3a3a3a303a3a3a4f49445f24232140255f56" ], "restrictedToVirtualServers": [ "1" ], "soapApiAccess": "FULL_CONTROL" }); const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } }); xhr.open("PATCH", "https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56"); xhr.setRequestHeader("Authorization", "Basic REPLACE_BASIC_AUTH"); xhr.setRequestHeader("content-type", "application/json"); xhr.send(data);
HttpResponse<String> response = Unirest.patch("https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56") .header("Authorization", "Basic REPLACE_BASIC_AUTH") .header("content-type", "application/json") .body("{\"description\":\"This is the description\",\"isEnabled\":true,\"restApiAccess\":\"READ_ONLY\",\"restrictedToApiKeyGroups\":[\"313a3a3a3a3a3a303a3a3a4f49445f24232140255f56\"],\"restrictedToVirtualServers\":[\"1\"],\"soapApiAccess\":\"FULL_CONTROL\"}") .asString();
import Foundation let headers = [ "Authorization": "Basic REPLACE_BASIC_AUTH", "content-type": "application/json" ] let parameters = [ "description": "This is the description", "isEnabled": true, "restApiAccess": "READ_ONLY", "restrictedToApiKeyGroups": ["313a3a3a3a3a3a303a3a3a4f49445f24232140255f56"], "restrictedToVirtualServers": ["1"], "soapApiAccess": "FULL_CONTROL" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume()
<?php $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_PORT => "8444", CURLOPT_URL => "https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "PATCH", CURLOPT_POSTFIELDS => "{\"description\":\"This is the description\",\"isEnabled\":true,\"restApiAccess\":\"READ_ONLY\",\"restrictedToApiKeyGroups\":[\"313a3a3a3a3a3a303a3a3a4f49445f24232140255f56\"],\"restrictedToVirtualServers\":[\"1\"],\"soapApiAccess\":\"FULL_CONTROL\"}", CURLOPT_HTTPHEADER => [ "Authorization: Basic REPLACE_BASIC_AUTH", "content-type: application/json" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_easy_setopt(hnd, CURLOPT_URL, "https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Authorization: Basic REPLACE_BASIC_AUTH"); headers = curl_slist_append(headers, "content-type: application/json"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"description\":\"This is the description\",\"isEnabled\":true,\"restApiAccess\":\"READ_ONLY\",\"restrictedToApiKeyGroups\":[\"313a3a3a3a3a3a303a3a3a4f49445f24232140255f56\"],\"restrictedToVirtualServers\":[\"1\"],\"soapApiAccess\":\"FULL_CONTROL\"}"); CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://172.27.146.40:8444/v9/storage/file-devices/management/api-keys/567667324c76345630433a3a3a303a3a3a4f49445f24232140255f56"); var request = new RestRequest(Method.PATCH); request.AddHeader("Authorization", "Basic REPLACE_BASIC_AUTH"); request.AddHeader("content-type", "application/json"); request.AddParameter("application/json", "{\"description\":\"This is the description\",\"isEnabled\":true,\"restApiAccess\":\"READ_ONLY\",\"restrictedToApiKeyGroups\":[\"313a3a3a3a3a3a303a3a3a4f49445f24232140255f56\"],\"restrictedToVirtualServers\":[\"1\"],\"soapApiAccess\":\"FULL_CONTROL\"}", ParameterType.RequestBody); IRestResponse response = client.Execute(request);
Body parameters
application/json
descriptionstring

Description to be associated with the item

Example:"This is the description"
isEnabledboolean

True if enabled, false for disabled

restApiAccessstring (Enum)

Access level for REST API access

Allowed values:"READ_ONLY""FULL_CONTROL""NO_ACCESS"
restrictedToApiKeyGroupsarray[string]

A list of API key groups that the API key is restricted to. The groups can be specified by name, index or object ID. An empty list removes any group restrictions that might already apply

restrictedToVirtualServersarray[string]

A list of virtual servers that the API key is restricted to. The virtual servers can be specified by name, virtualServerId or object ID. An empty list removes any virtual server restrictions that might already apply

soapApiAccessstring (Enum)

Access level for SOAP API access

Allowed values:"FULL_CONTROL""NO_ACCESS"
REQUEST
{ "description": "This is the description", "isEnabled": false, "restApiAccess": "READ_ONLY", "restrictedToApiKeyGroups": [ "313a3a3a3a3a3a303a3a3a4f49445f24232140255f56" ], "restrictedToVirtualServers": [ "1" ], "soapApiAccess": "FULL_CONTROL" }
Responses

No Content - the resource was updated successfully

Bad Request

Body
application/json
errorCodeintegerint32

Generic error code

Example:1081353
errorMsgstring

Main error message

Example:"Invalid description parameter - the optional parameter must be between 2 and 30 characters long to be valid, if supplied"
RESPONSE
{ "errorCode": 1081353, "errorMsg": "Invalid description parameter - the optional parameter must be between 2 and 30 characters long to be valid, if supplied" }

Unauthorized - the request was rejected because the credentials or API key were either missing or invalid

Forbidden - the client does not have the required permissions to perform the operation

Body
application/json
errorMsgstring

Main error message

Example:"Forbidden request - the client does not have the required permissions to perform the operation"
RESPONSE
{ "errorMsg": "Forbidden request - the client does not have the required permissions to perform the operation" }

Not Found - a resource specified was not found

Body
application/json
errorCodeintegerint32

Generic error code

Example:1081345
errorDetailobject

Detailed error information

detailstring

More details on why the error occurred

faultstring
fileNamestring

Source file where the error occurred

Example:"RestApiFilesystems.cpp"
functionstring

Internal function name where the error occurred

Example:"mountFilesystem"
lineNumberintegerint32

Line number within the source file, where the error occurred

messagestring

Reason why the error(s) occurred

Example:"The file system is currently unassigned"
reasonstring

Reason why the error(s) occurred

Example:"The file system is currently unassigned"
returnedValueintegerint32

Not used

subCodeintegerint32

Specific failure error code

errorMsgstring

Main error message

Example:"Cannot find the object of the operation on the device"
RESPONSE
{ "errorCode": 1081345, "errorDetail": { "detail": "", "fault": "", "fileName": "RestApiFilesystems.cpp", "function": "mountFilesystem", "lineNumber": 0, "message": "The file system is currently unassigned", "reason": "The file system is currently unassigned", "returnedValue": 0, "subCode": 0 }, "errorMsg": "Cannot find the object of the operation on the device" }

Internal Server Error

Body
application/json
errorCodeintegerint32

Generic error code

errorDetailobject

Detailed error information

detailstring

More details on why the error occurred

faultstring
fileNamestring

Source file where the error occurred

Example:"RestApiFilesystems.cpp"
functionstring

Internal function name where the error occurred

Example:"mountFilesystem"
lineNumberintegerint32

Line number within the source file, where the error occurred

messagestring

Reason why the error(s) occurred

Example:"The file system is currently unassigned"
reasonstring

Reason why the error(s) occurred

Example:"The file system is currently unassigned"
returnedValueintegerint32

Not used

subCodeintegerint32

Specific failure error code

errorMsgstring

Main error message

Example:"Failed to mount file system"
RESPONSE
{ "errorCode": 0, "errorDetail": { "detail": "", "fault": "", "fileName": "RestApiFilesystems.cpp", "function": "mountFilesystem", "lineNumber": 0, "message": "The file system is currently unassigned", "reason": "The file system is currently unassigned", "returnedValue": 0, "subCode": 0 }, "errorMsg": "Failed to mount file system" }