API signature reference
Cloudinary uses digital signatures both to verify the integrity of a message and to provide authentication for communicating over the Internet using the HTTP protocol. Signatures can help ensure that the message was not tampered with during transit and provide an additional layer of security to ensure that even if the transport channel has been compromised, the contents can still be verified.
Cloudinary's SDKs take care of the signature generation where needed for communication with Cloudinary, so you will only need to manually write the code for generating a signature when NOT using our SDKs or when you want to verify a signature that was sent from Cloudinary.
The following table summarizes Cloudinary's signature usage and the payload signed in each case.
Signature usage | Example use case | Payload to sign |
---|---|---|
Generating authentication signatures | Authenticating a POST request | A string with the parameters used in the POST request to Cloudinary:
|
Verifying notification signatures | Verifying a signature in the header of a notification sent from Cloudinary | A string containing the entire response body with the X-Cld-Timestamp value appended on the end of the string. |
Generating delivery URL signatures | The signature component of a signed delivery URL of the format: /s--SIGNATURE--/ |
A string including all the components of the delivery URL that will come after the signature component. |
Verifying signatures in the JSON response | Verifying the signature parameter returned in the response to a method call. | A string with the public_id and version parameters, separated from their values with an = and then joined together with an & . |
Signature generation
To generate the signature, append your API secret to the end of the payload to sign described above, and then create a hexadecimal message digest (hash value) of the string using a SHA-1 (or SHA-256) function.
For example:
require 'digest' signature = Digest::SHA1.digest(payload_to_sign + api_secret)
signature = sha1($payload_to_sign . $api_secret)
import hashlib signature = hashlib.sha1(payload_to_sign + api_secret).hexdigest()
var sha1 = require('sha1'); var signature = sha1(payload_to_sign + api_secret);
import static org.apache.commons.codec.digest.MessageDigestAlgorithms.SHA_224; string signature = DigestUtils.sha1Hex(payload_to_sign + api_secret)