Referensi REST API
Endpoint Kunci API
Kelola kunci API yang dibuat secara terprogram, pantau hash kunci aktif, dan cabut kredensial yang sudah tidak digunakan.
POST
/api/api-keys
Menghasilkan kunci API mentah baru berawalan cz_live_. Nilai rahasia mentah hanya ditampilkan satu kali saja saat pembuatan.
Request
curl -X POST https://api.cloudizero.com/api/api-keys \
-H "Cookie: authjs.session-token=..." \
-H "Content-Type: application/json" \
-d '{
"name": "Production Backend Worker",
"workspaceId": "ws_LXAlEW70v24YSc0y",
"projectIds": ["prj_LXAlEW70v24YSc0y"]
}'Response (200 OK)
{
"id": "key_W5ZwCHs1pwAP2Hmt",
"name": "Production Backend Worker",
"key": "cz_live_9f8ab2e4b830d9...",
"workspaceId": "ws_LXAlEW70v24YSc0y",
"projectId": "prj_LXAlEW70v24YSc0y",
"projectIds": ["prj_LXAlEW70v24YSc0y"],
"createdAt": "2026-10-12T12:00:00Z"
}Hanya Ditampilkan Sekali
Kunci API teks biasa tidak pernah disimpan di database. Segera simpan token ini di tempat penyimpanan rahasia (vault) atau manajer environment yang aman.
GET
/api/api-keys
Mengambil daftar seluruh kunci API aktif milik akun pengguna beserta prefix token, asosiasi proyek scoped, dan stempel waktu penggunaan terakhir.
Request
curl -X GET https://api.cloudizero.com/api/api-keys \
-H "Cookie: authjs.session-token=..."Response (200 OK)
[
{
"id": "key_W5ZwCHs1pwAP2Hmt",
"name": "Production Backend Worker",
"keyPrefix": "cz_live_9f8ab2e4...",
"workspaceId": "ws_LXAlEW70v24YSc0y",
"workspaceName": "Acme Engineering",
"projectId": "prj_LXAlEW70v24YSc0y",
"projectName": "Storefront Production",
"projects": [
{ "id": "prj_LXAlEW70v24YSc0y", "name": "Storefront Production" }
],
"lastUsedAt": "2026-10-21T18:30:00Z",
"createdAt": "2026-10-12T12:00:00Z"
}
]GET
/api/api-keys/[keyId]
Mengambil detail lengkap kunci API tertentu termasuk status perizinan workspace, daftar proyek terikat, serta agregasi volume penyimpanan dan jumlah file yang dapat diakses.
Request
curl -X GET https://api.cloudizero.com/api/api-keys/key_W5ZwCHs1pwAP2Hmt \
-H "Cookie: authjs.session-token=..."Response (200 OK)
{
"id": "key_W5ZwCHs1pwAP2Hmt",
"name": "Production Backend Worker",
"keyPrefix": "cz_live_9f8ab2e4...",
"workspace": {
"id": "ws_LXAlEW70v24YSc0y",
"name": "Acme Engineering",
"slug": "acme-engineering",
"isPersonal": false
},
"isGlobal": false,
"isWorkspaceWide": false,
"projects": [
{
"id": "prj_LXAlEW70v24YSc0y",
"name": "Storefront Production",
"totalSize": 14285700,
"fileCount": 128
}
],
"lastUsedAt": "2026-10-21T18:30:00Z",
"createdAt": "2026-10-12T12:00:00Z"
}DELETE
/api/api-keys/[keyId]
Mencabut dan menghapus kunci API secara permanen menggunakan path parameter /api/api-keys/[keyId] (atau query ?keyId=...). Kunci yang telah dicabut langsung kehilangan akses seketika.
Request
curl -X DELETE "https://api.cloudizero.com/api/api-keys/key_W5ZwCHs1pwAP2Hmt" \
-H "Cookie: authjs.session-token=..."Response (200 OK)
{
"success": true,
"message": "API key revoked"
}