Code Examples

Ready-to-use code examples in popular programming languages

Why Choose Our Certificate API?

🔧 Auto Resizing

We auto-resize text so you don't have to worry about people with long names

🎨 Customization

Change certificate settings to your liking such as font colors, font styles and more

📱 QR Code Integration

Automatic QR code generation with your custom verification URL

🆔 Custom Certificate IDs

Use your own certificate ID format or auto-generate secure ULIDs

cURL Examples

Basic Certificate Generation

# Generate a certificate with minimal parameters (returns JSON) curl -H "X-API-Key: your_api_key" \ "https://certgenapi.skalatec.com/certificate?certificate_name=Jane%20Smith&template_url=https://certgenapi.skalatec.com/public/templates/classic-template.pdf&project=graduation-2024"

Advanced Certificate with QR Code

# Generate a Modern style certificate with QR code (returns JSON) curl -H "X-API-Key: your_api_key" \ "https://certgenapi.skalatec.com/certificate?certificate_name=John%20Doe&template_url=https://certgenapi.skalatec.com/public/templates/modern-template.pdf&project=tech-conference&style=Modern&certificate_id_prefix_url=https://verify.mycompany.com"

POST Request with Custom Certificate ID

# Generate certificate using POST with custom ID curl -X POST \ -H "X-API-Key: your_api_key" \ -H "Content-Type: application/json" \ -d '{"certificate_name":"John Doe","template_url":"https://certgenapi.skalatec.com/public/templates/modern-template.pdf","project":"tech-conference","style":"Modern","certificate_id":"CUSTOM-2024-001"}' \ "https://certgenapi.skalatec.com/certificate"

JavaScript / Node.js

Fetch API (Browser)

