Configure Cloudinary
August 19, 2026 · View on GitHub
When to use
Do this once per process before any upload, admin, analysis, or URL-generation call.
Prerequisite: a cloud_name, api_key, and api_secret. If you do not have them,
see Get Cloudinary credentials — npx @cloudinary/cloud provisions
a working cloud with no signup.
Recommended: environment variable
Set CLOUDINARY_URL (from Console > Settings > API Keys, or written into .env for you
by npx @cloudinary/cloud):
export CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud_name>
const cloudinary = require('cloudinary').v2;
// Configuration is read from CLOUDINARY_URL automatically on first use.
console.log(cloudinary.config().cloud_name);
Alternative: explicit configuration
const cloudinary = require('cloudinary').v2;
cloudinary.config({
cloud_name: 'my-cloud',
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
secure: true
});
Behavior you should know
- Configuration is process-global:
cloudinary.config()affects every caller in the process. Pass per-call options as the last argument of a method when you need to override (for example a differentcloud_namefor one call). - Always import the v2 API once:
const cloudinary = require('cloudinary').v2;and then callcloudinary.uploader...directly — the imported object already is the v2 API. - Proxy support: set
api_proxyin config or theHTTPS_PROXYenvironment variable. - Account-level (provisioning) operations use
CLOUDINARY_ACCOUNT_URLinstead.
Validate configuration early
const { cloud_name, api_key, api_secret } = cloudinary.config();
if (!cloud_name || !api_key || !api_secret) {
throw new Error('Cloudinary is not configured: set CLOUDINARY_URL.');
}
Troubleshooting
Must supply cloud_name/Must supply api_key—CLOUDINARY_URLis missing or malformed; it must start withcloudinary://.Invalid api_key/api_secret mismatch— the key and secret do not belong to this cloud name; re-copy all three from the console.Invalid Signatureon uploads — the same cause as above: a wrongapi_secret. Uploads report it this way instead of naming the secret.
Related
- Get Cloudinary credentials — if you do not have an account yet.
- Sign a browser upload — keeping the secret server-side.
- Node SDK guide