Templify API Documentation

🚀 Introduction

Templify is an API-first SaaS that allows developers to create and manage templates and generate PDFs dynamically. This documentation provides the necessary details to integrate the Templify API seamlessly into your application.

🔐 Authentication

Templify API requires authentication using a Client ID and Secret ID. These credentials must be included in the request headers.

Authentication Headers:

Content-Type: application/json

To obtain your API key, sign in to your Templify account and navigate to the API Keys section.

🔗 API Endpoints

📄Generate PDF

Endpoint:

POST /convert/TEMPLATE_ID_HERE

Headers:

client_id: CLIENT_ID_HERE client_secret: CLIENT_SECRET_HERE

Request Body:

{
  "templateData": {
    "name": "John Doe",
    "invoice_number": "INV-1001",
    "items": [
      { "description": "Item 1", "price": 20 },
      { "description": "Item 2", "price": 30 }
    ]
  }
}

Response:

{
  data:PDF_DOC_IN_BYTE_ARRAY
}

📬 Request & Response Examples

cURL Example:

curl --location https://api.templify.cloud/convert/YOUR_TEMPLATE_ID_HERE' \
--header 'client_id: USER_ID_HERE' \
--header 'client_secret: CLIENT_SECRET_HERE' \
--header 'Content-Type: application/json' \
--header 'Cookie: NEXT_LOCALE=en' \
--data '{
  "templateData": {
         "name": "John Doe",
         "invoice_number": "INV-1001",
         "items": [
           { "description": "Item 1", "price": 20 },
           { "description": "Item 2", "price": 30 }
         ]
       }
     }'

📦 Template Versioning

Templify supports template versioning, enabling you to safely develop, test, and deploy updates to your templates without affecting the live (production) version.

🚀 Default Behavior

  • When youcreate a new template, it isautomatically published to production.
  • The template becomes immediately available to yourgenerate PDF API calls (unless in dev mode).

🛠 Updating Templates

When editing a template, you have two options:

  1. Update (Save Only)
    • Saves the changes in theunpublished (dev) version.
    • Ideal for testing changes inlower environments (e.g., staging).
    • These changesdo not affect the live template used in production.
  2. Update and Publish
    • Saves andpublishes the new version toproduction.
    • All future PDF generations (including fromgenerate API) will use this updated version.

🧪 Previewing Unpublished Versions (Dev Mode)

To preview changes made in dev (unpublished) mode:

  • Add?devMode=true to your preview or generation API calls.
  • This will render the latest saved (unpublished) version of the template.

Examplecurl to preview dev version:

curl --location https://api.templify.cloud/convert/YOUR_TEMPLATE_ID_HERE?devMode=true' \
--header 'client_id: USER_ID_HERE' \
--header 'client_secret: CLIENT_SECRET_HERE' \
--header 'Content-Type: application/json' \
--header 'Cookie: NEXT_LOCALE=en' \
--data '{
  "templateData": {
         "name": "John Doe",
         "invoice_number": "INV-1001",
         "items": [
           { "description": "Item 1", "price": 20 },
           { "description": "Item 2", "price": 30 }
         ]
       }
     }'

✅ Production PDF Generation (Default Behavior)

When you call the /convert API without devMode=true, Templify will always use the latest published version of the template.

❌ Error Handling

Templify API returns standard HTTP status codes.

Status CodeMeaningDescription
200OKRequest successful.
400Bad RequestMissing required parameters.
401UnauthorizedInvalid API key.
402UnauthorizedInsufficient credits.
404Not FoundTemplate ID does not exist.
500Server ErrorAn internal server error occurred.

Example error response:

{
  "error": "Template ID not found"
}

🔒 Security & Best Practices

  • Alwaysstore API keys securely and do not expose them in front-end code.
  • UseHTTPS for all API requests to ensure encryption.
  • Implementrate limiting to prevent abuse.

📞 Contact & Support

For any queries or issues, contact our support team:

  • Email: support@templify.cloud
  • API Status: https://status.templify.cloud

Happy coding! 🚀