Templates
This is a stable API but uses an older format. This means some functionality may not be available (for example test calls and Postman integration).
Use the templates API to create and manage CMS templates.
Retrieve version history for a website page template to understand when a certain change was made.
/content/api/v2/templates
Get all templates. Supports paging and filtering.
Requirements
Parameters
The number of items to return. Defaults to 20.
The offset set to start returning rows from. Defaults to 0.
exact, gt, lt
exact
exact
exact
exact
Response
Example GET URL:
http://api.hubapi.com/content/api/v2/templates
Example response:
{
"total_count":1,
"objects":[
{
"category_id":1,
"cdn_minified_url":"",
"cdn_url":"http://cdn2.hubspot.net/hub/62515/hub_generated/template_resource/1382477851647/custom/page/examples/simple-template.html",
"deleted_at":0,
"folder":"examples",
"generated_from_layout_id":null,
"id":359393980,
"is_available_for_new_content":true,
"is_from_layout":false,
"is_read_only":false,
"label":"Simple-template",
"linked_style_id":"",
"path":"custom/page/examples/simple-template.html",
"portal_id":62515,
"source":"The template source goes here",
"template_type":"4",
"thumbnail_width":154,
"type":"",
"updated":1382477851000,
"updated_by":""
}
],
"limit":20,
"offset":0
}
JSON Fields returned in the response
Parameter name | Type | Description |
---|---|---|
archived | bool | If True, the template will not show up in your dashboard, although the template will still be live |
category_id | string | The category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page |
cdn_minified_url | string | For JavaScript and CSS, this is the URL of the version of the content that has been rendered, minified, and uploaded to our Content Delivery Network |
cdn_url | string | For non-HTML templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN |
deleted_at | long | When the template was deleted, in milliseconds since the epoch. Zero if the template was never deleted. Use a DELETE request to template the page, do not set this directly. |
folder | string | The folder this template lives in |
generated_from_layout_id | string | The id of the layout that generated this template |
id | string | The unique id of the template |
is_available_for_new_content | string | True if this template will show up in the content creation screen |
is_from_layout | string | True if template was generated by publishing a layout |
is_read_only | string | True if the template can only be read |
label | string | The label of the template as it shows up in the template builder |
path | string | The path of the template, as should be used for HubL include statements |
source | string | The markup of the template |
thumbnail_path | string | The thumbnail image of the template |
updated | long | When the template was last updated, in milliseconds since the epoch |
/content/api/v2/templates/:template_id
Get a specific template by ID.
Requirements
Parameters
The unique id of the template.
Response
xxxxxxxxxx
Example GET URL:
http://api.hubapi.com/content/api/v2/templates/359393980
Example response:
{
"category_id":1,
"cdn_minified_url":"",
"cdn_url":"http://cdn2.hubspot.net/hub/62515/hub_generated/template_resource/1382477851647/custom/page/examples/simple-template.html",
"deleted_at":0,
"folder":"examples",
"generated_from_layout_id":null,
"id":359393980,
"is_available_for_new_content":true,
"is_from_layout":false,
"is_read_only":false,
"label":"Simple-template",
"linked_style_id":"",
"path":"custom/page/examples/simple-template.html",
"portal_id":62515,
"source":"The template source goes here",
"template_type":"4",
"thumbnail_path":null,
"thumbnail_width":154,
"type":"",
"updated":1382477851000,
"updated_by":""
}
JSON Fields returned in the response
Parameter name | Type | Description |
---|---|---|
archived | bool | If True, the template will not show up in your dashboard, although the template will still be live |
category_id | string | The category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page |
cdn_minified_url | string | For javascript and css, this is the URL of the version of the content that has been rendered, minified, and uploaded to our Content Delivery Network |
cdn_url | string | For non-html templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN |
deleted_at | long | When the template was deleted, in milliseconds since the epoch. Zero if the template was never deleted. Use a DELETE request to template the page, do not set this directly. |
folder | string | The folder this template lives in |
generated_from_layout_id | string | The id of the layout that generated this template |
id | string | The unique id of the template |
is_available_for_new_content | string | True if this template will show up in the content creation screen |
is_from_layout | string | True if template was generated by publishing a layout. |
is_read_only | string | True if the template can only be read |
label | string | The label of the template as it shows up in the template builder |
path | string | The path of the template, as should be used for HubL include statements |
source | string | The markup of the template |
thumbnail_path | string | The thumbnail image of the template |
updated | long | When the template was last updated, in milliseconds since the epoch |
Gets the current contents of the auto-save buffer
Gets the current contents of the auto-save buffer
/content/api/v2/templates/:template_id/buffer
The auto-save buffer is updated continuously when a user is editing the content through the UI. Only when the user clicks "Save" or "Publish" does the auto-save buffer get copied to the live object.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example URL:
http://api.hubapi.com/content/api/v2/templates/359393980/buffer
Example response:
{
"attached_stylesheets": [
],
"category_id": 1,
"cdn_minified_url": "",
"cdn_url": "http://cdn1.hubspot.com/hub/62515/hub_generated/template_resource/1382477851647/custom/page/examples/simple-template.html",
"deleted_at": 0,
"enable_domain_stylesheets": null,
"folder": "examples",
"generated_from_layout_id": null,
"id": 359393980,
"include_default_custom_css": null,
"is_available_for_new_content": true,
"is_deletable": 1,
"is_from_layout": false,
"is_read_only": false,
"is_renameable": 1,
"is_theme_layout": false,
"label": "Simple-template",
"last_edit_session_id": null,
"last_edit_update_id": null,
"linked_style_id": "",
"migrated_from_style_manager": false,
"path": "custom/page/examples/simple-template.html",
"portal_id": 62515,
"source": {% raw %}"<html>\n <head>\n {{ content.html_title }}\n {{ standard_header_includes }}\n </head>\n <body>\n {% rich_text \"main_content\" html=\"This is the simplest possible template\" %}\n {{ standard_footer_includes }}\n </body>\n</html>",{% endraw %}
"template_type": 4,
"thumbnail_path": "http://cdn1.hubspot.com/hubshot/13/10/23/bd2b1b76-ae6e-4e49-963a-0bcbb0d10fa4.png",
"thumbnail_width": 490,
"type": "",
JSON Fields returned in the response
Parameter name | Type | Description |
---|---|---|
category_id | string | The category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page |
cdn_minified_url | string | For javascript and css, this is the URL of the version of the content that has been rendered, minified, and uploaded to our Content Delivery Network |
cdn_url | string | For non-html templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN |
created | long | When the template was first created, in milliseconds since the epoch |
deleted_at | long | When the template was deleted, in milliseconds since the epoch. Zero if the template was never deleted. Use a DELETE request to template the page, do not set this directly. |
folder | string | The folder this template lives in |
generated_from_layout_id | string | The id of the layout that generated this template |
id | string | The unique id of the template |
is_available_for_new_content | string | True if this template will show up in the content creation screen |
is_from_layout | string | True if template was generated by publishing a layout. |
is_read_only | string | True if the template can only be read |
label | string | The label of the template as it shows up in the template builder |
path | string | The path of the template, as should be used for HubL include statements |
source | string | The markup of the template |
thumbnail_path | string | The thumbnail image of the template |
updated | long | When the template was last updated, in milliseconds since the epoch |
Determine if the auto-save buffer differs from the live Template
Determine if the auto-save buffer differs from the live Template
/content/api/v2/templates/:template_id/has-buffered-changes
Returns a dictionary: {"has_buffered_changes": false/true}
depending on if the buffer is different from the live object.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example GET URL:
http://api.hubapi.com/content/api/v2/templates/359393980/has-buffered-changes
Example response:
{
"has_changes" : true
}
/content/api/v2/templates/:template_id/versions
Get all previous versions of a template.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example URL:
http://api.hubapi.com/content/api/v2/templates/359393980/versions
Example response:{% raw %}
[
{
"object": {
"attached_stylesheets": [
],
"category_id": 1,
"cdn_minified_url": "",
"cdn_url": "",
"deleted_at": 0,
"enable_domain_stylesheets": null,
"folder": "examples",
"generated_from_layout_id": null,
"id": 359393980,
"include_default_custom_css": null,
"is_available_for_new_content": true,
"is_deletable": 1,
"is_from_layout": false,
"is_read_only": false,
"is_renameable": 1,
"is_theme_layout": false,
"label": "Simple-template",
"last_edit_session_id": null,
"last_edit_update_id": null,
"linked_style_id": "",
"migrated_from_style_manager": false,
"path": "custom/page/examples/simple-template.html",
"portal_id": 62515,
"source": "<html>\n <head>\n {{ content.html_title }}\n {{ standard_header_includes }}\n </head>\n <body>\n {% rich_text \"main_content\" html=\"This is the simplest possible template\" %}\n {{ standard_footer_includes }}\n </body>\n</html>",
"template_type": "4",
"thumbnail_path": "http://cdn1.hubspot.com/hubshot/13/10/23/bd2b1b76-ae6e-4e49-963a-0bcbb0d10fa4.png",
"thumbnail_width": 490,
/content/api/v2/templates/:template_id/versions/:version_id
Get a specific revision of a template. Version id is the id of the version from the list previous versions endpoint.
Requirements
Parameters
Unique identifier for a particular blog.
Unique identifier for a specific version.
Response
xxxxxxxxxx
Example GET URL:
http://api.hubapi.com/content/api/v2/templates/359393980/versions/4596453633
Example response:{% raw %}
{
"attached_stylesheets": [
],
"category_id": 1,
"cdn_minified_url": "",
"cdn_url": "http://cdn1.hubspot.com/hub/62515/hub_generated/template_resource/1382477851647/custom/page/examples/simple-template.html",
"deleted_at": 0,
"enable_domain_stylesheets": null,
"folder": "examples",
"generated_from_layout_id": null,
"id": 359393980,
"include_default_custom_css": null,
"is_available_for_new_content": 1,
"is_deletable": 1,
"is_from_layout": false,
"is_read_only": false,
"is_renameable": 1,
"is_theme_layout": false,
"label": "Simple-template",
"last_edit_session_id": null,
"last_edit_update_id": null,
"linked_style_id": "",
"migrated_from_style_manager": false,
"path": "custom/page/examples/simple-template.html",
"portal_id": 62515,
"source": "<html>\n <head>\n {{ content.html_title }}\n {{ standard_header_includes }}\n </head>\n <body>\n {% rich_text \"main_content\" html=\"This is the simplest possible template\" %}\n {{ standard_footer_includes }}\n </body>\n</html>",
"template_type": 4,
"thumbnail_path": "http://cdn1.hubspot.com/hubshot/13/10/23/bd2b1b76-ae6e-4e49-963a-0bcbb0d10fa4.png",
"thumbnail_width": 490,
"type": "",
JSON Fields returned in the response
Parameter name | Type | Description |
---|---|---|
archived | bool | If True, the template will not show up in your dashboard, although the template will still be live |
category_id | string | The category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page |
cdn_minified_url | string | For javascript and css, this is the URL of the version of the content that has been rendered, minified, and uploaded to our Content Delivery Network |
cdn_url | string | For non-html templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN |
created | long | When the template was first created, in milliseconds since the epoch |
deleted_at | long | When the template was deleted, in milliseconds since the epoch. Zero if the template was never deleted. Use a DELETE request to template the page, do not set this directly. |
folder | string | The folder this template lives in |
generated_from_layout_id | string | The id of the layout that generated this template |
id | string | The unique id of the template |
is_available_for_new_content | string | True if this template will show up in the content creation screen |
is_from_layout | string | True if template was generated by publishing a layout. |
is_read_only | string | True if the template can only be read |
label | string | The label of the template as it shows up in the template builder |
path | string | The path of the template, as should be used for HubL include statements |
source | string | The markup of the template |
thumbnail_path | string | The thumbnail image of the template |
updated | long | When the template was last updated, in milliseconds since the epoch |
/content/api/v2/templates
Create a new coded template object in Design Manager.
Requirements
Parameters
This parameter category type:
- 0 - Unmapped
- 1 - Landing Pages
- 2 - Email
- 3 - Blog Post
- 4 - Site Page
The name of the folder to save the template in Design Manager.
This parameter accepts a numeric value and sets the type of template that is created. The following numbers correspond to specific template types:
- 2 - Email template
- 4 - Page template
- 11 - Error template
- 12 - Subscription preferences template
- 13 - Backup unsubscribe page template
- 14 - Subscriptions update confirmation template
- 19 - Password prompt page template
- 27 - Search results template
- 29 - Membership login template
- 30 - Membership registration template
- 31 - Membership reset password confirmation template
- 32 - Membership reset password request template
The Design Manager path to the directory that contains the file being created.
The source code of the file.
Used to determine if the template should be expected to pass page/content validation and be used with live content (if "True", the template source must contain the required variables for the template type).
This is equivalent to the "Make Available for New Content?" checkbox on Publish in the UI, and the "Template" vs. "Template Partial" radio select on template creation in the design manager beta.
- Default value is "False".
Response
xxxxxxxxxx
Example POST URL:
https://api.hubapi.com/content/api/v2/templates
Example POST body:
{
"category_id": 1,
"folder": "examples",
"is_available_for_new_content": "False",
"template_type": 4,
"path":"custom/page/examples/a-new-template.html",
"source":"The template source goes here"
}
Copy the contents of the auto-save buffer into the live Template
Copy the contents of the auto-save buffer into the live Template
/content/api/v2/templates/:template_id/push-buffer-live
Copies the contents of the UI auto-save buffer into the live template.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example POST URL:
http://api.hubapi.com/content/api/v2/templates/359393980/push-buffer-live
Does not take any data in the request body.
Example response:
{
"attached_stylesheets": [
],
"category_id": 1,
"cdn_minified_url": "",
"cdn_url": "",
"deleted_at": 0,
"enable_domain_stylesheets": null,
"folder": "examples",
"generated_from_layout_id": null,
"id": 359393980,
"include_default_custom_css": null,
"is_available_for_new_content": true,
"is_deletable": 1,
"is_from_layout": false,
"is_read_only": false,
"is_renameable": 1,
"is_theme_layout": false,
"label": "Simple-template",
"last_edit_session_id": null,
"last_edit_update_id": null,
"linked_style_id": "",
"migrated_from_style_manager": false,
"path": "custom/page/examples/simple-template.html",
"portal_id": 62515,
"source": {% raw %}"<html>\n <head>\n {{ content.html_title }}\n {{ standard_header_includes }}\n </head>\n <body>\n {% rich_text \"main_content\" html=\"This is the simplest possible template\" %}\n {{ standard_footer_includes }}\n </body>\n</html>",{% endraw %}
"template_type": 4,
"thumbnail_path": "http://cdn1.hubspot.com/hubshot/13/10/23/bd2b1b76-ae6e-4e49-963a-0bcbb0d10fa4.png",
"thumbnail_width": 490,
/content/api/v2/templates/:template_id/restore-deleted
Restore a previously deleted template.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example POST URL:
http://api.hubapi.com/content/api/v2/templates/359393980/restore-deleted
Does not take any data in the request body.
Example response:
{"succeeded": true, "message": "Action succeeded"}
/content/api/v2/templates/:template_id/versions/restore
Restore a previous version of the Template. The version_id in the request body is the ID of a specific revision of the template.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example POST URL:
http://api.hubapi.com/content/api/v2/templates/359393980/versions/restore
Example request body:
{"version_id":"3280956201"}
Example response:
{"succeeded": true, "message": "Action succeeded"}
/content/api/v2/templates/:template_id
Updates a template. If not all the fields are included in the body, we will only update the included fields.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example PUT URL:
https://api.hubapi.com/content/api/v2/templates/359393980
Example PUT body:
{
"source": "{% raw %}<html><head>{{ content.html_title }}{{ standard_header_includes }}</head><body>{% rich_text \"main_content\" html=\"This is the simplest possible template\" %}{{ standard_footer_includes }}</body></html>{% endraw %}"
}
Example response:
{
"attached_stylesheets": [
],
"category_id": 1,
"cdn_minified_url": "",
"cdn_url": "",
"deleted_at": 0,
"enable_domain_stylesheets": null,
"folder": "examples",
"generated_from_layout_id": null,
"id": 359393980,
"include_default_custom_css": null,
"is_available_for_new_content": true,
"is_deletable": 1,
"is_from_layout": false,
"is_read_only": false,
"is_renameable": 1,
"is_theme_layout": false,
"label": "Simple-template",
"last_edit_session_id": null,
"last_edit_update_id": null,
"linked_style_id": "",
"migrated_from_style_manager": false,
/content/api/v2/templates/:template_id/buffer
Updates the auto-save buffer. Live objects will not be impacted.
Requirements
Parameters
Unique identifier for a particular blog.
Response
xxxxxxxxxx
Example PUT URL:
api.hubapi.com/content/api/v2/templates/7352426967/buffer
Example PUT response:
{
"amp_validated": false,
"attached_amp_stylesheet": 0,
"attached_js": [],
"attached_stylesheets": [],
"body": {
"folder": "templates_folder",
"cdn_minified_url": null,
"cdn_url": "",
"has_user_changes": true,
"has_style_tag": false,
"has_menu_tag": false
},
"category": 1,
"category_id": 1,
"cdn_minified_url": "",
"cdn_url": "",
"content_tags": [],
"css_or_js_template": false,
"default": false,
"deleted": false,
"deleted_at": 0,
"description_i18n_key": "",
"extension_name": "",
"folder": "templates_folder",
"folder_id": 7352426969,
"has_style_tag": false,
"host_template_types": [
"ANY"
],
"id": 7352426967,
"is_available_for_new_content": false,
/content/api/v2/templates/:template_id
Marks the selected Template as deleted. The Template can be restored later via a POST to the restore-deleted endpoint.
Requirements
Parameters
Unique identifier for a particular blog.