Page API

This article displays API calls available for App (Portal Page) configuration:

  • /api/page: Allows retrieving, creating, updating, and deleting Apps, downloading assets from an App, and uploading assets to an App.

Prerequisites:

Table of contents:

  1. Access Admin > System > API Toolkit
  2. Retrieve Apps
  3. Create New App
  4. Delete App
  5. Download App Assets
  6. Upload App Assets

1. Access Admin > System > API Toolkit

2. Retrieve Apps

  • The GET request to /api/page returns all Apps (Portal Pages) data.
  • The GET request to /api/page/id/<ID> returns the selected App data
  1. Item: page
  2. Method: GET
  3. Optionally, filter the results by:
    • ID: Enter the App ID
    • internal_name: Enter the Internal Name of the App
  4. Enter an API Token
  5. [Run request]

Example Response

{
  "pages": [
    {
      "id": 190,
      "name": "Start",
      "internal_name": "start-page",
      "enabled": "Y",
      "visible_in_homepage": "Y",
      "template_id": 35,
      "template": "main page",
      "custom_domain": "subdomain.company.com",
      "base_url": "https://docs.metricinsights.com/p/start-page",
      "groups": []
    },
    {
      "id": 114,
      "name": "Sales KPIs",
      "internal_name": "SalesKPIs",
      "enabled": "Y",
      "visible_in_homepage": "Y",
      "template_id": null,
      "template": null,
      "custom_domain": null,
      "base_url": "https://docs.metricinsights.com/p/sales-kpis",
      "groups": [
        {
          "group_id": 63,
          "name": "Robert Group"
        }
      ]
    }
  ]
}

Fields Description

Parameter Name Value Type Description
id integer The ID of the App
name string The name of the App
internal_name string The Internal Name of the App used in URL
enabled string Whether the App is enabled.
  • Supported values: "Y" and "N"
visible_in_homepage string Whether the App is displayed on the homepage.
  • Supported values: "Y" and "N"
template_id
integer
The ID of the App's Template
template
string
The name of the App's Template
custom_domain
string
The Custom Domain of the App
base_url
string
The URL of the App
groups
array An array of objects representing Groups with access to the App
Below are the Group object parameters from the groups array:
group_id integer
The ID of the Group with access to the App
name string
The name of the Group with access to the App

3. Create New App

The POST request to /api/page creates a new App.

  1. Item: page
  2. Method: POST
  3. ID: Enter the ID of an existing App
  4. Select JSON request and modify the request body by providing the following values:
    • enabled: Whether or not the App is enabled
    • name: The name of the App
    • internal_name: The name used in the App's URL
      • NOTE: Letters, numbers, dashes and underscores are the only supported characters for Apps' URL names
    • visible_in_homepage: Whether the App is displayed on the homepage
  5. Enter an API Token
  6. [Run request]

4. Delete App

The DELETE request to /api/page/id/<page_id> deletes the selected App.

  1. Item: page
  2. Method: DELETE
  3. ID: Enter the ID of the App that needs to be deleted
  4. Enter an API Token
  5. [Run request]

5. Download App Assets

The GET request to /api/page/id/<app_id>/asset/download downloads a .zip file with App's assets.

Example:

$.ajax({
  url: "https://test.metricinsights.com/api/page/id/19/asset/download",
  method: "GET",
  headers: {
    "Authorization": "...", 
    "Cookie": "...",
  }
});

6. Upload App Assets

The POST request to /api/page/id/<app_id>/asset/upload uploads a .zip file with App's assets.

Example:

const form = new FormData();

form.append("file", fileInput.files[0], "C:/Users/Robert/Downloads/assets.zip");

$.ajax({
  url: "https://test.metricinsights.com/api/page/id/81/asset/upload",
  method: "POST", 
  headers: {
    "Authorization": "...", 
    "Cookie": "...",
  },
  processData: false,
  contentType: false,
  data: form
});