Create, fetch, update, and delete, files in the HubSpot developer file system. Additionally you can validate files for different types of errors & warnings
environment
and path
parameters to identify files in the CMS Developer File System. These parameters are generally specified in the endpoint path itself, as in /cms/v3/source-code/{environment}/content/{path}
.
The environment
parameter refers to whether you are interacting with the unpublished or live version of each file. For unpublished changes, use draft
. For live changes, use published
.
published
is equivalent to pressing the “Publish” button in the Design Manager. As such, whatever is currently in draft
will be cleared.path
parameter refers to the location of the file in the CMS Developer File System. Top level assets are not preceded by a /
character as you would see in a UNIX based operating system. When uploading a new file, this should be the desired location where the file should be created. When retrieving or uploading changes to an existing file, this should match the path of the existing file.
We use the local file formats for all asset types, which means that certain types of assets are broken up into multiple files. For instance, a module is actually represented as a directory ending in the .module
suffix, so to retrieve the HTML for a module, one would need to use the path foo.module/module.html
. See the local development documentation for further information.
GET
request to /cms/v3/source-code/{environment}/content/{path}
and set the header to Accept: application/octet-stream
.
File data will be downloaded in binary format. You cannot download the entire contents of a folder. Instead, you must fetch the folder metadata and retrieve each of its children individually.
GET
request to /cms/v3/source-code/{environment}/metadata/{path}
and set the header to Accept: application/json
.
File and folder metadata will be returned in a JSON object:
folder: true
property.children
array will show the names of files and subfolders within the folder. These filenames can be used to traverse the folder tree: simply fetch one folder metadata and recursively fetch the children of the folder and all subfolders.PUT
request to /cms/v3/source-code/{environment}/content/{path}
. You must upload the file using the multipart/form-data
content type, and the binary file data must be included as a field named file
.
For example:
/cms/v3/source-code/published/content/my-new-file.html
Content-Type: multipart/form-data
Form Data: { file: [_binary file data_] }
/cms/v3/source-code/draft/content/path/to/existing-file.html
Content-Type: multipart/form-data
Form Data: { file: [_binary file data_] }
css
js
json
html
txt
md
jpg
jpeg
png
gif
map
svg
ttf
woff
woff2
zip
POST
request to /cms/v3/source-code/{environment}/validate/{path}
. You must upload the file using the multipart/form-data
content type, and the binary file data must be included as a field named file
.
This can be used to validate HubL in a template/module or JSON for a theme or module. If there are validation errors, you will receive a 400
response with the list of relevant errors. These are the same warnings and errors you would see within the design manager.
/cms/v3/source-code/published/validate/my-file.html
Content-Type: multipart/form-data
Form Data: { file: [_binary file data_] }
DELETE
request to /cms/v3/source-code/{environment}/content/{path}
.
Deleting from the published
environment will remove the file entirely, while deleting from the draft
environment will simply clear out any unpublished changes. Note that deleting published files will immediately impact live content if used anywhere, so make sure to remove all existing references to the file before deleting.
POST
request to /cms/v3/source-code/extract/{path}
.
The path
must be a zip file already uploaded to the account. The extraction process is asynchronous and can take up to a minute depending on how many and how large the compressed files are. The contents of the zip are extracted in place to the same folder that contains the zip file, and the original zip file is not deleted automatically upon successful extraction.