Create Consumer API Key
curl --request POST \
--url https://api.truthlocks.com/v1/consumer/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "CI pipeline key"
}
'import requests
url = "https://api.truthlocks.com/v1/consumer/api-keys"
payload = { "name": "CI pipeline key" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'CI pipeline key'})
};
fetch('https://api.truthlocks.com/v1/consumer/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://api.truthlocks.com/v1/consumer/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([
'name' => 'CI pipeline key'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.truthlocks.com/v1/consumer/api-keys"
payload := strings.NewReader("{\n \"name\": \"CI pipeline key\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.truthlocks.com/v1/consumer/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"CI pipeline key\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.truthlocks.com/v1/consumer/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"CI pipeline key\"\n}"
response = http.request(request)
puts response.read_body{
"key_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "CI pipeline key",
"prefix": "tlk_abcd1234",
"status": "active",
"scopes": [
"consumer:read",
"consumer:write",
"attestations:mint",
"attestations:read",
"verify:read"
],
"secret": "tlk_abcd1234abcd5678ef901234abcd5678ef901234abcd5678ef901234abcd5678",
"created_at": "2026-03-25T14:30:00Z",
"expires_at": "2026-06-23T14:30:00Z"
}{
"code": "VALIDATION_ERROR",
"message": "Maximum of 5 active API keys reached. Revoke an existing key first.",
"http_status": 400
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}Consumer (B2C)
Create consumer API key
Creates a new personal API key. The full secret is returned once and cannot be retrieved again. Consumers may hold up to 5 active keys. Keys expire after 90 days.
POST
/
v1
/
consumer
/
api-keys
Create Consumer API Key
curl --request POST \
--url https://api.truthlocks.com/v1/consumer/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "CI pipeline key"
}
'import requests
url = "https://api.truthlocks.com/v1/consumer/api-keys"
payload = { "name": "CI pipeline key" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'CI pipeline key'})
};
fetch('https://api.truthlocks.com/v1/consumer/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://api.truthlocks.com/v1/consumer/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([
'name' => 'CI pipeline key'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.truthlocks.com/v1/consumer/api-keys"
payload := strings.NewReader("{\n \"name\": \"CI pipeline key\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.truthlocks.com/v1/consumer/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"CI pipeline key\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.truthlocks.com/v1/consumer/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"CI pipeline key\"\n}"
response = http.request(request)
puts response.read_body{
"key_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "CI pipeline key",
"prefix": "tlk_abcd1234",
"status": "active",
"scopes": [
"consumer:read",
"consumer:write",
"attestations:mint",
"attestations:read",
"verify:read"
],
"secret": "tlk_abcd1234abcd5678ef901234abcd5678ef901234abcd5678ef901234abcd5678",
"created_at": "2026-03-25T14:30:00Z",
"expires_at": "2026-06-23T14:30:00Z"
}{
"code": "VALIDATION_ERROR",
"message": "Maximum of 5 active API keys reached. Revoke an existing key first.",
"http_status": 400
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}Creates a new personal API key for the authenticated consumer. The full secret is returned once in the response and cannot be retrieved again — store it securely.
Each consumer can hold up to 5 active keys. Keys automatically expire after 90 days.
Parameters
string
required
A human-readable label for the key (e.g., “CI pipeline key”).
Responses
Authorizations
JWT for user-initiated operations
Body
application/json
A human-readable label for the key
Response
API key created. The secret is shown only in this response.
Human-readable label for the key
First 12 characters of the key, for display purposes
Available options:
active, revoked Permission scopes granted to this key
Keys expire 90 days after creation
Timestamp of the last request made with this key
Full API key value (shown once)

