Generate PDF from template by name
curl --request POST \
--url https://peedief.com/api/templates/by-name/{templateName}/pdf \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"contextJson": {},
"fileName": "<string>"
}
'import requests
url = "https://peedief.com/api/templates/by-name/{templateName}/pdf"
payload = {
"contextJson": {},
"fileName": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({contextJson: {}, fileName: '<string>'})
};
fetch('https://peedief.com/api/templates/by-name/{templateName}/pdf', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://peedief.com/api/templates/by-name/{templateName}/pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contextJson' => [
],
'fileName' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://peedief.com/api/templates/by-name/{templateName}/pdf"
payload := strings.NewReader("{\n \"contextJson\": {},\n \"fileName\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://peedief.com/api/templates/by-name/{templateName}/pdf")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"contextJson\": {},\n \"fileName\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://peedief.com/api/templates/by-name/{templateName}/pdf")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contextJson\": {},\n \"fileName\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"downloadUrl": "<string>",
"previewUrl": "<string>",
"fileName": "<string>",
"fileSize": 123,
"templateId": "<string>",
"templateName": "<string>"
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}API Documentation
Generate PDF from Template
Generate a PDF by rendering a named template with provided context data
POST
/
api
/
templates
/
by-name
/
{templateName}
/
pdf
Generate PDF from template by name
curl --request POST \
--url https://peedief.com/api/templates/by-name/{templateName}/pdf \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"contextJson": {},
"fileName": "<string>"
}
'import requests
url = "https://peedief.com/api/templates/by-name/{templateName}/pdf"
payload = {
"contextJson": {},
"fileName": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({contextJson: {}, fileName: '<string>'})
};
fetch('https://peedief.com/api/templates/by-name/{templateName}/pdf', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://peedief.com/api/templates/by-name/{templateName}/pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contextJson' => [
],
'fileName' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://peedief.com/api/templates/by-name/{templateName}/pdf"
payload := strings.NewReader("{\n \"contextJson\": {},\n \"fileName\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://peedief.com/api/templates/by-name/{templateName}/pdf")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"contextJson\": {},\n \"fileName\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://peedief.com/api/templates/by-name/{templateName}/pdf")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contextJson\": {},\n \"fileName\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"downloadUrl": "<string>",
"previewUrl": "<string>",
"fileName": "<string>",
"fileSize": 123,
"templateId": "<string>",
"templateName": "<string>"
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}{
"success": false,
"error": "<string>",
"details": [
{}
]
}Generate PDF from Template
Create a PDF using your custom template and structured JSON data. This is the primary endpoint for template-based PDF generation.Path Parameters
templateName(string, required): The name of your custom template created in the dashboard
Request Headers
x-api-key(string, required): Your API key for authenticationContent-Type:application/json
Request Body
{
"contextJson": {
// Your template data - structure depends on your template
"customerName": "John Doe",
"invoiceNumber": "INV-001",
"amount": 150.00
},
"fileName": "optional-filename.pdf"
}
Response
Success (200):{
"success": true,
"downloadUrl": "https://peedief.com/download/abc123...",
"previewUrl": "https://peedief.com/preview/abc123...",
"fileName": "invoice-001.pdf",
"fileSize": 245760,
"templateId": "tpl_abc123",
"templateName": "invoice"
}
previewUrl as the src for an iframe (or <object> tag) when you want to render a read-only preview directly in your UI. The URL is short-lived and expires alongside the download link.
Error (400/401/404):
{
"success": false,
"error": "Template not found",
"code": "TEMPLATE_NOT_FOUND"
}
Example Request
curl -X POST "https://peedief.com/api/templates/by-name/my-invoice-template/pdf" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contextJson": {
"companyName": "Acme Corp",
"customerInfo": {
"name": "Jane Smith",
"email": "jane@example.com",
"address": "123 Main St, City, State 12345"
},
"items": [
{
"description": "Product A",
"quantity": 2,
"price": 50.00
}
],
"total": 100.00,
"dueDate": "2024-02-15"
},
"fileName": "invoice-jane-smith.pdf"
}'
Template Data Structure
ThecontextJson object structure depends entirely on your template design. Common patterns include:
Certificate Template:
{
"contextJson": {
"recipientName": "John Smith",
"courseName": "Advanced JavaScript",
"completionDate": "2024-01-30",
"instructor": "Dr. Sarah Wilson",
"grade": "A+"
}
}
{
"contextJson": {
"invoiceNumber": "INV-2024-001",
"customerName": "TechStart Inc",
"services": [
{
"description": "Web Development",
"hours": 40,
"rate": 125.00
}
],
"subtotal": 5000.00,
"taxRate": 0.08,
"total": 5400.00
}
}
Error Codes
TEMPLATE_NOT_FOUND: Template with specified name doesn’t existINVALID_API_KEY: API key is invalid or expiredMISSING_TEMPLATE_DATA: Required template fields are missingQUOTA_EXCEEDED: Account has exceeded PDF generation limits
Authorizations
Path Parameters
URL-encoded name of the template to use for PDF generation
Body
application/json
Response
PDF generated successfully
Whether the PDF generation was successful
Example:
true
Signed URL to download the generated PDF (expires in 1 hour)
Signed URL to preview the generated PDF in an iframe (expires in 1 hour)
Name of the generated PDF file
Size of the generated PDF in bytes
ID of the template used for generation
Name of the template used for generation