Generate an API key

Cortex XSIAM Platform APIs

post /public_api/v1/api_keys/generate

Generate a new API key and define the roles assigned to it and whether the security level is standard or advanced.

Required license: Cortex XSIAM Premium or Cortex XSIAM Enterprise or Cortex XSIAM NG SIEM or Cortex XSIAM Enterprise Plus.

Request headers
authorization String required

api_key

Example: DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr
x-xdr-auth-id String required

api_key_id

Example: 2841
x-xdr-timestamp String required

timestamp in milliseconds

Example: xXdrTimestamp_example
x-xdr-nonce String required

64 byte random string

Example: xXdrNonce_example
x-child-tenant-id String required

child tenant ID

Example: xChildTenantId_example
CLIENT REQUEST
curl -X 'POST'
-H 'Accept: application/json'
-H 'Content-Type: application/json'
-H 'authorization: DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr' -H 'x-xdr-auth-id: 2841' -H 'x-xdr-timestamp: xXdrTimestamp_example' -H 'x-xdr-nonce: xXdrNonce_example' -H 'x-child-tenant-id: xChildTenantId_example'
'https://api-yourfqdn/public_api/v1/api_keys/generate'
-d ''
import http.client conn = http.client.HTTPSConnection("api-yourfqdn") payload = "{\"request_data\":{\"roles\":[\"string\"],\"security_level\":\"standard\",\"expiration\":0,\"comment\":\"string\"}}" headers = { 'authorization': "DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr", 'x-xdr-auth-id': "2841", 'x-xdr-timestamp': "SOME_STRING_VALUE", 'x-xdr-nonce': "SOME_STRING_VALUE", 'x-child-tenant-id': "SOME_STRING_VALUE", 'content-type': "application/json" } conn.request("POST", "/public_api/v1/api_keys/generate", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
require 'uri' require 'net/http' require 'openssl' url = URI("https://api-yourfqdn/public_api/v1/api_keys/generate") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url) request["authorization"] = 'DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr' request["x-xdr-auth-id"] = '2841' request["x-xdr-timestamp"] = 'SOME_STRING_VALUE' request["x-xdr-nonce"] = 'SOME_STRING_VALUE' request["x-child-tenant-id"] = 'SOME_STRING_VALUE' request["content-type"] = 'application/json' request.body = "{\"request_data\":{\"roles\":[\"string\"],\"security_level\":\"standard\",\"expiration\":0,\"comment\":\"string\"}}" response = http.request(request) puts response.read_body
const data = JSON.stringify({ "request_data": { "roles": [ "string" ], "security_level": "standard", "expiration": 0, "comment": "string" } }); const xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); } }); xhr.open("POST", "https://api-yourfqdn/public_api/v1/api_keys/generate"); xhr.setRequestHeader("authorization", "DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr"); xhr.setRequestHeader("x-xdr-auth-id", "2841"); xhr.setRequestHeader("x-xdr-timestamp", "SOME_STRING_VALUE"); xhr.setRequestHeader("x-xdr-nonce", "SOME_STRING_VALUE"); xhr.setRequestHeader("x-child-tenant-id", "SOME_STRING_VALUE"); xhr.setRequestHeader("content-type", "application/json"); xhr.send(data);
HttpResponse<String> response = Unirest.post("https://api-yourfqdn/public_api/v1/api_keys/generate") .header("authorization", "DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr") .header("x-xdr-auth-id", "2841") .header("x-xdr-timestamp", "SOME_STRING_VALUE") .header("x-xdr-nonce", "SOME_STRING_VALUE") .header("x-child-tenant-id", "SOME_STRING_VALUE") .header("content-type", "application/json") .body("{\"request_data\":{\"roles\":[\"string\"],\"security_level\":\"standard\",\"expiration\":0,\"comment\":\"string\"}}") .asString();
import Foundation let headers = [ "authorization": "DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr", "x-xdr-auth-id": "2841", "x-xdr-timestamp": "SOME_STRING_VALUE", "x-xdr-nonce": "SOME_STRING_VALUE", "x-child-tenant-id": "SOME_STRING_VALUE", "content-type": "application/json" ] let parameters = ["request_data": [ "roles": ["string"], "security_level": "standard", "expiration": 0, "comment": "string" ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-yourfqdn/public_api/v1/api_keys/generate")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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_URL => "https://api-yourfqdn/public_api/v1/api_keys/generate", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"request_data\":{\"roles\":[\"string\"],\"security_level\":\"standard\",\"expiration\":0,\"comment\":\"string\"}}", CURLOPT_HTTPHEADER => [ "authorization: DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr", "content-type: application/json", "x-child-tenant-id: SOME_STRING_VALUE", "x-xdr-auth-id: 2841", "x-xdr-nonce: SOME_STRING_VALUE", "x-xdr-timestamp: SOME_STRING_VALUE" ], ]); $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, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "https://api-yourfqdn/public_api/v1/api_keys/generate"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "authorization: DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr"); headers = curl_slist_append(headers, "x-xdr-auth-id: 2841"); headers = curl_slist_append(headers, "x-xdr-timestamp: SOME_STRING_VALUE"); headers = curl_slist_append(headers, "x-xdr-nonce: SOME_STRING_VALUE"); headers = curl_slist_append(headers, "x-child-tenant-id: SOME_STRING_VALUE"); headers = curl_slist_append(headers, "content-type: application/json"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"request_data\":{\"roles\":[\"string\"],\"security_level\":\"standard\",\"expiration\":0,\"comment\":\"string\"}}"); CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api-yourfqdn/public_api/v1/api_keys/generate"); var request = new RestRequest(Method.POST); request.AddHeader("authorization", "DCdIeow0xm73EwnxjPza1tdHTfZQv2eH7bTKlTPkgBHLj8aSjFzjgTE9bQUK1DidlWLrnYRhaYQ4PCIyNrNJbMUC6DOWi8ANIn1JWpMTE2neGvoDIRsKUbj6pJ1z7Gmr"); request.AddHeader("x-xdr-auth-id", "2841"); request.AddHeader("x-xdr-timestamp", "SOME_STRING_VALUE"); request.AddHeader("x-xdr-nonce", "SOME_STRING_VALUE"); request.AddHeader("x-child-tenant-id", "SOME_STRING_VALUE"); request.AddHeader("content-type", "application/json"); request.AddParameter("application/json", "{\"request_data\":{\"roles\":[\"string\"],\"security_level\":\"standard\",\"expiration\":0,\"comment\":\"string\"}}", ParameterType.RequestBody); IRestResponse response = client.Execute(request);
Body parameters
application/json
request_dataobjectrequired
rolesarray[string]

A list of roles to be assigned to the API key.

security_levelobject (Enum)

The seurity level of the API key. API keys with advanced security are hashed with a nonce and timestamp, which is useful for proprietary scripts and are intended to prevent replay attacks. Standard security API keys can be used as-is and are suitable for curl.

Allowed values:"standard""advanced"
expirationinteger

Integer in timestamp epoch milliseconds. Default value is one week from the time of the API call. Maximum expiration date is six months from the time of the API call.

commentstring
REQUEST
{ "request_data": { "roles": [ "Public API Action" ], "security_level": "standard", "comment": "Api key for John" } }
{ "request_data": { "roles": [ "Public API Action" ], "security_level": "standard", "expiration": 1725802080000, "comment": "API key for Joe" } }
Responses

OK

Body
application/json
replyobject
idinteger
keystring
RESPONSE
{ "reply": { "id": 4267, "key": "oZFaXmXCLCdoWIXTb9ITSqUvl4OBLsUQgCeuZc5FdwMpmpY5QBn8OUePZiLMb" } }