Templates
Get Template
Retrieve a specific PDF template by its unique identifier
GET
/
api
/
templates
/
{id}
Get Template by ID
curl --request GET \
--url https://api.curatepdf.com/api/templates/{id} \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.curatepdf.com/api/templates/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.curatepdf.com/api/templates/{id}"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.curatepdf.com/api/templates/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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;
}HttpResponse<String> response = Unirest.get("https://api.curatepdf.com/api/templates/{id}")
.header("x-api-key", "<api-key>")
.asString();package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.curatepdf.com/api/templates/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"success": true,
"template": {
"id": "template_123abc",
"name": "Invoice Template",
"template": {
"size": {
"width": 595,
"height": 842,
"orientation": "portrait"
},
"margins": {
"top": 72,
"right": 72,
"bottom": 72,
"left": 72
},
"sections": {
"header": {
"visible": true,
"height": 100,
"elements": [
{
"type": "text",
"content": "{{company.name}}",
"position": {
"x": 50,
"y": 20,
"width": 300,
"height": 40
},
"style": {
"fontSize": 24,
"fontWeight": "bold",
"color": "#000000"
}
}
]
},
"content": {
"visible": true,
"elements": [
{
"type": "text",
"content": "Invoice #{{invoiceNumber}}",
"position": {
"x": 50,
"y": 50,
"width": 200,
"height": 30
},
"style": {
"fontSize": 18,
"fontWeight": "bold"
}
}
]
},
"footer": {
"visible": false,
"elements": []
}
}
},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-02T12:30:00.000Z",
"user_id": "user_123"
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}
{
"success": false,
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template not found"
}
}
{
"success": false,
"error": {
"code": "DATABASE_ERROR",
"message": "An error occurred while retrieving the template"
}
}
Overview
The Get Template endpoint allows you to retrieve a specific PDF template using its unique identifier. This is useful for viewing template details, editing existing templates, or preparing to generate PDFs from a specific template.Use this endpoint to fetch template configuration data before generating PDFs or when building template management interfaces.
Path Parameters
The endpoint requires a single path parameter to identify the template:string
required
The unique identifier of the template you want to retrieve.Example:
template_123abcResponse Structure
The response contains the complete template object with all configuration details:boolean
Indicates whether the request was successful
object
The complete template object containing all template data
Show Template Object Properties
Show Template Object Properties
string
Unique identifier for the template
string
Human-readable name of the template
object
The template configuration object containing layout, styling, and element definitions
string
ISO 8601 timestamp when the template was created
string
ISO 8601 timestamp when the template was last modified
string
ID of the user who owns the template
Usage Examples
curl -X GET "https://api.curatepdf.com/api/templates/template_123abc" \
-H "x-api-key: YOUR_API_KEY"
const response = await fetch('https://api.curatepdf.com/api/templates/template_123abc', {
method: 'GET',
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const result = await response.json();
console.log('Template:', result.template);
import requests
url = "https://api.curatepdf.com/api/templates/template_123abc"
headers = {
"x-api-key": "YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
template_data = response.json()
print(f"Template Name: {template_data['template']['name']}")
<?php
$templateId = 'template_123abc';
$url = "https://api.curatepdf.com/api/templates/{$templateId}";
$headers = [
'x-api-key: YOUR_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$templateData = json_decode($response, true);
echo "Template Name: " . $templateData['template']['name'];
curl_close($ch);
?>
package main
import (
"fmt"
"io"
"net/http"
"encoding/json"
)
func main() {
templateID := "template_123abc"
url := fmt.Sprintf("https://api.curatepdf.com/api/templates/%s", templateID)
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var result map[string]interface{}
json.Unmarshal(body, &result)
template := result["template"].(map[string]interface{})
fmt.Printf("Template Name: %s\n", template["name"])
}
Response Example
Example Response
{
"success": true,
"template": {
"id": "template_123abc",
"name": "Invoice Template",
"template": {
"size": {
"width": 595,
"height": 842,
"orientation": "portrait"
},
"margins": {
"top": 72,
"right": 72,
"bottom": 72,
"left": 72
},
"sections": {
"header": {
"visible": true,
"height": 100,
"elements": [
{
"type": "text",
"content": "{{company.name}}",
"position": {
"x": 50,
"y": 20,
"width": 300,
"height": 40
},
"style": {
"fontSize": 24,
"fontWeight": "bold",
"color": "#000000"
}
}
]
},
"content": {
"visible": true,
"elements": [
{
"type": "text",
"content": "Invoice #{{invoiceNumber}}",
"position": {
"x": 50,
"y": 50,
"width": 200,
"height": 30
},
"style": {
"fontSize": 18,
"fontWeight": "bold"
}
}
]
},
"footer": {
"visible": false,
"elements": []
}
}
},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-02T12:30:00.000Z",
"user_id": "user_123"
}
}
Error Responses
The endpoint may return the following responses:{
"success": true,
"template": {
"id": "template_123abc",
"name": "Invoice Template",
"template": {
"size": {
"width": 595,
"height": 842,
"orientation": "portrait"
},
"margins": {
"top": 72,
"right": 72,
"bottom": 72,
"left": 72
},
"sections": {
"header": {
"visible": true,
"height": 100,
"elements": [
{
"type": "text",
"content": "{{company.name}}",
"position": {
"x": 50,
"y": 20,
"width": 300,
"height": 40
},
"style": {
"fontSize": 24,
"fontWeight": "bold",
"color": "#000000"
}
}
]
},
"content": {
"visible": true,
"elements": [
{
"type": "text",
"content": "Invoice #{{invoiceNumber}}",
"position": {
"x": 50,
"y": 50,
"width": 200,
"height": 30
},
"style": {
"fontSize": 18,
"fontWeight": "bold"
}
}
]
},
"footer": {
"visible": false,
"elements": []
}
}
},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-02T12:30:00.000Z",
"user_id": "user_123"
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}
{
"success": false,
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template not found"
}
}
{
"success": false,
"error": {
"code": "DATABASE_ERROR",
"message": "An error occurred while retrieving the template"
}
}
Use Cases
Template Preview
Display TemplatesFetch template details to show previews in your application’s template gallery or management interface.
PDF Generation
Pre-Generation SetupRetrieve template configuration before generating PDFs to validate data requirements or show generation options.
Template Editing
Modification WorkflowLoad existing template data into your template editor for users to modify layouts and styling.
Data Field Analysis
Dynamic Content PlanningAnalyze template structure to determine what data fields are required for successful PDF generation.
Next Steps
After retrieving a template, you can:- Generate PDFs using the Generate PDF endpoint
- Update the template using the template update endpoint
- Extract data fields to understand what data is needed for PDF generation
- Create template variations by copying and modifying the template configuration
Keep template IDs accessible in your application for quick retrieval. Consider caching frequently used templates to improve performance.
⌘I
Get Template by ID
curl --request GET \
--url https://api.curatepdf.com/api/templates/{id} \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.curatepdf.com/api/templates/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.curatepdf.com/api/templates/{id}"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.curatepdf.com/api/templates/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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;
}HttpResponse<String> response = Unirest.get("https://api.curatepdf.com/api/templates/{id}")
.header("x-api-key", "<api-key>")
.asString();package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.curatepdf.com/api/templates/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"success": true,
"template": {
"id": "template_123abc",
"name": "Invoice Template",
"template": {
"size": {
"width": 595,
"height": 842,
"orientation": "portrait"
},
"margins": {
"top": 72,
"right": 72,
"bottom": 72,
"left": 72
},
"sections": {
"header": {
"visible": true,
"height": 100,
"elements": [
{
"type": "text",
"content": "{{company.name}}",
"position": {
"x": 50,
"y": 20,
"width": 300,
"height": 40
},
"style": {
"fontSize": 24,
"fontWeight": "bold",
"color": "#000000"
}
}
]
},
"content": {
"visible": true,
"elements": [
{
"type": "text",
"content": "Invoice #{{invoiceNumber}}",
"position": {
"x": 50,
"y": 50,
"width": 200,
"height": 30
},
"style": {
"fontSize": 18,
"fontWeight": "bold"
}
}
]
},
"footer": {
"visible": false,
"elements": []
}
}
},
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-02T12:30:00.000Z",
"user_id": "user_123"
}
}
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}
{
"success": false,
"error": {
"code": "TEMPLATE_NOT_FOUND",
"message": "Template not found"
}
}
{
"success": false,
"error": {
"code": "DATABASE_ERROR",
"message": "An error occurred while retrieving the template"
}
}