Tạo khóa API
curl --request POST \
--url https://app.getkavio.app/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"expires_at": "<string>"
}
'import requests
url = "https://app.getkavio.app/api/api-keys"
payload = {
"name": "<string>",
"expires_at": "<string>"
}
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: '<string>', expires_at: '<string>'})
};
fetch('https://app.getkavio.app/api/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://app.getkavio.app/api/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' => '<string>',
'expires_at' => '<string>'
]),
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://app.getkavio.app/api/api-keys"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"expires_at\": \"<string>\"\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://app.getkavio.app/api/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"expires_at\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.getkavio.app/api/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\": \"<string>\",\n \"expires_at\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"token": {},
"plain_token": "<string>"
}Khóa API
Tạo khóa API
Tạo khóa API mới. Token dạng văn bản thuần chỉ hiển thị một lần.
POST
/
api-keys
Tạo khóa API
curl --request POST \
--url https://app.getkavio.app/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"expires_at": "<string>"
}
'import requests
url = "https://app.getkavio.app/api/api-keys"
payload = {
"name": "<string>",
"expires_at": "<string>"
}
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: '<string>', expires_at: '<string>'})
};
fetch('https://app.getkavio.app/api/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://app.getkavio.app/api/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' => '<string>',
'expires_at' => '<string>'
]),
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://app.getkavio.app/api/api-keys"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"expires_at\": \"<string>\"\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://app.getkavio.app/api/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"expires_at\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.getkavio.app/api/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\": \"<string>\",\n \"expires_at\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"token": {},
"plain_token": "<string>"
}Yêu cầu
string
bắt buộc
Tên khóa API, tối đa 255 ký tự.
string
Thời hạn không bắt buộc. Có thể dùng mọi chuỗi ngày tháng mà máy chủ đọc được
(ví dụ
2026-12-31, 2026-12-31T15:00:00Z) nhưng phải sau hôm nay. Bỏ qua
trường này nếu khóa không hết hạn.Phản hồi
Trả về201, khóa mới và token dạng văn bản thuần. Token chỉ xuất hiện tại đây, vì vậy hãy lưu ngay.
object
Cấu trúc giống một mục trong
GET /api-keys: id, name,
last_used_at, expires_at, created_at (mọi mốc thời gian đều theo ISO
8601).string
Bearer token dạng opaque để gửi trong
Authorization: Bearer …. Token này sẽ
không được trả về lần nữa.Sao chép
plain_token ngay sau khi tạo. Kavio chỉ lưu mã băm của khóa API,
không lưu chính khóa đó. Nếu làm mất, bạn cần tạo khóa mới.curl -X POST https://app.getkavio.app/api/api-keys \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "CI/CD Pipeline",
"expires_at": "2025-12-31"
}'
{
"token": {
"id": "a7b8c9d0-e1f2-3a4b-5c6d-7e8f9a0b1c2d",
"name": "CI/CD Pipeline",
"last_used_at": null,
"expires_at": "2025-12-31T00:00:00+00:00",
"created_at": "2025-01-14T12:00:00+00:00"
},
"plain_token": "9f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a..."
}

