Create an upload token
Mint a short-lived upload token with POST /v1/upload-tokens so a browser can upload straight to Blob Storage without your API key.
POST
The API key for your account. You can find this in your account settings.
blob:write scope and an active plan.
The token goes in the Authorization header of Object Post or the chunked upload routes, and works nowhere else (403 UPLOAD_TOKEN_NOT_ALLOWED). Everything you set when minting it is pinned: the browser can’t change the name, prefix, visibility, expiry or metadata, send a larger file, or use another file type.
- Each upload spends one use: a call to Object Post, or opening a chunked upload (its parts and completion don’t spend more).
- In chunked uploads, a token only drives the uploads it opened itself (status, parts, completion and abort): an
uploadvalue from another upload answers400 INVALID_UPLOAD_TOKEN. - Without a
name, the browser picks it and the name always gets a security hash, so a leaked token can never replace your existing files. - The token stops working when its uses run out (
401 UPLOAD_TOKEN_USED), when it expires, when the API key that minted it is regenerated or revoked, or when the dashboard session that minted it logs out (401 ACCESS_DENIED).
Parameters
Only with
name: false lets the upload replace the file with that name. Otherwise the name always gets a hash.Rate limits
120 tokens per minute (
RATE_LIMITED, 429). Minting stores nothing, so one token per end-user upload is fine.Response
Errors
When the browser uploads:
401 UPLOAD_TOKEN_USED (used up), 401 ACCESS_DENIED (expired, its key regenerated or revoked, or its session logged out), 403 PREFIX_NOT_ALLOWED (other prefix), 400 FILE_TYPE_NOT_ALLOWED (extension not allowed) and 413 FILE_TOO_LARGE (over max_size).
Related
- Blob SDK:
blob.uploadTokens.create()

