# Templates API Reference

Source: https://instatus.com/help/api/templates

## Get all page templates

**Endpoint:**

```bash
GET /v1/:page_id/templates?page=:page&per_page=:per_page
```

- The default page number is 1.
- The default per_page number is 50 and the maximum is 100 items per page.

**Example response:**

```json
[
  {
    "id": "cl9mq0ah50646mpvlmbrvf979",
    "type": "MAINTENANCE",
    "name": "Some Template",
    "nameTranslationId": null,
    "message": "",
    "messageTranslationId": null,
    "messageHtml": "",
    "messageHtmlTranslationId": null,
    "status": "NOTSTARTEDYET",
    "notify": true,
    "createdAt": "2022-10-24T11:53:46.505Z",
    "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
    "importedFrom": null,
    "deletedAt": null,
    "components": [],
    "translations": {
      "name": null,
      "message": null
    }
  },
  {
    "id": "cl9ranzrn0040xovluqicus6h",
    "type": "INCIDENT",
    "name": "Some Template 2",
    "nameTranslationId": null,
    "message": "We're currently investigating an issue with the Website",
    "messageTranslationId": null,
    "messageHtml": "<p>We&#39;re currently investigating an issue with the Website</p>",
    "messageHtmlTranslationId": null,
    "status": "INVESTIGATING",
    "notify": true,
    "createdAt": "2022-10-27T16:43:09.394Z",
    "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
    "importedFrom": null,
    "deletedAt": null,
    "components": [
      {
        "id": "cl9rbadkx0024lhvlicjbe304",
        "status": "MAJOROUTAGE",
        "isCustomPercentage": true,
        "componentId": "cl9fzgipf14075qjvljphlnwkk",
        "templateId": "cl9ranzrn0040xovluqicus6h",
        "importedFrom": null
      }
    ],
    "translations": {
      "name": null,
      "message": null
    }
  }
]
```

## Get a template

**Endpoint:**

```bash
GET /v1/:page_id/templates/:template_id
```

**Example response:**

```json
{
  "id": "cl9mq0ah50646mpvlmbrvf979",
  "type": "MAINTENANCE",
  "name": "Some Template",
  "nameTranslationId": null,
  "message": "",
  "messageTranslationId": null,
  "messageHtml": "",
  "messageHtmlTranslationId": null,
  "status": "NOTSTARTEDYET",
  "notify": true,
  "createdAt": "2022-10-24T11:53:46.505Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null,
  "deletedAt": null,
  "components": [],
  "translations": {
    "name": null,
    "message": null
  }
}
```

## Add a template

**Endpoint:**

```bash
POST /v1/:page_id/templates
```

**Example request:**

```json
{
  "subdomain": "some-subdomain",
  "type": "INCIDENT",
  "name": "Test template",
  "message": "We're currently investigating an issue with the Website",
  "status": "INVESTIGATING",
  "notify": true,
  "components": [
    {
      "id": "cl9fzgipf14075qjvljphlnwkk",
      "status": "PARTIALOUTAGE",
      "customImpactPercentage": 40
    }
  ],
  "translations": {
    "name": {
      "fr": "Modèle de test"
    },
    "message": {
      "fr": "Nous enquêtons actuellement sur un problème avec le site Web"
    }
  }
}
```

**Example response:**

```json
{
  "id": "cl9xobpoe00614tvldhh90t0w",
  "type": "INCIDENT",
  "name": "Test template",
  "nameTranslationId": null,
  "message": "We're currently investigating an issue with the Website",
  "messageTranslationId": null,
  "messageHtml": "<p>We&#39;re currently investigating an issue with the Website</p>",
  "messageHtmlTranslationId": null,
  "status": "INVESTIGATING",
  "notify": true,
  "createdAt": "2022-11-01T03:52:08.126Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null,
  "deletedAt": null,
  "components": [],
  "translations": {
    "name": {
      "fr": "Modèle de test"
    },
    "message": {
      "fr": "Nous enquêtons actuellement sur un problème avec le site Web"
    }
  }
}
```

## Update template

**Endpoint:**

```bash
PUT /v1/:page_id/templates/:template_id
```

**Example request:**

```json
{
  "type": "INCIDENT",
  "name": "Test template 2",
  "message": "We're currently investigating an issue with the Website",
  "status": "INVESTIGATING",
  "notify": true,
  "components": [
    {
      "id": "cl9fzgipf14075qjvljphlnwkk",
      "status": "MAJOROUTAGE"
    }
  ],
  "translations": {
    "name": {
      "fr": "Modèle de test"
    },
    "message": {
      "fr": "Nous enquêtons actuellement sur un problème avec le site Web"
    }
  }
}
```

**Example response:**

```json
{
  "id": "cl9ranzrn0040xovluqicus6h",
  "type": "INCIDENT",
  "name": "Test template 2",
  "nameTranslationId": null,
  "message": "We're currently investigating an issue with the Website",
  "messageTranslationId": null,
  "messageHtml": "<p>We&#39;re currently investigating an issue with the Website</p>",
  "messageHtmlTranslationId": null,
  "status": "INVESTIGATING",
  "notify": true,
  "createdAt": "2022-10-27T16:43:09.394Z",
  "siteId": "cl9fzgilx14063qjvl5oqdtxtg",
  "importedFrom": null,
  "deletedAt": null,
  "components": [
    {
      "id": "cl9xockck01654tvlwfn7vbaz",
      "status": "OPERATIONAL",
      "componentId": "cl9fzgipf14075qjvljphlnwkk",
      "templateId": "cl9ranzrn0040xovluqicus6h",
      "importedFrom": null
    }
  ],
  "translations": {
    "name": {
      "fr": "Modèle de test"
    },
    "message": {
      "fr": "Nous enquêtons actuellement sur un problème avec le site Web"
    }
  }
}
```

## Delete template

**Endpoint:**

```bash
DELETE /v1/:page_id/templates/:template_id
```

**Example response:**

```json
{
  "id": "cl9ra5iu20023bxvlu1x8bqj6",
  "name": "Test template",
  "message": "We're currently investigating an issue with the Website",
  "createdAt": "2022-10-27T16:28:47.642Z",
  "site": {
    "id": "cl9fzgilx14063qjvl5oqdtxtg"
  }
}
```
