Skip to content

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/blob
client.uploadFromUrl(url, options?); // ingest a remote URL server-side
client.sign(fileId, { expiresIn, transform }); // mint a signed URL
client.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

codemeaning
missing_keyNo key option and no DROPKIT_KEY env var
missing_authThe bearer header was missing on the API call
invalid_keyKey was not recognized
origin_not_allowedThe browser’s origin isn’t in the project allowlist
size_out_of_rangeFile size is 0 or exceeds the plan cap
file_too_largeFile exceeds your plan’s per-file cap
quota_exceededPlan’s total storage cap hit
upload_failedThe file upload PUT request failed
needs_secret_keyOperation requires sk_live_
demo_rate_limitedPer-IP limit on demo project reached
demo_fullShared 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.