Generate certificate of accomplishment

Case study

Often time, course participants will receive their certificate of accomplishment digitally and they can link the image of the certificate in their social profile network like LinkedIn.
If you are running these courses and would like to provide such certificate there are few things that you need to handle.
First, generating the certificate image itself. Then, most importantly ensuring certificate authenticity. Since the image can be doctored digitally, you need to employ your own system to handle certificate validation.
Stencil's secured signed image can solve these issues and you'll see how we can this is handled. Of course, in some complicated cases you would still need to roll your own system but for the majority of the time, this is sufficient.


Design your certificate template

AWS-like certificate
For this design, candidate's name can be customized later using our API.

Creating Signed URL for Image

Getting the necessary information

You'll need some information that can be retrieved from Console > Integrations > Secure Signed Image
Information required in the next step

Generate the URL

The section Basic explains how the URL is generated. We can use the Python code provided and modifying it based on the information we get. We also need to specify the proper modifications that will be sent to our API.
For example this is the Python code we use with the certificate template that was created from previous step.
import json
import hmac
import hashlib
import base64
def base64_encode(string):
Removes any `=` used as padding from the encoded string.
encoded = base64.b64encode(string.encode())
encoded = encoded.rstrip(b'=')
return encoded
def generate_url():
user_id = "be6a052e-bce8-4c14-8bbb-ea6b6f9941d5"
secret_key = "secretzzzz"
base_id = "TEafv3AfNptmzii4zj2jkc"
modifications = [
{ "name": "text_candidate", "text": "John Wick" }
# ensure no spaces in json output
encoded = json.dumps(modifications, separators=(',', ':'))
encoded = base64_encode(encoded).decode()
parameters = "{user_id}+{base_id}+{modifications}".format(user_id=user_id, base_id=base_id, modifications=encoded)
signature =, parameters.encode(), hashlib.sha256).hexdigest()
url = "{user_id}/{base_id}.png?modifications={modifications}&s={signature}".format(
if __name__ == "__main__":
Running the above code gives us the following output,


Visiting the URL gives us the certificate,
Signed image with candidate's name

Determining authenticity

All certificates generated and hot-linked using our CDN can be considered as authentic i.e. all links started with are authentic.


All images are signed with your secret key. Trying to modify the data will invalidate the signature.
Continue reading to know the details.
Let's break it down. The URL can be broken down to several parts,
This is the base URL
Base64 encoded modifications
Signature that we use to determine the authenticity of the request
If we decode the base64 modifications, we will get the following output,
[{"name":"text_candidate","text":"John Wick"}]
You might think, "Hey what if I modify the value and encode it back. That should work, right?"
Let's just do that. We changed the value to John the Impostor and got back the following base64 encoded string.
[{"name":"text_candidate","text":"John the Impostor"}]
Putting everything together we get back,
Visiting the URL gave us the following image instead,
Invalid image
If you look at the response header, you should see the following header
x-stencil-error: Invalid signature
The reason is that, the signature doesn't contain the right modifications and thus rejected by our server. By ensuring the image is signed with our secret key, we can ensure image authenticity. Simple, right?

No-code URL generation

As you can see, we have to run one Python script to generate the link for our certificate. There are few things we can do so that we don't have to run the Python script each time. Here are few options you can explore to do this.

1. AWS Lambda

You can modify the Python script as a lambda function that accepts the candidate's name and when run, it will return the generated URL.
You can then combine this with other tools such as Airtable where you can input list of names, and use any automation services like Zapier, Integromat, UiPath and others to run the lambda function when your Airtable rows are added/updated and update the corresponding rows with the generated link.

2. Airtable

Airtable has scripting ability and you can write a similar script to generate the link.

3. Google Sheet

Google Sheet also has scripting ability and you can write a similar script to generate the link.
There are numerous of ways to do this and these are just some of them.
We have created a guide utilizing AWS Lambda for this. You can find it here