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 you create a new template, it is automatically published to production.
- The template becomes immediately available to your generate PDF API calls (unless in dev mode).
🛠 Updating Templates#
When editing a template, you have two options:
- Update (Save Only)
- Saves the changes in the unpublished (dev) version.
- Ideal for testing changes in lower environments (e.g., staging).
- These changes do not affect the live template used in production.
- Update and Publish
- Saves and publishes the new version to production.
- All future PDF generations (including from generate 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.
Example curl 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 Code | Meaning | Description |
---|---|---|
200 | OK | Request successful. |
400 | Bad Request | Missing required parameters. |
401 | Unauthorized | Invalid API key. |
402 | Unauthorized | Insufficient credits. |
404 | Not Found | Template ID does not exist. |
500 | Server Error | An internal server error occurred. |
Example error response:
{ "error": "Template ID not found" }
🔒 Security & Best Practices#
- Always store API keys securely and do not expose them in front-end code.
- Use HTTPS for all API requests to ensure encryption.
- Implement rate 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! 🚀