const generateCertificate = async (name, project) => { const params = new URLSearchParams({ certificate_name: name, template_url: 'https://certgenapi.skalatec.com/public/templates/classic-template.pdf', project: project, style: 'Modern' }); const response = await fetch( `https://certgenapi.skalatec.com/certificate?${params}`, { headers: { 'X-API-Key': 'your_api_key' } }); if (response.ok) { const result = await response.json(); console.log('Certificate generated:', result.data.certificate_id); console.log('Download URL:', result.data.uploaded_url); // Open the certificate in new tab window.open(result.data.uploaded_url, '_blank'); } }; // Usage generateCertificate('John Doe', 'my-event');

Node.js with Axios

const axios = require('axios'); const fs = require('fs'); const generateCertificate = async (name, project) => { try { const response = await axios({ method: 'GET', url: 'https://certgenapi.skalatec.com/certificate', headers: { 'X-API-Key': 'your_api_key' }, params: { certificate_name: name, template_url: 'https://certgenapi.skalatec.com/public/templates/modern-template.pdf', project: project, style: 'Professional' }, responseType: 'json' }); // Get the certificate URL console.log('Certificate ID:', response.data.data.certificate_id); console.log('Download URL:', response.data.data.uploaded_url); } catch (error) { console.error('Error:', error.response?.data || error.message); } }; // Usage generateCertificate('Jane Smith', 'workshop-2024');

Python

Using Requests

import requests def generate_certificate(name, project): url = "https://certgenapi.skalatec.com/certificate" headers = { "X-API-Key": "your_api_key" } params = { "certificate_name": name, "template_url": "https://certgenapi.skalatec.com/public/templates/classic-template.pdf", "project": project, "style": "Classic" } response = requests.get(url, headers=headers, params=params) if response.status_code == 200: result = response.json() print(f"Certificate ID: {result['data']['certificate_id']}") print(f"Download URL: {result['data']['uploaded_url']}") else: print(f"Error: {response.status_code} - {response.text}") # Usage generate_certificate("Alice Johnson", "training-2024")

Async with aiohttp

import aiohttp import asyncio async def generate_certificate(name, project): url = "https://certgenapi.skalatec.com/certificate" headers = {"X-API-Key": "your_api_key"} params = { "certificate_name": name, "template_url": "https://certgenapi.skalatec.com/public/templates/modern-template.pdf", "project": project, "style": "Modern" } async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, params=params) as response: if response.status == 200: result = await response.json() print(f"Certificate ID: {result['data']['certificate_id']}") print(f"Download URL: {result['data']['uploaded_url']}") else: error = await response.text() print(f"Error: {response.status} - {error}") # Usage asyncio.run(generate_certificate("Bob Wilson", "conference-2024"))

PHP

Using cURL

<?php function generateCertificate($name, $project) { $url = "https://certgenapi.skalatec.com/certificate"; $params = http_build_query([ 'certificate_name' => $name, 'template_url' => 'https://certgenapi.skalatec.com/public/templates/professional-template.pdf', 'project' => $project, 'style' => 'Professional' ]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url . '?' . $params); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-API-Key: your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode === 200) { $result = json_decode($response, true); echo "Certificate ID: " . $result['data']['certificate_id'] . "\n"; echo "Download URL: " . $result['data']['uploaded_url'] . "\n"; } else { echo "Error: HTTP $httpCode\n"; } } // Usage generateCertificate('Sarah Davis', 'certification-program'); ?>

QR Code Verification Examples

Generate Certificate with Custom Verification URL

# Generate certificate with QR code pointing to your verification system curl -H "X-API-Key: your_api_key" \ "https://certgenapi.skalatec.com/certificate?certificate_name=Jane%20Smith&template_url=https://certgenapi.skalatec.com/public/templates/classic-template.pdf&project=graduation-2024&certificate_id_prefix_url=https://your-verification-site.com/verify"

Building a Verification Endpoint (Node.js)

const express = require('express'); const app = express(); // Simple in-memory database (use a real database in production) const certificateDatabase = new Map(); // Verification endpoint that QR codes will link to app.get('/verify/:certificateId', (req, res) => { const { certificateId } = req.params; // Look up certificate in your database const certificate = certificateDatabase.get(certificateId); if (certificate) { res.send(` <html> <body style="font-family: Arial, sans-serif; text-align: center; padding: 2rem;"> <h1>✅ Certificate Verified</h1> <p><strong>Recipient:</strong> ${certificate.name}</p> <p><strong>Program:</strong> ${certificate.program}</p> <p><strong>Issued:</strong> ${certificate.issueDate}</p> <p><strong>Certificate ID:</strong> ${certificateId}</p> </body> </html> `); } else { res.status(404).send(` <html> <body style="font-family: Arial, sans-serif; text-align: center; padding: 2rem;"> <h1>❌ Certificate Not Found</h1> <p>Certificate ID ${certificateId} not found in our system.</p> </body> </html> `); } }); // Store certificate when generated (called by webhook) app.post('/webhook/certificate', express.json(), (req, res) => { const { data } = req.body; if (data.certificate_id && data.certificate_name) { certificateDatabase.set(data.certificate_id, { name: data.certificate_name, program: data.project_folder, issueDate: new Date().toLocaleDateString() }); console.log(`Stored certificate: ${data.certificate_id}`); } res.status(200).send('OK'); }); app.listen(3000, () => { console.log('Verification server running on port 3000'); });

Python Flask Verification Example

from flask import Flask, request, render_template_string import sqlite3 from datetime import datetime app = Flask(__name__) # Initialize SQLite database def init_db(): conn = sqlite3.connect('certificates.db') conn.execute(''' CREATE TABLE IF NOT EXISTS certificates ( id TEXT PRIMARY KEY, name TEXT, program TEXT, issue_date TEXT ) ''') conn.close() # Verification endpoint @app.route('/verify/<certificate_id>') def verify_certificate(certificate_id): conn = sqlite3.connect('certificates.db') cursor = conn.execute( 'SELECT name, program, issue_date FROM certificates WHERE id = ?', (certificate_id,) ) certificate = cursor.fetchone() conn.close() if certificate: return render_template_string(''' <html> <body style="font-family: Arial, sans-serif; text-align: center; padding: 2rem;"> <h1>✅ Certificate Verified</h1> <p><strong>Recipient:</strong> {{ name }}</p> <p><strong>Program:</strong> {{ program }}</p> <p><strong>Issued:</strong> {{ issue_date }}</p> </body> </html> ''', name=certificate[0], program=certificate[1], issue_date=certificate[2]) else: return 'Certificate not found', 404 # Webhook to store certificates @app.route('/webhook/certificate', methods=['POST']) def webhook(): data = request.json['data'] conn = sqlite3.connect('certificates.db') conn.execute( 'INSERT OR REPLACE INTO certificates VALUES (?, ?, ?, ?)', (data['certificate_id'], data['certificate_name'], data['project_folder'], datetime.now().strftime('%Y-%m-%d')) ) conn.commit() conn.close() return 'OK' if __name__ == '__main__': init_db() app.run(port=3000)

Webhook Integration Example

Node.js/Express Webhook Handler

const express = require('express'); const app = express(); app.use(express.json()); app.post('/webhooks/certificate', (req, res) => { const { event, timestamp, data } = req.body; if (event === 'certificate.generated') { console.log(`✅ Certificate generated for ${data.certificate_name}`); console.log(`📄 Download URL: ${data.uploaded_url}`); console.log(`🔗 Certificate ID: ${data.certificate_id}`); // Process successful certificate generation // - Send email notification // - Update database // - Trigger next workflow step } else if (event === 'certificate.failed') { console.error(`❌ Certificate failed for ${data.certificate_name}`); console.error(`Error: ${data.error}`); // Handle certificate generation failure // - Log error // - Retry logic // - Notify administrators } res.status(200).send('OK'); }); app.listen(3000, () => { console.log('Webhook server running on port 3000'); });

Generate Certificate with Webhook

curl -H "X-API-Key: your_api_key" \ "https://certgenapi.skalatec.com/certificate?certificate_name=Alice%20Johnson&template_url=https://certgenapi.skalatec.com/public/templates/modern-template.pdf&project=webinar-series&style=Modern&webhook_url=https://your-app.com/webhooks/certificate"

Sample JSON Response

{ "event": "certificate.generated", "timestamp": "2025-06-26T12:00:00.000Z", "data": { "certificate_name": "Alice Johnson", "certificate_id": "CID-01HKQRST9V8WXY2Z3ABC4DEF5G", "style": "Modern", "uploaded_url": "https://storage.example.com/certificates/alice-johnson-CID-123.pdf", "project_folder": "webinar-series", "certificate_id_prefix_url": "https://your-verification-site.com/verify" } }
💡 Pro Tips:
  • Always handle errors gracefully in production code
  • Use webhooks for asynchronous processing in high-volume applications
  • Cache template URLs for better performance
  • Implement retry logic for network failures
  • Store API keys securely using environment variables