# Install Analytics Template

Install a template as your own page, or a bundle as pages in a new folder. Give a connection id, or null to skip, for every app the install plan lists. Synced data sources start fetching right away.

`POST https://connect.mindcloud.co/v2/analytics/templates/:templateId/install`

Permissions: `analytics:page:create`.

## Parameters

### Path

- `templateId` (string, required): The template id, from List Analytics Templates.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. Here a key acts in another organization only as one of its members: with "Use this key across all of your organizations" on, in an organization its creator belongs to with a role. Child organizations and MindCloud staff access do not reach this endpoint. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `connections` (object, required): A connection id or null for every app the install plan lists, keyed by app id or slug.
  One entry per app the template needs, keyed by the app's id or slug (from the install plan): a connection id (from the install plan or List Connections), or null to skip that app.
- `name` (string): A name for the new page (or a bundle's folder).
  A name for the new page, or for a bundle's new folder. Defaults to the template's name.
- `templateIds` (array): For a bundle, the members to install, from the install plan's members.
  For a bundle, the members to install (ids from the install plan's members). Defaults to every member you can install.

## Example request

```bash
curl --request POST \
  --url 'https://connect.mindcloud.co/v2/analytics/templates/Tp8Hm4Zk2RwN/install' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "connections": {
    "shopify": "Cn6vH3jW8qYt",
    "gmail": null
  },
  "name": "Store sales",
  "templateIds": [
    "Tp8Hm4Zk2RwN"
  ]
}'
```

## Response fields

- `kind` (string): page for one installed page; bundle for a bundle installed as pages in a new folder.
  Allowed values:
    - `page`
    - `bundle`
- `folderId` (string): The new folder holding a bundle's pages (List Analytics Folders), or null for a page template.
- `pages` (array of objects): The pages the install made.
  - `id` (string): The new page, now yours: read it with Get Analytics Page.
  - `templateId` (string): The template it was made from (for a bundle, the member).
  - `connectedAppIds` (array): The apps wired to the connections you gave. Their data sources are fetching now.
  - `skippedAppIds` (array): The apps you skipped. Their data sources and the panels reading them stay empty until you connect them.
- `reusedDataSourceCount` (number): How many of the template's data sources were ones you already had, from an earlier install: they are reused with their data. Null for a bundle.

## Errors

- 400 An app has no connection (ANALYTICS_TEMPLATE_CONNECTIONS_REQUIRED): `VALIDATION_FAILED` / `ANALYTICS_TEMPLATE_CONNECTIONS_REQUIRED` "Every app the template needs takes a connection id or null (skip it). Missing: shopify. Nothing was installed."
