Update Template
Update an existing template using the Docstron API. This endpoint allows you to modify template content, styling, status, and other properties.
Endpoint
Section titled “Endpoint”PATCH https://api.docstron.com/v1/templates/{template_id}
Authentication
Section titled “Authentication”This endpoint requires authentication using a Bearer token. Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Parameters
Section titled “Parameters”Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
template_id | string | Yes | The unique identifier of the template (e.g., template-773753f0-590a-4855-acc8-9e6c9cf8a8a0 ) |
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
content | string | Yes | Updated HTML content of the template |
name | string | No | Updated name of the template |
is_active | boolean | No | Whether the template is active (true ) or inactive (false ) |
extra_css | string | No | Updated additional CSS rules for PDF styling |
Request Examples
Section titled “Request Examples”curl --location --request PATCH 'https://api.docstron.com/v1/templates/template-773753f0-590a-4855-acc8-9e6c9cf8a8a0' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --data '{ "name": "Template 1 updated", "is_active": false, "content": "<h1>Hello World! Updated</h1>" }'
Response
Section titled “Response”200 - Success Response
{ "success": true, "message": "Request successful", "data": { "template_id": "template-c2465c0b-fc54-4672-b9ac-7446886cd6de", "application_id": "app-7b4d78fb-820c-4ca9-84cc-46953f210301", "name": "Template 1", "is_active": true, "created_at": "2025-10-14T16:39:19", "updated_at": "2025-10-14T16:39:19", "content": "<h1>Hello World!</h1>", "extra_css": "@page { margin: 3cm; @bottom-left { color: #1ee494; content: '♥ Thank you!'; } }" }}
Response Fields
Section titled “Response Fields”Field | Type | Description |
---|---|---|
template_id | string | Unique identifier of the template |
application_id | string | The application ID associated with this template |
name | string | Name of the template |
is_active | boolean | Whether the template is active (true ) or inactive (false ) |
created_at | string | Timestamp when the template was created |
updated_at | string | Timestamp when the template was last updated |
content | string | HTML content of the template |
extra_css | string | Additional CSS rules for PDF styling |
Error Responses
Section titled “Error Responses”422 - Unprocessable Entity
Returned when the request body is invalid or no fields are provided for update.
{ "success": false, "message": "Validation failed", "errors": [ { "field": "content", "message": "Field required", "type": "missing" } ]}
Common causes:
- Empty request body
- Invalid JSON format
- Invalid data types for fields
Solution: Verify that the content
field is provided and properly formatted in the request body.
404 - Template Not Found
Returned when the provided template_id
does not exist or is invalid.
{ "success": false, "message": "Template not found.", "data": []}
Common causes:
- Invalid or mistyped
template_id
- Template has been deleted
- The template belongs to a someone else
Solution: Verify the template_id
is correct by using the Get Template endpoint.
500 - Internal Server Error
Returned when an unexpected server error occurs while updating the template.
{ "success": false, "message": "Failed to update the template.", "data": []}
Common causes:
- Temporary server issue
- Database connectivity problem
- Service maintenance
Solution: Wait a few moments and retry the request. If the problem persists, contact support@docstron.com.
Need Help?
Section titled “Need Help?”If you have questions about applications or need assistance:
- 📧 Email: support@docstron.com
- 💬 Live Chat: Available in your dashboard
- 📚 Documentation: You’re reading it!