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>'
{
  "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"
  }
}

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:
id
string
required
The unique identifier of the template you want to retrieve.Example: template_123abc

Response Structure

The response contains the complete template object with all configuration details:
success
boolean
Indicates whether the request was successful
template
object
The complete template object containing all template data

Usage Examples

curl -X GET "https://api.curatepdf.com/api/templates/template_123abc" \
  -H "x-api-key: YOUR_API_KEY"

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"
  }
}

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.

Authorizations

x-api-key
string
header
required

API key for accessing the Docurate PDF API

Path Parameters

id
string
required

Template ID

Response

200
application/json

Template retrieved successfully

The response is of type object.