Getting Started
Quickstart Guide
Learn how to generate an API key, install the TypeScript SDK, and upload your first asset in less than 3 minutes.
1
Generate an API Key
Before interacting with Cloudizero APIs or the SDK, you need an API key. Navigate to the API Keys Console and create a new key.
Keep API Keys Confidential
API keys prefixed with
cz_live_ grant access to manage your storage. Never expose secret keys in client-side bundles or public GitHub repositories.2
Install @cloudizero/sdk
Install the official package using your preferred package manager:
pnpm add @cloudizero/sdk3
Upload Your First Asset
Create an upload script (e.g., upload.ts) and execute it:
upload.ts
import { Cloudizero } from "@cloudizero/sdk";
import fs from "fs";
// 1. Inisialisasi Klien Cloudizero (otomatis membaca CLOUDIZERO_API_KEY dari environment)
const cz = new Cloudizero();
async function main() {
// 2. Baca file yang akan diunggah
const fileBuffer = fs.readFileSync("./sample.png");
// 3. Unggah langsung ke Cloudflare R2
const asset = await cz.storage.upload({
file: fileBuffer,
fileName: "sample.png",
projectId: "your-project-id", // temukan di dashboard /projects
mimeType: "image/png",
});
console.log("Upload Success!");
console.log("Asset ID:", asset.id);
console.log("Public CDN URL:", asset.url);
}
main().catch(console.error);What's Next?
Check out the detailed Uploads Guide to learn about browser uploads with real-time progress callbacks, or explore Storage Explorer API to organize folders.