Authentication
Every Upload API request identifies the project with the public key, sent as the UPLOADCARE_PUB_KEY parameter or pub_key where the endpoint says so.
Signed access
A project with signed uploads enabled additionally requires a credential generated on your backend with the project secret key.
There are two credential schemes:
- Token, a JSON Web Token in the
Authorizationheader. It can restrict which endpoints the client may call and how many operations it may spend. - Signature (deprecated), the
signatureandexpirerequest parameters. It allows every endpoint until it expires. This is the legacy scheme; use tokens for new integrations.
signature and an Authorization header, the signature is checked and the header is ignored.Credentials are checked only when signed uploads are enabled for the project. The signed uploads guide explains how to enable them and which credential to choose.
Token
A token is a JSON Web Token (RFC 7519) sent in the Authorization header with the Bearer scheme:
Signing
The token MUST be signed with HS256. The signing key is the SHA-256 digest of the project secret key, as raw 32 bytes rather than their hex representation. Any of the project’s secret keys works.
Claims
Standard claims sit at the root of the payload. Everything Uploadcare interprets sits under the uc claim.
Other standard claims are ignored. Keys under uc other than the ones listed above are not allowed: such a token is rejected.
sub or jti claims, especially if you generate tokens for multiple clients within a short period of time. Having all the same claims for different clients can lead to incorrect accounting of the client quota (the shared quota for different clients).Payload example:
Scope and limits
Each signed endpoint has a scope path. A scope item matches a path exactly, or as a prefix when it ends with /*. A bare /* matches every endpoint. The list holds from 1 to 16 items, each up to 64 characters and starting with /.
The operations counter lives as long as the token. A request that would exceed the limit is refused. Requests that fail with a 4xx response do not consume operations. A multipart upload that is started but never completed still consumes its operation.
Generate a token
Use any JWT library that supports HS256:
NodeJS
Python
Ruby
Upload example
Errors
Signature
The signature and expire parameters are sent together with the request, either in the query string or as form fields.
Any of the project’s secret keys works.
Generate a signature
@uploadcare/signed-uploads package accepts milliseconds and converts to seconds internally. If you implement signing without this package, expire must be in seconds, not milliseconds.JavaScript
NodeJS
Python
Ruby
Elixir
Upload example
Errors
For the complete list of Upload API errors, see Errors.