Create an API key
curl --request POST \
--url https://your-kordless-instance.com/v1/api-keys \
--header 'Content-Type: application/json' \
--data '
{
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"environmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
'import requests
url = "https://your-kordless-instance.com/v1/api-keys"
payload = {
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"environmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
projectId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
environmentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
name: '<string>'
})
};
fetch('https://your-kordless-instance.com/v1/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-kordless-instance.com/v1/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'environmentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-kordless-instance.com/v1/api-keys"
payload := strings.NewReader("{\n \"projectId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"environmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-kordless-instance.com/v1/api-keys")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"environmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-kordless-instance.com/v1/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"environmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"apiKey": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspaceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"environmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"keyPrefix": "<string>",
"lastFour": "<string>",
"createdByClerkUserId": "<string>",
"lastUsedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"revokedAt": "2023-11-07T05:31:56Z",
"revokeAfter": "2023-11-07T05:31:56Z"
},
"secret": "<string>"
},
"requestId": "<string>"
}{
"error": {
"code": "unauthorized",
"message": "Authentication is required.",
"requestId": "req_9f8e7d6c"
}
}{
"error": {
"code": "forbidden",
"message": "Your Workspace role cannot perform this action.",
"requestId": "req_9f8e7d6c"
}
}{
"error": {
"code": "environment_not_found",
"message": "The Project or Environment does not exist in the active Workspace.",
"requestId": "req_9f8e7d6c"
}
}{
"error": {
"code": "invalid_request",
"message": "The request failed validation.",
"requestId": "req_9f8e7d6c",
"details": {
"fields": {
"url": [
"Expected an HTTPS URL without credentials or fragments"
]
}
}
}
}API keys
Create an API key
Creates a key for any Environment. The generated prefix follows the
Environment kind (sk_test_ or sk_live_); the plaintext secret is
returned exactly once and stored as a SHA-256 digest. Requires the
api_keys:create permission.
POST
/
v1
/
api-keys
Create an API key
curl --request POST \
--url https://your-kordless-instance.com/v1/api-keys \
--header 'Content-Type: application/json' \
--data '
{
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"environmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
'import requests
url = "https://your-kordless-instance.com/v1/api-keys"
payload = {
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"environmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
projectId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
environmentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
name: '<string>'
})
};
fetch('https://your-kordless-instance.com/v1/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-kordless-instance.com/v1/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'environmentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-kordless-instance.com/v1/api-keys"
payload := strings.NewReader("{\n \"projectId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"environmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-kordless-instance.com/v1/api-keys")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"environmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-kordless-instance.com/v1/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"environmentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"apiKey": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspaceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"environmentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"keyPrefix": "<string>",
"lastFour": "<string>",
"createdByClerkUserId": "<string>",
"lastUsedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"revokedAt": "2023-11-07T05:31:56Z",
"revokeAfter": "2023-11-07T05:31:56Z"
},
"secret": "<string>"
},
"requestId": "<string>"
}{
"error": {
"code": "unauthorized",
"message": "Authentication is required.",
"requestId": "req_9f8e7d6c"
}
}{
"error": {
"code": "forbidden",
"message": "Your Workspace role cannot perform this action.",
"requestId": "req_9f8e7d6c"
}
}{
"error": {
"code": "environment_not_found",
"message": "The Project or Environment does not exist in the active Workspace.",
"requestId": "req_9f8e7d6c"
}
}{
"error": {
"code": "invalid_request",
"message": "The request failed validation.",
"requestId": "req_9f8e7d6c",
"details": {
"fields": {
"url": [
"Expected an HTTPS URL without credentials or fragments"
]
}
}
}
}⌘I