Skip to main content

Templates

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.

GET/content/api/v2/templates

Get all templates. Supports paging and filtering.

Requirements
Scopes
  1. content
Auth Methods

Private apps

OAuth

Parameters
limit

Query param

The number of items to return. Defaults to 20.

offset

Query param

The offset set to start returning rows from. Defaults to 0.

deleted_at

Query param

exact, gt, lt

id

Query param

exact

is_available_for_new_content

Query param

exact

label

Query param

exact

path

Query param

exact

Response

Show more
JSON Fields returned in the response
Parameter nameTypeDescription
archivedboolIf True, the template will not show up in your dashboard, although the template will still be live
category_idstringThe category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page
cdn_minified_urlstringFor 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_urlstringFor non-HTML templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN
deleted_atlongWhen 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.
folderstringThe folder this template lives in
generated_from_layout_idstringThe id of the layout that generated this template
idstringThe unique id of the template
is_available_for_new_contentstringTrue if this template will show up in the content creation screen
is_from_layoutstringTrue if template was generated by publishing a layout
is_read_onlystringTrue if the template can only be read
labelstringThe label of the template as it shows up in the template builder
pathstringThe path of the template, as should be used for HubL include statements
sourcestringThe markup of the template
thumbnail_pathstringThe thumbnail image of the template
updatedlongWhen the template was last updated, in milliseconds since the epoch
Show more
GET/content/api/v2/templates/:template_id

Get a specific template by ID.

Requirements
Scopes
  1. content
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

The unique id of the template.

Response

Show more
JSON Fields returned in the response
Parameter nameTypeDescription
archivedboolIf True, the template will not show up in your dashboard, although the template will still be live
category_idstringThe category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page
cdn_minified_urlstringFor 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_urlstringFor non-html templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN
deleted_atlongWhen 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.
folderstringThe folder this template lives in
generated_from_layout_idstringThe id of the layout that generated this template
idstringThe unique id of the template
is_available_for_new_contentstringTrue if this template will show up in the content creation screen
is_from_layoutstringTrue if template was generated by publishing a layout.
is_read_onlystringTrue if the template can only be read
labelstringThe label of the template as it shows up in the template builder
pathstringThe path of the template, as should be used for HubL include statements
sourcestringThe markup of the template
thumbnail_pathstringThe thumbnail image of the template
updatedlongWhen the template was last updated, in milliseconds since the epoch
Show more

Gets the current contents of the auto-save buffer

GET/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
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
JSON Fields returned in the response
Parameter nameTypeDescription
category_idstringThe category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page
cdn_minified_urlstringFor 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_urlstringFor non-html templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN
createdlongWhen the template was first created, in milliseconds since the epoch
deleted_atlongWhen 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.
folderstringThe folder this template lives in
generated_from_layout_idstringThe id of the layout that generated this template
idstringThe unique id of the template
is_available_for_new_contentstringTrue if this template will show up in the content creation screen
is_from_layoutstringTrue if template was generated by publishing a layout.
is_read_onlystringTrue if the template can only be read
labelstringThe label of the template as it shows up in the template builder
pathstringThe path of the template, as should be used for HubL include statements
sourcestringThe markup of the template
thumbnail_pathstringThe thumbnail image of the template
updatedlongWhen the template was last updated, in milliseconds since the epoch
Show more

Determine if the auto-save buffer differs from the live Template

GET/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
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
GET/content/api/v2/templates/:template_id/versions

Get all previous versions of a template.

Requirements
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
GET/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
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

version_id*

Path param

Unique identifier for a specific version.

Response

Show more
JSON Fields returned in the response
Parameter nameTypeDescription
archivedboolIf True, the template will not show up in your dashboard, although the template will still be live
category_idstringThe category of content this template can be used for. 1 for landing page, 2 for email, 3 for site page
cdn_minified_urlstringFor 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_urlstringFor non-html templates, the URL to the version of the template that has been rendered and uploaded to the HubSpot CDN
createdlongWhen the template was first created, in milliseconds since the epoch
deleted_atlongWhen 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.
folderstringThe folder this template lives in
generated_from_layout_idstringThe id of the layout that generated this template
idstringThe unique id of the template
is_available_for_new_contentstringTrue if this template will show up in the content creation screen
is_from_layoutstringTrue if template was generated by publishing a layout.
is_read_onlystringTrue if the template can only be read
labelstringThe label of the template as it shows up in the template builder
pathstringThe path of the template, as should be used for HubL include statements
sourcestringThe markup of the template
thumbnail_pathstringThe thumbnail image of the template
updatedlongWhen the template was last updated, in milliseconds since the epoch
Show more
POST/content/api/v2/templates

Create a new coded template object in Design Manager.

Requirements
Auth Methods

Private apps

OAuth

Parameters
category_id

Body param

This parameter category type:

  • 0 - Unmapped
  • 1 - Landing Pages
  • 2 - Email
  • 3 - Blog Post
  • 4 - Site Page
folder

Body param

The name of the folder to save the template in Design Manager.

template_type

Body param

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
path

Body param

The Design Manager path to the directory that contains the file being created.

source

Body param

The source code of the file.

is_available_for_new_content

Body param

  • 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

Show more

Copy the contents of the auto-save buffer into the live Template

POST/content/api/v2/templates/:template_id/push-buffer-live

Copies the contents of the UI auto-save buffer into the live template.

Requirements
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
POST/content/api/v2/templates/:template_id/restore-deleted

Restore a previously deleted template.

Requirements
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
POST/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
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
PUT/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
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
PUT/content/api/v2/templates/:template_id/buffer

Updates the auto-save buffer. Live objects will not be impacted.

Requirements
Scopes
  1. content
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.

Response

Show more
DELETE/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
Auth Methods

Private apps

OAuth

Parameters
template_id*

Path param

Unique identifier for a particular blog.