# Scheduled Mutes API

Contents

* [Scheduled Mutes API](https://docs.hostedgraphite.com/alerting-guide/scheduled-mutes-api)
  * [Creating scheduled mutes](#creating-scheduled-mutes)
  * [Searching scheduled mutes](#searching-scheduled-mutes)
  * [Obtain information on a single scheduled mute](#obtain-information-on-a-single-scheduled-mute)
  * [Updating scheduled mutes](#updating-scheduled-mutes)
  * [Deleting scheduled mutes](#deleting-scheduled-mutes)

### [Creating scheduled mutes](#creating-scheduled-mutes)

<mark style="color:green;">`POST`</mark> `/v2/schedules/`

#### Path Parameters

| Name                                          | Type   | Description                                                                                                                                                                           |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>        | String | A name that uniquely identifies this scheduled mute.                                                                                                                                  |
| start\_time<mark style="color:red;">\*</mark> | String | A 24-hour time string at which the scheduled mute will begin.                                                                                                                         |
| duration<mark style="color:red;">\*</mark>    | String | Mute time in minutes.                                                                                                                                                                 |
| timezone                                      | String | The timezone string for this scheduled mute’s start time. Valid values are “UTC-12”...”UTC-1”, “UTC”, “UTC+1”...”UTC+14”. Defaults to “UTC” if not specified.                         |
| repeat                                        | String | The list of days at which the scheduled mute will repeat on. Becomes a one-time scheduled mute if not specified. Valid values are “mon”, “tue”, “wed”, “thu”, “fri”, “sat” and “sun”. |

{% tabs %}
{% tab title="201" %}

```http
HTTP/1.1 201 
Content-Type: application/json 
```

```json
{
  "id": "<scheduled_mute_id>",
  "url": "/v2/schedules/<scheduled_mute_id>"
}
```

{% endtab %}

{% tab title="400" %}
Bad Request Invalid
{% endtab %}

{% tab title="409" %}
Conflict Already exists
{% endtab %}
{% endtabs %}

**Request format**:

```
{
   "name": "string",
   "start_time": "14:20",
   "duration": 123,
   "timezone": "UTC-2",
   "repeat": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
}
```

**Curl example**

```
curl -H "Content-Type: application/json" -X POST -d \
'{"name": "Mute on weekends", "start_time": "00:00", "duration": 1440, "timezone": "UTC+2", "repeat": ["sat", "sun"]}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/schedules/"
```

Creates a scheduled mute named “Mute on weekends” that starts at 12 AM in timezone UTC+2, with a mute duration of 24 hours, and repeats every Saturday and Sunday.

***

### [Searching scheduled mutes](#searching-scheduled-mutes)

<mark style="color:blue;">`GET`</mark> `/v2/schedules/?`

Returns a JSON object containing information on scheduled mutes matching the search query. Returns all scheduled mutes if the parameter is left empty.

#### Path Parameters

| Name        | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name        | String | <p>Format: <code>\&name=\<scheduled\_mute\_name1>\&name=\<scheduled\_mute\_name2></code></p><p>The scheduled mute name to search for. Can specify multiple scheduled mute names to search for more than 1. Performs an <code>OR</code> operation so a query such as</p><p><code>\&name=\<scheduled\_mute\_name1>\&name=\<scheduled\_mute\_name2></code></p><p>will return info on both <code>scheduled\_mute\_name1</code> and <code>scheduled\_mute\_name2</code>.</p> |
| id          | String | <p>Format: <code>\&id=\<scheduled\_mute\_id1>\&id=\<scheduled\_mute\_id2></code></p><p>The scheduled mute ID to search for. Can specify multiple scheduled mute IDs to search for more than 1. Performs an <code>OR</code> operation so a query such as</p><p><code>\&name=\<scheduled\_mute\_id1>\&name=\<scheduled\_mute\_id2></code></p><p>will return info on both <code>scheduled\_mute\_id1</code> and <code>scheduled\_mute\_id2</code>.</p>                     |
| duration    | String | <p>Format: <code>\&duration=\<duration1>\&id=\<duration2></code></p><p>Searches for scheduled mutes by their duration. Can specify multiple durations to search for. Performs an <code>OR</code> operation so a query such as</p><p><code>\&duration=30\&duration=10</code></p><p>will return scheduled mutes with a 10-minute duration or a 30-minute duration.</p>                                                                                                    |
| start\_time | String | <p>Format: <code>\&start\_time=\<start\_time1>\&start\_time=\<start\_time2></code></p><p>Searches for scheduled mutes by their start time. Can specify multiple start times to search for. Performs an OR operation so a query such as</p><p><code>\&start\_time=12:00\&start\_time=20:00</code></p><p>will return scheduled mutes that start at either 12 PM or 8 PM.</p>                                                                                              |
| timezone    | String | <p>Format: <code>\&timezone=\<timezone1>\&timezone=\<timezone2></code></p><p>Searches for scheduled mutes by their timezone. Can specify multiple time zones to search for. Performs an OR operation so a query such as</p><p><code>\&timezone=UTC+2\&timezone=UTC-14</code></p><p>will return scheduled mutes that have either UTC+2 or UTC-14 time zones.</p>                                                                                                         |
| repeat      | String | <p>Format: <code>\&repeat=\<day1>\&repeat=\<day2></code></p><p>Searches for scheduled mutes by their repeat days. Can specify multiple repeat days to search for. Performs an OR operation so a query such as</p><p>\&repeat=sun\&repeat=thu</p><p>will return scheduled mutes that repeat on either Sunday or Thursday.</p>                                                                                                                                            |
| page        | String | <p>Format: <code>\&page=1</code></p><p>The page number to query. Used if there are more items that can be displayed in a single request (default: 1).</p>                                                                                                                                                                                                                                                                                                               |
| max         | String | <p>Format: <code>\&max=50</code></p><p>The maximum number of items to display. Limit of 100 (default: 100).</p>                                                                                                                                                                                                                                                                                                                                                         |

{% tabs %}
{% tab title="200" %}

```http
HTTP/1.1 200 
Content-Type: application/json 
```

```json
{
  "scheduled_mutes": [
    {
      "name": "Maintenance Window",
      "id": "mute_id_1",
      "duration": 60,
      "alerts": ["alert_id1", "alert_id2", "alert_id3"],
      "start_time": "20:20",
      "timezone": "UTC+4",
      "repeat": ["mon", "wed", "fri"]
    },
    {
      "name": "Holiday Quiet Hours",
      "id": "mute_id_2",
      "duration": 120,
      "alerts": ["alert_id4", "alert_id5"],
      "start_time": "18:00",
      "timezone": "UTC+1",
      "repeat": ["sat", "sun"]
    }
  ],
  "next_page": false
}

```

{% endtab %}

{% tab title="400" %}
Bad Request Invalid
{% endtab %}
{% endtabs %}

**Curl example:**

```bash
curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/schedules/?"
```

Specifying multiple fields performs an `OR` operation and returns scheduled mutes that match either criterion.

***

### [Obtain information on a single scheduled mute](#obtain-information-on-a-single-scheduled-mute)

<mark style="color:blue;">`GET`</mark> `/v2/schedules/<scheduled_mute_id>/`

Returns information on a single scheduled mute identified by `<scheduled_mute_id>`.

{% tabs %}
{% tab title="200" %}

```http
HTTP/1.1 200 
Content-Type: application/json 
```

```json
{
  "name": "Maintenance Window",
  "id": "mute_id_1",
  "duration": 123,
  "alerts": ["alert_id1", "alert_id2", "alert_id3"],
  "start_time": "20:20",
  "timezone": "UTC+4",
  "repeat": ["mon", "wed", "fri"]
}

```

{% endtab %}

{% tab title="404" %}
Not Found Scheduled mute doesn’t exist.
{% endtab %}
{% endtabs %}

**Curl example:**

```
curl -X GET "https://YOUR-API-KEY@api.hostedgraphite.com/v2/schedules/123-456-789/"
```

Obtain information on the scheduled mute identified by the ID `123-456-789`.

***

### [Updating scheduled mutes](#updating-scheduled-mutes)

<mark style="color:orange;">`PUT`</mark> `/v2/schedules/<scheduled_mute_id>/`

Updates the attributes of a scheduled mute identified by `<scheduled_mute_id>`.

#### Path Parameters

| Name        | Type   | Description                                                                                                                                                                           |
| ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name        | String | A name that uniquely identifies this scheduled mute.                                                                                                                                  |
| start\_time | String | A 24-hour time string at which the scheduled mute will begin                                                                                                                          |
| duration    | String | Mute time in minutes.                                                                                                                                                                 |
| timezone    | String | The timezone string for this scheduled mute’s start time. Valid values are “UTC-12”...”UTC-1”, “UTC”, “UTC+1”...”UTC+14”. Defaults to “UTC” if not specified.                         |
| repeat      | String | The list of days at which the scheduled mute will repeat on. Becomes a one-time scheduled mute if not specified. Valid values are “mon”, “tue”, “wed”, “thu”, “fri”, “sat” and “sun”. |

{% tabs %}
{% tab title="200" %}

```json
{
  "name": "string",
  "start_time": "14:20",
  "duration": 123,
  "timezone": "UTC-2",
  "repeat": [
    "mon",
    "tue",
    "wed",
    "thu",
    "fri",
    "sat",
    "sun"
  ]
}
```

{% endtab %}

{% tab title="400" %}
Bad Request Invalid
{% endtab %}

{% tab title="404" %}
Not Found Scheduled mute doesn’t exist.
{% endtab %}

{% tab title="409" %}
Conflict Scheduled mute with the updated name already exists.
{% endtab %}
{% endtabs %}

**Curl example:**

```
curl -H "Content-Type: application/json" -X PUT \
-d '{"start_time": "14:50", "timezone": "UTC+12"}' \
"https://YOUR-API-KEY@api.hostedgraphite.com/v2/schedules/123-456-789/"
```

Updates the start time and timezone of the scheduled mute with the id `123-456-789.`

Each field is optional and only the specified fields are updated.

***

### [Deleting scheduled mutes](#deleting-scheduled-mutes)

<mark style="color:red;">`DELETE`</mark> `/v2/schedules/<scheduled_mute_id>/`

Deletes a scheduled mute identified by `<scheduled_mute_id>`.

{% tabs %}
{% tab title="200 " %}
OK
{% endtab %}

{% tab title="404" %}
Not Found Scheduled mute doesn’t exist.
{% endtab %}
{% endtabs %}

**Curl example:**

```
curl -X DELETE "https://YOUR-API-KEY@api.hostedgraphite.com/v2/schedules/123-456-789/"
```

Delete the scheduled mute identified by the ID `123-456-789`.
