# Update Event

## Update Event

<mark style="color:purple;">`PATCH`</mark> `https://environment.monterosa.cloud/api/v2/events/:event_id`

#### Path Parameters

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| event\_id | string | Event ID.   |

#### Headers

| Name          | Type   | Description                             |
| ------------- | ------ | --------------------------------------- |
| Authorization | string | Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb |
| Content-Type  | string | application/vnd.api+json                |

#### Request Body

| Name        | Type    | Description                                                                                                            |
| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| name        | string  | Event name.                                                                                                            |
| duration    | integer | Event duration in seconds.                                                                                             |
| start\_at   | integer | Planned event start time (timestamp).                                                                                  |
| start\_mode | string  | Start mode. Possible values: "manual", "clock".                                                                        |
| repeat      | boolean | Repeat mode.                                                                                                           |
| repeat\_in  | integer | When to start repeat event after previous event end, in minutes.                                                       |
| settings    | array   | List of fields of event settings. Each field is updated separately and if present its content is rewritten completely. |
| action      | string  | Set to perform action on event. Possible actions: `start` - start manual event; `stop` - stop event.                   |
| end\_mode   | string  | Event end mode. One of "duration", "scheduled".                                                                        |

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

```javascript
// no content
```

{% endtab %}
{% endtabs %}

## Example

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

```javascript
// PATCH /api/v2/events/2e9ddb8b-1ed0-4887-840a-9b37197a26e7
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "type": "events",
    "id": "126cd46d-02db-4369-84af-922cd0a8846b",
    "attributes": {
      "name": "Upcoming Event",
      "duration": 1800,
      "start_at": 1458927300,
      "start_at_iso": "2016-03-25T17:35:00Z",
      "start_mode": "clock",
      "end_mode": "scheduled",
      "repeat": true,
      "repeat_in": 60,
      "settings": [
        {
          "key": "hold_prompt",
          "values": {
            "en": "On hold..."
          }
        },
        {
          "key": "number_of_users",
          "values": {
            "all" : 6
          }
        }
      ]
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
// Status: 204 No Content
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request PATCH \
  --url https://environment.monterosa.cloud/api/v2/events/2e9ddb8b-1ed0-4887-840a-9b37197a26e7 \
  --header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
  --header 'Content-Type: application/vnd.api+json' \
  --data '{
    "data": {
      "type": "events",
      "id": "126cd46d-02db-4369-84af-922cd0a8846b",
      "attributes": {
        "name": "Upcoming Event",
        "duration": 1800,
        "start_at": 1458927300,
        "start_at_iso": "2016-03-25T17:35:00Z",
        "start_mode": "clock",
        "end_mode": "scheduled",
        "repeat": true,
        "repeat_in": 60,
        "settings": [
          {
            "key": "hold_prompt",
            "values": {
              "en": "On hold..."
            }
          },
          {
            "key": "number_of_users",
            "values": {
              "all" : 6
            }
          }
        ]
      }
    }
  }'
```

{% endtab %}
{% endtabs %}

### Actions on an event

An example how to start a manual event.

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

```javascript
// PATCH /api/v2/events/2e9ddb8b-1ed0-4887-840a-9b37197a26e7
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "id": "2e9ddb8b-1ed0-4887-840a-9b37197a26e7",
    "type": "events",
    "attributes": {
      "action": "start"
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```
// Status: 204 No Content
```

{% endtab %}
{% endtabs %}

### Validation error message that can't stop already finished event

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

```javascript
// PATCH /api/v2/events/7540ec1e-49b0-4283-9e37-e11624644fc1
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json

{
  "data": {
    "id": "7540ec1e-49b0-4283-9e37-e11624644fc1",
    "type": "events",
    "attributes": {
      "action": "stop"
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
// Status: 422 Unprocessable Entity

{
  "errors": [
    {
      "source": {
        "pointer": "/data/attributes/action"
      },
      "detail": "cannot stop event"
    }
  ]
}
```

{% endtab %}
{% endtabs %}
