Criar Chave de API do Consumidor
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"
}
'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));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)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))
}{
"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:00.000Z",
"expires_at": "2026-06-23T14:30:00.000Z"
}{
"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
}Consumidor (B2C)
Criar chave de API do consumidor
Cria uma nova chave de API pessoal. O segredo completo é retornado uma vez e não pode ser recuperado novamente. Os consumidores podem ter até 5 chaves ativas. As chaves expiram após 90 dias. Requer uma sessão de consumidor individual autenticada; uma sessão de negócios ou chave de API de espaço de trabalho não pode substituir a identidade do usuário.
POST
/
v1
/
consumer
/
api-keys
Criar Chave de API do Consumidor
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"
}
'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));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)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))
}{
"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:00.000Z",
"expires_at": "2026-06-23T14:30:00.000Z"
}{
"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
}Cria uma nova chave de API pessoal para o consumidor autenticado. O segredo completo é retornado uma vez na resposta e não pode ser recuperado novamente — armazene-o com segurança.
Cada consumidor pode ter até 5 chaves ativas. As chaves expiram automaticamente após 90 dias.
Respostas
Resposta
Chave de API criada. O segredo é mostrado apenas nesta resposta.

