

# Event messages
<a name="iot-events"></a>

This section contains information about messages published by AWS IoT when things or jobs are updated or changed. For information about the AWS IoT Events service that allows you to create detectors to monitor your devices for failures or changes in operation, and to trigger actions when they occur, see [AWS IoT Events](https://aws.amazon.com/iot-events).

## How event messages are generated
<a name="iot-events-how"></a>

AWS IoT publishes event messages when certain events occur. For example, events are generated by the registry when things are added, updated, or deleted. Each event causes a single event message to be sent. Event messages are published over MQTT with a JSON payload. The content of the payload depends on the type of event.

**Note**  
Event messages are guaranteed to be published once. It is possible for them to be published more than once. The ordering of event messages is not guaranteed.

### Policy for receiving event messages
<a name="iot-events-policy"></a>

To receive event messages, your device must use an appropriate policy that allows it to connect to the AWS IoT device gateway and subscribe to MQTT event topics. You must also subscribe to the appropriate topic filters.

The following is an example of the policy required for receiving lifecycle events:

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iot:Subscribe",
                "iot:Receive"
            ],
            "Resource": [
                "arn:aws:iot:us-east-1:123456789012:/$aws/events/*"
            ]
        }
    ]
}
```

## Enable events for AWS IoT
<a name="iot-events-enable"></a>

Before subscribers to the reserved topics can receive messages, you must enable event messages from the AWS Management Console or by using the API or CLI. For information about the event messages that the different options manage, see the [Table of AWS IoT event configuration settings](#iot-events-settings-table).
+ To enable event messages, go to the [Settings](https://console.aws.amazon.com//iot/home#/settings) tab of the AWS IoT console and then, in the **Event-based messages** section, choose **Manage events**. You can specify the events that you want to manage.
+ To control which event types are published by using the API or CLI, call the [UpdateEventConfigurations](https://docs.aws.amazon.com/iot/latest/apireference/API_UpdateEventConfigurations.html) API or use the **update-event-configurations** CLI command. For example:

  ```
  aws iot update-event-configurations --event-configurations "{\"THING\":{\"Enabled\": true}}"
  ```

**Note**  
All quotation marks (") are escaped with a backslash (\$1).

You can get the current event configuration by calling the [DescribeEventConfigurations](https://docs.aws.amazon.com/iot/latest/apireference/API_DescribeEventConfigurations.html) API or by using the **describe-event-configurations** CLI command. For example:.

```
aws iot describe-event-configurations
```<a name="iot-events-settings-table"></a>

**Table of AWS IoT event configuration settings**


|  Event category  (AWS IoT Console: Settings: Event-based messages)  |  `eventConfigurations` key value (AWS CLI/API)  |    Event message topic  | 
| --- | --- | --- | 
|  *(Can only be configured by using the AWS CLI/API)*  |  `CA_CERTIFICATE`  |  `$aws/events/certificates/registered/caCertificateId`  | 
|  *(Can only be configured by using the AWS CLI/API)*  |  `CERTIFICATE`  |  `$aws/events/presence/connected/clientId`  | 
|  *(Can only be configured by using the AWS CLI/API)*  |  `CERTIFICATE`  |  `$aws/events/presence/disconnected/clientId`  | 
|  *(Can only be configured by using the AWS CLI/API)*  |  `CERTIFICATE`  |  `$aws/events/subscriptions/subscribed/clientId`  | 
|  *(Can only be configured by using the AWS CLI/API)*  |  `CERTIFICATE`  |  `$aws/events/subscriptions/unsubscribed/clientId`  | 
|  Job completed, canceled  |  `JOB`  |  `$aws/events/job/jobID/canceled`  | 
|  Job completed, canceled  |  `JOB`  |  `$aws/events/job/jobID/cancellation_in_progress`  | 
|  Job completed, canceled  |  `JOB`  |  `$aws/events/job/jobID/completed`  | 
|  Job completed, canceled  |  `JOB`  |  `$aws/events/job/jobID/deleted`  | 
|  Job completed, canceled  |  `JOB`  |  `$aws/events/job/jobID/deletion_in_progress`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/canceled`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/deleted`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/failed`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/rejected`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/removed`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/succeeded`  | 
|  Job execution: success, failed, rejected, canceled, removed  |  `JOB_EXECUTION`  |  `$aws/events/jobExecution/jobID/timed_out`  | 
|  Thing: created, updated, deleted  |  `THING`  |  `$aws/events/thing/thingName/created`  | 
|  Thing: created, updated, deleted  |  `THING`  |  `$aws/events/thing/thingName/updated`  | 
|  Thing: created, updated, deleted  |  `THING`  |  `$aws/events/thing/thingName/deleted`  | 
|  Thing group: added, removed  |  `THING_GROUP`  |  `$aws/events/thingGroup/thingGroupName/created`  | 
|  Thing group: added, removed  |  `THING_GROUP`  |  `$aws/events/thingGroup/thingGroupName/updated`  | 
|  Thing group: added, removed  |  `THING_GROUP`  |  `$aws/events/thingGroup/thingGroupName/deleted`  | 
|  Thing group hierarchy: added, removed  |  `THING_GROUP_HIERARCHY`  |  `$aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/added`  | 
|  Thing group hierarchy: added, removed  |  `THING_GROUP_HIERARCHY`  |  `$aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/removed`  | 
|  Thing group membership: added, removed  |  `THING_GROUP_MEMBERSHIP`  |  `$aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/added`  | 
|  Thing group membership: added, removed  |  `THING_GROUP_MEMBERSHIP`  |  `$aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/removed`  | 
|  Thing type: created, updated, deleted  |  `THING_TYPE`  |  `$aws/events/thingType/thingTypeName/created`  | 
|  Thing type: created, updated, deleted  |  `THING_TYPE`  |  `$aws/events/thingType/thingTypeName/updated`  | 
|  Thing type: created, updated, deleted  |  `THING_TYPE`  |  `$aws/events/thingType/thingTypeName/deleted`  | 
|  Thing type association: added, removed  |  `THING_TYPE_ASSOCIATION`  |  `$aws/events/thingTypeAssociation/thing/thingName/thingType/thingTypeName/added` `$aws/events/thingTypeAssociation/thing/thingName/thingType/thingTypeName/removed`  | 