Template Versioning
DocSpring supports versioning for PDF templates. This allows you to:
- Publish versions of your templates (e.g. 1.0.0, 1.0.1, etc.)
- Work on draft changes without affecting your production API calls
- Restore previous versions of templates
Restore a Template Version
Restore a template to a previous version. This will copy the template version's content to your draft template.
HTTP Request
POST https://api.docspring.com/api/v1/templates/<TEMPLATE_ID>/restore_version?version=1.0.0
Parameters
The following query parameters are supported:
version
(string, required): The version number to restore (e.g. "1.0.0")
Authentication
You must send an Authorization
header with the value Basic
followed by base 64 encoded token_id:token_secret
.
For example: Authorization: Basic dG9rZW5faWQ6dG9rZW5fc2VjcmV0Cg==
See the Authentication documentation for more information.
Example Code
var DocSpring = require('docspring')
var config = new DocSpring.Configuration()
config.apiTokenId = 'DOCSPRING_TOKEN_ID'
config.apiTokenSecret = 'DOCSPRING_TOKEN_SECRET'
client = new DocSpring.Client(config)
client.restoreTemplateVersion(
'YOUR_TEMPLATE_ID',
'1.0.0',
function (error, response) {
if (error) throw error
console.log(response)
}
)
$docspring = new \DocSpring\Client();
$docspring->getConfig()
->setUsername("DOCSPRING_API_TOKEN_ID")
->setPassword("DOCSPRING_API_TOKEN_SECRET");
$templateId = "tpl_1234567890abcdef01";
$version = "1.0.0";
$response = $docspring->restoreTemplateVersion($templateId, $version);
echo "Template restored to version " . $version;
ApiClient client = new ApiClient("api_token_basic", "DOCSPRING_API_TOKEN_ID", "DOCSPRING_API_TOKEN_SECRET");
api = client.createService(PdfApi.class);
String templateId = "tpl_1234567890abcdef01";
String version = "1.0.0";
retrofit2.Response<TemplateResponse> retrofitResponse = api.restoreTemplateVersion(
templateId,
version
).execute();
if (!retrofitResponse.isSuccessful()) {
logger.info(retrofitResponse.errorBody().string());
}
TemplateResponse response = retrofitResponse.body();
System.out.printf("Template restored to version %s", version);
using System;
using System.Diagnostics;
using DocSpring.Client.Api;
using DocSpring.Client.Client;
using DocSpring.Client.Model;
namespace Example
{
public class DocSpringExample
{
public void main()
{
Configuration.Default.Username = "DOCSPRING_TOKEN_ID";
Configuration.Default.Password = "DOCSPRING_TOKEN_SECRET";
var apiInstance = new PDFApi();
string templateId = "tpl_1234567890abcdef01";
string version = "1.0.0";
var response = apiInstance.RestoreTemplateVersion(templateId, version);
Debug.WriteLine(response);
}
}
}
Version Numbers
Template versions follow semantic versioning (MAJOR.MINOR.PATCH). You can use these however you like, but we recommend the following:
- MAJOR version for incompatible field changes, updates to the underlying PDF, etc.
- MINOR version for backwards-compatible field additions
- PATCH version for backwards-compatible minor changes and bug fixes
When you publish a new version:
- The current draft template is saved as a new version
- API submissions continue to use the latest published version
- You can safely make changes to the draft without affecting production API calls
Working with Versions
- Make changes to your draft template
- Test the changes using the
version=draft
query parameter in your API calls or web forms - When ready, publish the draft as a new version
- API submissions will automatically use the latest published version if no version is specified
- If needed, you can restore a previous version or delete specific versions
This versioning system allows you to safely iterate on your templates while maintaining stable production API endpoints.
See the Delete Template documentation for information about deleting specific template versions.