Page Template API
This article displays API calls available for App (Portal Page) Template configuration:
-
/api/page_template
: Allows retrieving Templates, downloading assets from a Template, and uploading assets to a Template.
Prerequisites:
- Set up API access
- Verify that you have API access and obtain a token via get_token call
Table of contents:
1. Access Admin > System > API Toolkit
2. Retrieve Templates
- The GET request to
/api/page_template
returns all App (Portal Page) Templates data. - The GET request to
/api/page_template/id/<ID>
returns the selected App Template data, including the version identifier.
- Item: page_template
- Optionally, filter the results by:
- ID: Enter the Template ID
- internal_name: Enter the Internal Name of the Template
- Enter an API Token
- [Run request]
Example Response
{
"page_templates": [
{
"id": 4,
"name": "Basic Template",
"internal_name": "Basic-Template",
"enabled": "Y",
"sync_with_git": "N",
"visible_in_homepage": "Y",
"display_without_nav_bar": "N",
"can_edit": "Y"
}
]
}
Fields Description
Parameter Name | Value Type | Description |
---|---|---|
id | integer | The ID of the App Template |
name | string | The name of the App Template |
enabled |
string |
Whether or not the App Template is enabled. Supported values: "Y", "N". |
sync_with_git |
string |
Whether or not the App Template is synced with Git. Supported values: "Y", "N". |
visible_in_homepage |
string |
Whether or not the App Template is in Homepage navigation bar. Supported values: "Y", "N". |
display_without_nav_bar |
string |
Whether or not the App Template is displayed without Metric Insights navigation bar. Supported values: "Y", "N". |
can_edit |
string |
Whether or not the user executing the API request can edit the App Template. Supported values: "Y", "N". |
3. Download Assets from Template
The GET request to /api/page_template/id/<template_id>/asset/download
downloads .zip file with Template's assets.
Example:
$.ajax({
url: "https://test.metricinsights.com/api/page_template/id/19/asset/download",
method: "GET",
headers: {
"Authorization": "...",
"Cookie": "...",
}
});
4. Upload Assets to Template
The POST request to /api/page_template/id/<template_id>/asset/upload
uploads a .zip file with Template's assets.
Example:
form.append("file", fileInput.files[0], "C:/Users/Robert/Downloads/assets.zip");
$.ajax({
url: "https://test.metricinsights.com/api/page_template/id/81/asset/upload",
method: "POST",
headers: {
"Authorization": "...",
"Cookie": "...",
},
processData: false,
contentType: false,
data: form
});