SDK reference
import { dropkit } from '@dropkit/sdk';
const client = dropkit({ key: 'pk_live_...', // required endpoint: 'https://api.dropkit.app', // optional});
const { data, error } = await client.upload(file, { visibility: 'public', // or 'private' metadata: { user: '123' }, // optional onProgress: (bytes, total) => {}, // optional signal: controller.signal, // optional});The factory returns a typed client. Reuse it across calls. Tree-shakable and runs on Node, Bun, Deno, Cloudflare Workers, Vercel Edge.
Methods
client.upload(file, options?); // upload a local file/blobclient.uploadFromUrl(url, options?); // ingest a remote URL server-sideclient.sign(fileId, { expiresIn, transform }); // mint a signed URLclient.delete(fileId); // delete (secret key only)transform is optional. Pass { w, h, q, format, fit } to bake image-resize params into the signed URL so it works directly as a thumbnail <img src>. Transforms are a paid-plan feature; free-plan URLs serve the original.
Response shape
// success{ data: { id, url, name, size, type, visibility }, error: null }
// failure{ data: null, error: { code, message, fix? } }Error codes
| code | meaning |
|---|---|
missing_key | No key option and no DROPKIT_KEY env var |
missing_auth | The bearer header was missing on the API call |
invalid_key | Key was not recognized |
origin_not_allowed | The browser’s origin isn’t in the project allowlist |
size_out_of_range | File size is 0 or exceeds the plan cap |
file_too_large | File exceeds your plan’s per-file cap |
quota_exceeded | Plan’s total storage cap hit |
upload_failed | The file upload PUT request failed |
needs_secret_key | Operation requires sk_live_ |
demo_rate_limited | Per-IP limit on demo project reached |
demo_full | Shared demo is at its 50 GB cap |
Aborting
const ctrl = new AbortController();const client = dropkit({ key: '...' });client.upload(file, { signal: ctrl.signal });ctrl.abort();Functional exports
If you prefer standalone functions instead of a client, the named exports work too:
import { upload, uploadFromUrl, signFileUrl, deleteFile } from '@dropkit/sdk';
await upload(file, { key: 'pk_live_...' });await uploadFromUrl('https://example.com/photo.jpg', { key: 'sk_live_...' });uploadFromUrl requires a real key (browser or server); the bundled demo key is rejected. Source must be https. Full reference: URL ingest.
Pick the factory in new code. The functional API is kept for simple single-call cases and for the existing recipes.